HTTPD

From Ethersex_Wiki
Jump to: navigation, search
HTTPD
Status
Stable
menuconfig Applications->HTTP Server->HTTPD
Pinning -
Ecmd -
Control6 -
Depends on  ?
Requires  ?
Code  ?


Web server on the ethersex

The built-in web server in Ethersex can read the files it should serve from various locations:

  • from an external dataflash
  • files stored in the flash memory of the MCU right after the firmware
  • run ECMD commands and serve the results (for AJAX)

Any of these sources for data can be enabled independent of the others. The easiest option is to initially keep the files in the internal flash memory and to access dynamic content via the HTTP ECMD interface.

Configuration

General Setup  --->
[*] VFS (Virtual File System) support  --->
| |     [ ] Atmel SPI Dataflash           |  
| |     [*] VFS File Inlining             |  
| |     [ ] SD/MMC-Card Access            |  
| |     [ ] EEPROM (24cxx) Raw Access     |  
| |     [-] DC3840 Camera                 |  
...
Applications  --->
| |     [*] HTTP Server                   |  
| |     [ ]   Basic Authentication        |  
...
Applications ---> 
Etherrape Control Interface (ECMD) --->
| | [*] ECMD support                |

Embedding files

If the option Supply Inline Files is enabled, all files stored in vfs/embed/ will be automatically packed with gzip and appended to the end of the firmware when building the image. Filenames remain unchanged, however the maximum length of filenames is 6 characters.

Preprocess files with the C preprocessor or m4

To include files dependent on configuration options (or not) respectively including only parts, if a certain option is enabled, they can be preprocessed by cpp or m4, before the output is packed and appended to the firmware. For that, the file must end in .cpp or .m4. When using cpp, all defines from config.h/autoconf.h are accessible (e.g. ~np~ONEWIRE_SUPPORT~/np~). When using m4, ~np~ONEWIRE_SUPPORT turns into conf_ONEWIRE ~/np~.

Content type of the files

Because the web server can not dynamically determine the content type, this information needs to be supplied in advance. The content type is determined by the first character of the file name:

  • S (e.g. Sty.c): text/css
  • X (e.g. Xow.ht): application/xhtml+xml;
  • everything else is served as text/html

Access files from the SD card

To serve files from an SD card, they are copied to the SD card. These can then be accessed by the browser via the following URL (IP and file

name must of course be changed)
http://192.168.23.244/Filename

If the file is located in a folder on the SD card, it can be accessed via the

following URL.
http://192.168.23.244/Foldername/Filename

The length of filenames is not limited to 6 characters with the SD card.

Manually triggering ECMD commands (via HTTP)

To query the IP via ECMD, the following URL (the IP must of course be changed) can be accessed with the browser, returning the output via HTTP.

http://192.168.23.244/ecmd?ip

In order to use commands containing spaces, e.g. "1w list", the spaces must be replaced with "+" or "%20". The following command lists 1-wire sensors, if any are present:

http://192.168.23.244/ecmd?1w+list

or

http://192.168.23.244/ecmd?1w%20list

Ethersex start page

If the web server is compiled in, when accessing http://YOUR_ETHERSEX_IP/ the browser should show such a page:

Ethersex-screen-startseite.png

Dataflash

TODO