Sensor with Web Server
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
HTTPServer.h@0:c385e589a779, 2014-04-08 (annotated)
- Committer:
- afilipem
- Date:
- Tue Apr 08 12:13:32 2014 +0000
- Revision:
- 0:c385e589a779
1 version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afilipem | 0:c385e589a779 | 1 | #ifndef HTTP_SERVER |
afilipem | 0:c385e589a779 | 2 | #define HTTP_SERVER |
afilipem | 0:c385e589a779 | 3 | |
afilipem | 0:c385e589a779 | 4 | #include <map> |
afilipem | 0:c385e589a779 | 5 | |
afilipem | 0:c385e589a779 | 6 | #include "mbed.h" |
afilipem | 0:c385e589a779 | 7 | #include "mbed_rpc.h" |
afilipem | 0:c385e589a779 | 8 | #include "RequestHandler.h" |
afilipem | 0:c385e589a779 | 9 | #include "Formatter.h" |
afilipem | 0:c385e589a779 | 10 | #include "EthernetInterface.h" |
afilipem | 0:c385e589a779 | 11 | #include "RPCCommand.h" |
afilipem | 0:c385e589a779 | 12 | |
afilipem | 0:c385e589a779 | 13 | |
afilipem | 0:c385e589a779 | 14 | class HTTPServer |
afilipem | 0:c385e589a779 | 15 | { |
afilipem | 0:c385e589a779 | 16 | public : |
afilipem | 0:c385e589a779 | 17 | |
afilipem | 0:c385e589a779 | 18 | HTTPServer(Formatter *f = new Formatter()); |
afilipem | 0:c385e589a779 | 19 | virtual ~HTTPServer(); |
afilipem | 0:c385e589a779 | 20 | |
afilipem | 0:c385e589a779 | 21 | bool init(int port); |
afilipem | 0:c385e589a779 | 22 | |
afilipem | 0:c385e589a779 | 23 | void run(); |
afilipem | 0:c385e589a779 | 24 | |
afilipem | 0:c385e589a779 | 25 | void add_request_handler(char *name, RequestHandler* handler); |
afilipem | 0:c385e589a779 | 26 | |
afilipem | 0:c385e589a779 | 27 | private : |
afilipem | 0:c385e589a779 | 28 | |
afilipem | 0:c385e589a779 | 29 | void handle_request(char *buffer); |
afilipem | 0:c385e589a779 | 30 | |
afilipem | 0:c385e589a779 | 31 | TCPSocketServer socket; |
afilipem | 0:c385e589a779 | 32 | std::map<char*, RequestHandler*, bool(*)(char*, char*)> handlers; |
afilipem | 0:c385e589a779 | 33 | Formatter *formatter; |
afilipem | 0:c385e589a779 | 34 | char reply[RPC_MAX_STRING]; |
afilipem | 0:c385e589a779 | 35 | RPCCommand command; |
afilipem | 0:c385e589a779 | 36 | }; |
afilipem | 0:c385e589a779 | 37 | |
afilipem | 0:c385e589a779 | 38 | #endif |
afilipem | 0:c385e589a779 | 39 |