+TCP HTTP server

Is there any comments or suggestions about a more full featured HTTP server for freertos? For one of my last projects I used the FreeRTOS_HTTP_Server, and extended it to allow POST. For my next project, I’d like something a bit more full featured.

Is FreeRTOS_HTTP_Server intended to be a demo only, or what was/is the real intent of this labs project?

What sort of challenges will be faced to integrate something like civetweb?

Any other embedded webserver suggestions would be appreciated here.

1 Like

The HTTP and FTP servers were intended to become official libraries but for now are just to be considered demos as I’m not sure when we will do the work necessary to harden and fully review them.

What are the system requirements for civetweb?

Well, the parent project mongoose seems to be used on lots of embedded devices, so it seems to be in the ballpark.

The embedding information says
Master thread uses poll() and accept() to accept new connections on listening sockets. poll() is used to avoid FD_SETSIZE limitation of select() . Since there are only a few listening sockets, there is no reason to use hi-performance alternatives like epoll() or kqueue() . Worker threads use blocking IO on accepted sockets for reading and writing data. All accepted sockets have SO_RCVTIMEO and SO_SNDTIMEO socket options set (controlled by the request_timeout_ms CivetWeb option, 30 seconds default) which specifies a read/write timeout on client connections.

So I’d need to sort that out.

FreeRTOS+TCP (our own TCP stack) has select(), but not poll() - it also enables sockets to set send and receive block times - so just from the little pasted here it is probably feasible to port - but presumably there is an interface to a file system of some sort as well as the network interface?

Erik,

What did you end up selecting for your FreeRTOS HTTP server?

I’ve added some features to the stock server. Essentially I’ve built a file system with processing capabilities into this server. It works sort of like this…

The exe runs and reads a script file built like this -

[WEBROOT]
C:/SomeWhere/web/build
[OUTPUT_SRC]
C:/SomeWhere/firmware/src/http
[OUTPUT_HDR]
C:/SomeWhere/firmware/inc/http
[INCLUDE]
http/httpROMFS.h
[NAME]
httpROMFS
[REDIRECTS]
status /
[SCRIPTS]
api/firmware.php POST firmware_POST_php json 0x1000000
api/setup.php GET setup_GET_php json 0
[FILES]
*.js
*.html
*.css
*.map
favicon.ico
api/siteDefaults/*.*
static/media/*.*
*.LICENSE
bsd.txt

Which builds a file system and headers for the custom scripts defined in [SCRIPTS]

The scripts would be defined like this -

_httpResponse setup_GET_php(uint8_t *data, uint32_t len, uint8_t * urlParams) {
  _httpResponse resp = { .responseCode = 200, .gz = 0, .sendFile = 0 };
  resp.data = buildSetupJson();
  if (resp.data == NULL) {
    resp.data = malloc(64);
    resp.responseCode = 500;
    resp.len = sprintf(resp.data, "JSON builder error");
  }
  resp.len = strlen(resp.data);
  return resp;
}

The file system gzips what it can. In my case, I store it in qspi flash, but the shim layer could use internal flash easily.

I might be interested in open sourcing this, It’d be nice if something similar could be built by freertos.

1 Like

That looks like a good solution.

Sorry, I don’t have time to polish this up, but this is a working demo on a STM32 NUCLEO board. If you need a license added to a core file I missed let me know.