-
Notifications
You must be signed in to change notification settings - Fork 13
Webserver
Note: UIP_CONF_BUFFER_SIZE Must be set to max size of CGI generated header + TCP/IP-header (60 Bytes) If no MSS is set, MSS will be (UIP_CONF_BUFFER_SIZE - 60) Note that also a possible router has to support this MSS!
The webserver provides 3 different complexity levels selectable using the define WEBSERVER_CONF_NANO
.
nano::
WEBSERVER_CONF_NANO=1
- 2 connections
- cgi
- txt
- 16byte filenames
micro::
WEBSERVER_CONF_NANO=2
- 20byte filenames
- ajax
mini::
WEBSERVER_CONF_NANO=2
There are several ways for storing the servers web content. Beside the different storage locations such as EEPROM, internal flash, external flash or SD card there are also different 'file system' types supported.
http-fs::
The most simple way is to include the raw data into system storage at compilation time.
The file httpd-fsdata.c
contains the web content.
It is generated using the PERL script /tools/makefsdata
coffee:: To use coffee the standard file system of contiki, do this and that...
FAT:: You can also use the FAT driver to access webserver data. This is espeacially advised in comibination with an SD card as it provides the possibility to transfer content from an external source to the webserver
Create and Add a CGI script:
-
create generator function:
static unsigned short generate_any_content(void *arg) { // do nice stuff here... return httpd_snprintf("custom text"); }
-
create socket handler
static PT_THREAD(any_content(struct httpd_state *s, char *ptr)) { PSOCK_BEGIN(&s->sout); PSOCK_GENERATOR_SEND(&s->sout, generate_any_content, (void *) ptr); PSOCK_END(&s->sout); }
-
creat cgi call
HTTPD_CGI_CALL(my_content, "my_content_name", any_content);
-
Add cgi call
httpd_cgi_add(&my_content)
To include the script in an html page, you need to add such a a line to your .shtml file.
!% my_content_name
Note: The webserver scans for script includes only in files ending with
.shtml
. Files ending with.html
or.htm
will not be scanned.
tbd