HTTP (RPC) Server mit UI
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
Fork of IoTKit_RPC-Server by
HTTP (RPC) Server mit eigener UI Oberfläche.
Board mit dem Ethernet verbinden. Console starten und angezeigte IP-Adresse notieren und in Browser öffnen.
Create Object
Type: DigitalOut Name: led1 arg(optional): PTB22
und Create Button drücken.
Call a function
Command: /led1/write 1
eingeben und Send drücken. Das rote LED auf dem Board geht aus. Mittels /led1/write 0 wird es wieder eingeschaltet.
Für die komplette Dokumentation siehe /users/feb11/code/HTTP-Server/
HTTPServer.h@0:9e4bcb10b3e3, 2013-07-17 (annotated)
- Committer:
- feb11
- Date:
- Wed Jul 17 10:15:05 2013 +0000
- Revision:
- 0:9e4bcb10b3e3
Initial import
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
feb11 | 0:9e4bcb10b3e3 | 1 | #ifndef HTTP_SERVER |
feb11 | 0:9e4bcb10b3e3 | 2 | #define HTTP_SERVER |
feb11 | 0:9e4bcb10b3e3 | 3 | |
feb11 | 0:9e4bcb10b3e3 | 4 | #include <map> |
feb11 | 0:9e4bcb10b3e3 | 5 | |
feb11 | 0:9e4bcb10b3e3 | 6 | #include "mbed.h" |
feb11 | 0:9e4bcb10b3e3 | 7 | #include "mbed_rpc.h" |
feb11 | 0:9e4bcb10b3e3 | 8 | #include "RequestHandler.h" |
feb11 | 0:9e4bcb10b3e3 | 9 | #include "Formatter.h" |
feb11 | 0:9e4bcb10b3e3 | 10 | #include "EthernetInterface.h" |
feb11 | 0:9e4bcb10b3e3 | 11 | #include "RPCCommand.h" |
feb11 | 0:9e4bcb10b3e3 | 12 | |
feb11 | 0:9e4bcb10b3e3 | 13 | |
feb11 | 0:9e4bcb10b3e3 | 14 | class HTTPServer |
feb11 | 0:9e4bcb10b3e3 | 15 | { |
feb11 | 0:9e4bcb10b3e3 | 16 | public : |
feb11 | 0:9e4bcb10b3e3 | 17 | |
feb11 | 0:9e4bcb10b3e3 | 18 | HTTPServer(Formatter *f = new Formatter()); |
feb11 | 0:9e4bcb10b3e3 | 19 | virtual ~HTTPServer(); |
feb11 | 0:9e4bcb10b3e3 | 20 | |
feb11 | 0:9e4bcb10b3e3 | 21 | bool init(int port); |
feb11 | 0:9e4bcb10b3e3 | 22 | |
feb11 | 0:9e4bcb10b3e3 | 23 | void run(); |
feb11 | 0:9e4bcb10b3e3 | 24 | |
feb11 | 0:9e4bcb10b3e3 | 25 | void add_request_handler(char *name, RequestHandler* handler); |
feb11 | 0:9e4bcb10b3e3 | 26 | |
feb11 | 0:9e4bcb10b3e3 | 27 | private : |
feb11 | 0:9e4bcb10b3e3 | 28 | |
feb11 | 0:9e4bcb10b3e3 | 29 | void handle_request(char *buffer); |
feb11 | 0:9e4bcb10b3e3 | 30 | |
feb11 | 0:9e4bcb10b3e3 | 31 | TCPSocketServer socket; |
feb11 | 0:9e4bcb10b3e3 | 32 | std::map<char*, RequestHandler*, bool(*)(char*, char*)> handlers; |
feb11 | 0:9e4bcb10b3e3 | 33 | Formatter *formatter; |
feb11 | 0:9e4bcb10b3e3 | 34 | char reply[RPC_MAX_STRING]; |
feb11 | 0:9e4bcb10b3e3 | 35 | RPCCommand command; |
feb11 | 0:9e4bcb10b3e3 | 36 | }; |
feb11 | 0:9e4bcb10b3e3 | 37 | |
feb11 | 0:9e4bcb10b3e3 | 38 | #endif |
feb11 | 0:9e4bcb10b3e3 | 39 |