WiFi WebServer for ESP8266
Fork of ESP8266_WebServer by
ESP8266_WebServer.h
- Committer:
- sschocke
- Date:
- 2015-01-01
- Revision:
- 1:1c4333ce7448
- Parent:
- 0:56c72c87d2f5
- Child:
- 2:6079554681d6
File content as of revision 1:1c4333ce7448:
#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); void SendFile(int linkID, FileHandle* file, const char* mimeType); }; #endif