Post topics, source code that relate to the Arduino Platform

User avatar
By GregShu
#58107 esp_httpd is a simple, entirely event-driven HTTP server for serving files and responding to RESTful requests, intended for use in Arduino-based projects. An ESP8266's underlying networking framework presents an event-driven interface so it was decided that all interaction with the networking framework would use this interface.

To be useful in a variety of projects it was decided that esp_httpd should be able to:

  • Serve files stored in flash using SPIFFS. These files will be static HTML, CSS, JS and images that comprise the host device's web interface.
  • Differentiate between GET, POST, PUT, and DELETE requests. This is how the host device will correctly respond to AJAX requests.
  • Parse key-value pairs in the URI or body. Data to be parsed can be submitted in the URI as a typical GET query string, or as key-value pairs in the body as in a typical POST. The data parsing should not be automatic in case raw or JSON-encoded data is sent in the body.
  • Route to different handlers based on the URI furnished, with support for a trailing wildcard and cascading handlers.
  • Use C-strings exclusively in place of Arduino String objects in an effort to minimize the potential for heap fragmentation.
This solution was greatly inspired by libesphttpd (https://github.com/Spritetm/libesphttpd). In fact, I originally intended to use libesphttpd in my own projects but ran into troubles I couldn't overcome (due to my own limitations, not the library's). Because I knew I didn't need all the functionality, and the resulting complexity, that libesphttpd offers I decided to start a new httpd library from scratch. At least this way I "should" understand what it is doing and why. :-)

The aspect of libesphttpd that really caught my attention was the routing array. I appreciate how the array codifies URI's to which the server is prepared to respond. Because esp_httpd is intended to be used in a RESTful manner it expands the routes specification to include the required method, if any.

esp_httpd is very much a work in progress - my first GitHub submitted projects. Your feedback is welcome and greatly appreciated.

https://github.com/gregschumacher/esp_httpd
User avatar
By arinmihai
#59057 Hello,

I just found your library. I tried to see if the examples work.
* @example ConnectWiFi.ino
* @brief The ConnectWiFi demo of library WeeESP8266.

In the example you are not starting the Serial1 used for comunication. So you get just errors.

void setup(void)
{
Serial.begin(115200);
Serial.print("setup begin\r\n");

Serial1.begin(115200);
Serial.print("Serial 1 Started");

Serial.print("FW Version: ");
Serial.println(wifi.getVersion().c_str());

Thanks.