Running a server on a different port, plus using TLS


#1

First off, this is my first microcontroller project, so apologies if I’m misunderstanding anything or if this should go in a platform-specific section.

I’m hoping to code a simple Gemini protocol server to run on my Cardputer through uLisp. I’m trying to figure out how viable the project is, and it seems like it’s manageable, but I’m running into a couple of issues that I’m trying to understand. I think they’re fixable problems, but they appear to need some changes to the .ino file used to flash, and since I’m not used to working with the constraints of microcontrollers, I figured I should do some research and, if that doesn’t work, ask some people who know better than me.

By default, (wifi-server) starts listening on port 80, but Gemini specifies port 1965. Having tracked this back through the Arduino libraries WiFi.h, WiFiServer.h, and a couple others, I can’t see any real reason this is fixed. It just opens a generic TCP port, nothing specific to the port it’s running on. I also can’t see anything in the ESP32-S3FN8 datasheet that suggests there’s any sort of limit on ports. Is there any reason I shouldn’t just change the default port to whatever I need?

I also need to use TLS because the Gemini protocol specification requires it, and this chip does have support for it built-in. I’ve managed to find the library for it, so if I managed to figure out how to access it through the Arduino IDE so I can #include it, how reasonable would it be to include? Compilation claims the sketch uses 36% of program storage space, plus 73% of dynamic memory for global variables, so space constraints might be relevant, but it seems feasible so far. I could maybe try to do something in uLisp to add the functionality, but it seems much easier to use the preexisting library if I can tap into it.

Thanks for any advice. Even if you don’t know for sure, if you know any resources that might help me figure it out, they would be appreciated.


#2

By default, (wifi-server) starts listening on port 80, but Gemini specifies port 1965.

There’s a line in the uLisp source that specifies the port for wifi-server:

WiFiServer server(80);

I think it should work if you change this to 1965 before uploading uLisp.

I also need to use TLS because the Gemini protocol specification requires it

I don’t have any experience of using uLisp with TLS. I’m pretty sure you would have to make changes to the Wi-Fi initialisation in uLisp. Perhaps someone else has had experience of doing this?


#3

So that isn’t hard coded due to a restriction or something? I was planning to tweak that, but I didn’t know if that was set because of some limitation, although there’s nothing I can think to expect.

Yeah, once I figure out how to get the ESP32 TLS library accessible in the Arduino IDE, I’m planning to use it to tweak functionality. I’m not too worried about figuring out how to do that. My main concern is seeing the memory usage and the maximums listed in the IDE after I compile the normal version. It’s reporting pretty high usage of some portions of available space, so I was afraid that introducing the extra functionality might be an unreasonable burden when I still need to implement a simple server with what’s left. However, I think I might be misunderstanding the various types of memory available in a microcontroller like this because neither the max of 3,342,336 bytes in program storage space nor the max of 327,680 bytes align with anything I’m seeing on the data sheet. Even combined, that’s less than half the flash memory, and I thought the part about dynamic memory might be talking about the RAM, but the Cardputer should have 512 KB of RAM, so just over 320 KB doesn’t line up with that, either. I suspect I need to do more research on the different types of storage space in microcontrollers and how tools like the Arduino IDE evaluate and use that space.


#4

I forgot to answer this in your original question:

Compilation claims the sketch uses 36% of program storage space, plus 73% of dynamic memory for global variables, so space constraints might be relevant

The uLisp source allocates as much of the dynamic memory as possible to the Lisp workspace before the compiler gives a low memory warning message. You can simply increase the amount of dynamic memory available, if necessary, by reducing the WORKSPACE figure in the line:

#define WORKSPACESIZE 22250          /* Cells (8*bytes) */