WiFi WebServer for ESP8266
Fork of ESP8266_WebServer by
ESP8266_WebServer.h
- Committer:
- sschocke
- Date:
- 2015-01-01
- Revision:
- 3:4ef7db7a95a7
- Parent:
- 2:6079554681d6
- Child:
- 4:759de84e790b
- Child:
- 5:48b7fd921bef
File content as of revision 3:4ef7db7a95a7:
#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"; const char mimeGIF[] = "image/gif"; const char mimeText[] = "text/plain"; 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, char const* reply, int replySize, const char* mimeType); void SendReply(int linkID, char const* reply, int replySize, const char* mimeType, int maxAge); void SendReply(int linkID, char const* reply, const char* mimeType, int maxAge); void SendFile(int linkID, FileHandle* file, const char* mimeType); void SendFile(int linkID, FileHandle* file, const char* mimeType, int maxAge); }; #endif