Skip to content

Modifications to the main esphttpd to add large file post support

Notifications You must be signed in to change notification settings

billprozac/esphttpd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-httpd OTA Edition README

################################
This is mostly just mods to Spritemods esphttpd
I have added the OTA functionality and a few other common requests, but the below is all still true

*** Note *** I move to using esptool.py, so the process of flashing is much easier.  
There is no more resetting involved. The whole process is much easier.
################################

This is a small but powerful webserver for ESP8266(EX) chips. Included is an example of how
to make a module that can have the AP it connects to configured over a webbrowser.

ABOUT THE WEBSERVER

The Good (aka: what's awesome)
 - Supports multiple connections, for eg simultaneous html/css/js/images downloading
 - Static files stored in flash, in an (optionally compressed) RO filesystem
 - Pluggable using external cgi routines
 - Simple template engine for mixed c and html things
 - Supports OTA building and flashing
 - Supports quickly changing build SDKs by changing SDK_VERSION

The Bad (aka: what can be improved)
 - Not built for speediness, although it's reasonable fast.
 - Built according to what I remember of the HTTP protocol, not according to the
   RFCs. Should work with most modern browsers, though.
 - No support for https.
 - Code written by me... sorry in advance ;)

The Ugly (aka: bugs, misbehaviour)
- Possible buffer overflows (usually not remotely exploitable) due to no os_snprintf
  This can be theoretically remedied by either Espressif including an os_snprintf in 
  their libs or by using some alternate printf lib, like elm-chans xprintf

ABOUT THE EXAMPLE

When you flash the example into an ESP8266(EX) module, you get a small webserver with a few example
pages. If you've already connected your module to your WLAN before, it'll keep those settings. When
you haven't or the settings are wrong, keep GPIO0 for >5 seconds. The module will reboot into
its STA+AP mode. Connect a computer to the newly formed access point and browse to 
http://192.168.4.1/wifi in order to connect the module to your WiFi network. The example also
allows you to control a LED that's connected to GPIO2.

BUILDING EVERYTHING

For this, you need an environment that can compile ESP8266 firmware. Environments for this still
are in flux at the moment, but I'm using esp-open-sdk: https://github.com/pfalcon/esp-open-sdk .
You probably also need an UNIX-like system; I'm working on Debian Linux myself. 

To manage the paths to all this, you can source a small shell fragment into your current session. For
example, I source a file with these contents:
export PATH=${PWD}/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
export SDK_ROOT=${PWD}/esp-open-sdk/
export SDK_VERSION=1.0.0
export ESPTOOLPY=${PWD}/esptool/esptool.py
export ESPPORT=/dev/ttyUSB0
export ESPBAUD=460800
export ESP_IPADDRESS=192.168.4.1 // When the device is up and connected to your AP, this IP can be used for OTA flashes

Actual setup of the SDK and toolchain is out of the scope of this document, so I hope this helps you
enough to set up your own if you haven't already. 

If you have that, you can clone out the source code:
git clone https://github.com/billprozac/esphttpd

(original upstream source) http://git.spritesserver.nl/esphttpd.git/

This project makes use of heatshrink, which is a git submodule. To fetch the code:
cd esphttpd
git submodule init
git submodule update

You should then modify the file lib/heatshrink/heatshrink_decoder.h and change line 4 from 
#include <stdint.h>
to
//#include <stdint.h>

Now, build the code and pack the static files for the website:
make
make flash

You should have a working webserver now.

WRITING CODE FOR THE WEBSERVER

...errm... to be done. For now, look at the examples. Hey, you probably managed to find out how
the SDK works, this shouldn't be too hard :P


CHANGE FROM SDK 0.9.3 (and earlier) TO SDK 0.9.4 (and later):
Change all occurences of
espconn_sent(connData->conn, (uint8 *)buff, len);
to
httpdSend(connData, buff, len)
please. The reason for this is that you can't do multiple espconn_sent calls serially anymore, so
httpd needs to buffer the writes now. This is only needed in your own code; the code that comes
with httpd already has this changed.


About

Modifications to the main esphttpd to add large file post support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published