WiFi WebServer for ESP8266
Fork of ESP8266_WebServer by
Diff: ESP8266_WebServer.h
- Revision:
- 0:56c72c87d2f5
- Child:
- 1:1c4333ce7448
diff -r 000000000000 -r 56c72c87d2f5 ESP8266_WebServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ESP8266_WebServer.h Thu Jan 01 10:11:55 2015 +0000 @@ -0,0 +1,70 @@ +#include "mbed.h" +#include <string> +#include <map> +#include <queue> +#include <list> + +#ifndef _ESP8266_WEB_SERVER_H +#define _ESP8266_WEB_SERVER_H + +const char mimeHTML[] = "text/html"; +const char mimeJavaScript[] = "text/javascript"; +const char mimeCSS[] = "text/css"; +const char mimeJPEG[] = "image/jpeg"; +const char mimePNG[] = "image/png"; + +class ESP8266_WebRequest +{ + char httpMethod[64]; + char httpURI[512]; + char* data; + Serial *debugSerial; + + public: + ESP8266_WebRequest(const char* packet, Serial* debug); + ~ESP8266_WebRequest(); + int LinkID; + void Read(void); + std::string Method; + std::string URI; + std::map<std::string, std::string> Parameters; +}; + +class ESP8266_WebServer +{ + Serial *serial; + char buffer[1024]; + char reply[1024]; + char response[2048]; + char reqBuffer[1024]; + volatile char* rxptr; + volatile char* rxptrStored; + volatile bool reqMode; + volatile int ipdLen; + volatile int reqLen; + std::queue<ESP8266_WebRequest*, std::list<ESP8266_WebRequest*> > incoming; + + private: + short data_waiting(void); + short string_waiting(const char*); + void readBuffer(void); + void sendResponse(int linkID, int numBytes); + void queueRequest(void); + + public: + Serial *debugSerial; + bool echoMode; + + ESP8266_WebServer(Serial *espUART); + void rxint(void); + void debugBuffers(Serial* target); + void Initialize(void); + ESP8266_WebRequest* GetRequest(void); + void SendError(int linkID, std::string error); + void SendError(int linkID, const char* error); + void Send404Error(int linkID); + void SendReply(int linkID, std::string reply, const char* mimeType); + void SendReply(int linkID, const char* reply, int replySize, const char* mimeType); +}; + +#endif \ No newline at end of file