Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ESP8266_WebServer mbed
Fork of WiFiLamp by
ESP8266_WebServer/ESP8266_WebServer.h@11:3ab606a42227, 2014-12-28 (annotated)
- Committer:
- sschocke
- Date:
- Sun Dec 28 16:04:22 2014 +0000
- Revision:
- 11:3ab606a42227
- Parent:
- 9:319aeb6e0123
- Child:
- 20:f5a6527bfda6
WebServer API Updates for multiple content types
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sschocke | 5:42c6f9d916bc | 1 | #include "mbed.h" |
| sschocke | 7:f15c81074400 | 2 | #include <string> |
| sschocke | 9:319aeb6e0123 | 3 | #include <map> |
| sschocke | 5:42c6f9d916bc | 4 | |
| sschocke | 5:42c6f9d916bc | 5 | #ifndef _ESP8266_WEB_SERVER_H |
| sschocke | 5:42c6f9d916bc | 6 | #define _ESP8266_WEB_SERVER_H |
| sschocke | 5:42c6f9d916bc | 7 | |
| sschocke | 11:3ab606a42227 | 8 | const char mimeHTML[] = "text/html"; |
| sschocke | 11:3ab606a42227 | 9 | const char mimeJavaScript[] = "text/javascript"; |
| sschocke | 11:3ab606a42227 | 10 | const char mimeCSS[] = "text/css"; |
| sschocke | 11:3ab606a42227 | 11 | const char mimeJPEG[] = "image/jpeg"; |
| sschocke | 11:3ab606a42227 | 12 | const char mimePNG[] = "image/png"; |
| sschocke | 11:3ab606a42227 | 13 | |
| sschocke | 9:319aeb6e0123 | 14 | class ESP8266_WebRequest |
| sschocke | 9:319aeb6e0123 | 15 | { |
| sschocke | 9:319aeb6e0123 | 16 | char httpMethod[64]; |
| sschocke | 9:319aeb6e0123 | 17 | char httpURI[512]; |
| sschocke | 9:319aeb6e0123 | 18 | |
| sschocke | 9:319aeb6e0123 | 19 | public: |
| sschocke | 9:319aeb6e0123 | 20 | ESP8266_WebRequest(int linkID, const char* packet, Serial* debugSerial); |
| sschocke | 9:319aeb6e0123 | 21 | int LinkID; |
| sschocke | 9:319aeb6e0123 | 22 | std::string Method; |
| sschocke | 9:319aeb6e0123 | 23 | std::string URI; |
| sschocke | 9:319aeb6e0123 | 24 | std::map<std::string, std::string> Parameters; |
| sschocke | 9:319aeb6e0123 | 25 | }; |
| sschocke | 9:319aeb6e0123 | 26 | |
| sschocke | 5:42c6f9d916bc | 27 | class ESP8266_WebServer |
| sschocke | 5:42c6f9d916bc | 28 | { |
| sschocke | 7:f15c81074400 | 29 | Serial *serial; |
| sschocke | 7:f15c81074400 | 30 | char buffer[1024]; |
| sschocke | 7:f15c81074400 | 31 | char reply[1024]; |
| sschocke | 7:f15c81074400 | 32 | char response[2048]; |
| sschocke | 7:f15c81074400 | 33 | char* rxptr; |
| sschocke | 5:42c6f9d916bc | 34 | |
| sschocke | 7:f15c81074400 | 35 | private: |
| sschocke | 7:f15c81074400 | 36 | short data_waiting(void); |
| sschocke | 7:f15c81074400 | 37 | short string_waiting(const char*); |
| sschocke | 7:f15c81074400 | 38 | void readBuffer(void); |
| sschocke | 11:3ab606a42227 | 39 | void sendResponse(int linkID, int numBytes); |
| sschocke | 9:319aeb6e0123 | 40 | |
| sschocke | 7:f15c81074400 | 41 | public: |
| sschocke | 7:f15c81074400 | 42 | Serial *debugSerial; |
| sschocke | 7:f15c81074400 | 43 | |
| sschocke | 7:f15c81074400 | 44 | ESP8266_WebServer(Serial *espUART); |
| sschocke | 7:f15c81074400 | 45 | void rxint(void); |
| sschocke | 7:f15c81074400 | 46 | void Initialize(void); |
| sschocke | 9:319aeb6e0123 | 47 | ESP8266_WebRequest* GetRequest(void); |
| sschocke | 11:3ab606a42227 | 48 | void SendError(int linkID, std::string error); |
| sschocke | 11:3ab606a42227 | 49 | void SendError(int linkID, const char* error); |
| sschocke | 11:3ab606a42227 | 50 | void Send404Error(int linkID); |
| sschocke | 11:3ab606a42227 | 51 | void SendReply(int linkID, std::string reply, const char* mimeType); |
| sschocke | 11:3ab606a42227 | 52 | void SendReply(int linkID, const char* reply, int replySize, const char* mimeType); |
| sschocke | 7:f15c81074400 | 53 | }; |
| sschocke | 7:f15c81074400 | 54 | |
| sschocke | 5:42c6f9d916bc | 55 | #endif |
