HTTP RPC Server mit vordefinierten Objekten

Dependencies:   EthernetInterface HttpServer Servo mbed-rtos mbed

Fork of RPCHTTPServerVariable by th.iotkit2.ch

Mittels RPCVariable lassen sich lokale Variablen setzen. Diese Variablen können gesetzt write oder gelesen read werden.

Mittels Ticker u.ä. Varianten lassen sich damit auch Objektwerte setzen, welche von RPC nicht unterstützt werden, z.B. Servo's.

Client

Wert setzen: http://<IP-Adresse mbed>/rpc/servo2/write+0.5

Committer:
stefan1691
Date:
Wed Mar 11 17:48:42 2015 +0000
Revision:
9:66ff9ae5572e
Parent:
8:3e6bfb96a451
Child:
10:f92d1e679fea
Minimalistischer RCP HTTP Server

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefan1691 9:66ff9ae5572e 1 /** Minimalistischer RCP HTTP Server
stefan1691 9:66ff9ae5572e 2 */
yueee_yt 0:050a5d4ffd55 3 #include "mbed.h"
yueee_yt 0:050a5d4ffd55 4 #include "rtos.h"
yueee_yt 0:050a5d4ffd55 5 #include "EthernetInterface.h"
yueee_yt 0:050a5d4ffd55 6 #include "HTTPServer.h"
yueee_yt 3:5758cfefe980 7 #include "mbed_rpc.h"
yueee_yt 5:bfa9878aa274 8
yueee_yt 0:050a5d4ffd55 9 EthernetInterface eth;
yueee_yt 3:5758cfefe980 10
yueee_yt 0:050a5d4ffd55 11 int main()
yueee_yt 0:050a5d4ffd55 12 {
stefan1691 9:66ff9ae5572e 13 printf("RPC HTTP Server\n");
stefan1691 9:66ff9ae5572e 14 eth.init(); //Use DHCP
stefan1691 9:66ff9ae5572e 15 eth.connect();
stefan1691 9:66ff9ae5572e 16 printf("IP Address is %s\n\r", eth.getIPAddress());
stefan1691 9:66ff9ae5572e 17
stefan1691 9:66ff9ae5572e 18 // Klassen
yueee_yt 3:5758cfefe980 19 RPC::add_rpc_class<RpcDigitalOut>();
marcel1691 7:8a319a112fba 20
stefan1691 9:66ff9ae5572e 21 // Objekte
stefan1691 9:66ff9ae5572e 22 RPC::construct<RpcDigitalOut, PinName, const char*>(D10, "led1");
stefan1691 9:66ff9ae5572e 23 RPC::construct<RpcDigitalOut, PinName, const char*>(D11, "led2");
stefan1691 9:66ff9ae5572e 24 RPC::construct<RpcDigitalOut, PinName, const char*>(D12, "led3");
stefan1691 9:66ff9ae5572e 25 RPC::construct<RpcDigitalOut, PinName, const char*>(D13, "led4");
yueee_yt 3:5758cfefe980 26
stefan1691 9:66ff9ae5572e 27 // Handler
yueee_yt 3:5758cfefe980 28 HTTPServerAddHandler<RPCHandler>("/rpc");
stefan1691 9:66ff9ae5572e 29
stefan1691 9:66ff9ae5572e 30 // Start HTTP Server auf Port 80
stefan1691 9:66ff9ae5572e 31 printf( "Starte Server\n" );
yueee_yt 0:050a5d4ffd55 32 HTTPServerStart(80);
yueee_yt 0:050a5d4ffd55 33 }
yueee_yt 0:050a5d4ffd55 34