rpc_over_http
Dependencies: EthernetNetIf HTTPServer mbed
Revision 0:d020b026a3f5, committed 2015-06-06
- Comitter:
- zeeshan0123
- Date:
- Sat Jun 06 08:28:43 2015 +0000
- Commit message:
- rpc_over_http
Changed in this revision
diff -r 000000000000 -r d020b026a3f5 EthernetNetIf.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetNetIf.lib Sat Jun 06 08:28:43 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mamezu/code/EthernetNetIf/#0f6c82fcde82
diff -r 000000000000 -r d020b026a3f5 HTTPServer.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPServer.lib Sat Jun 06 08:28:43 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/HTTPServer/#d753966e4d97
diff -r 000000000000 -r d020b026a3f5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jun 06 08:28:43 2015 +0000 @@ -0,0 +1,63 @@ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "HTTPServer.h" + +DigitalOut led1(LED1, "led1"); +DigitalOut led2(LED2, "led2"); +DigitalOut led3(LED3, "led3"); +PwmOut zoom(LED4, "zoomo"); +AnalogIn temperature(p20, "tempo"); + +LocalFileSystem fs("webfs"); + +EthernetNetIf eth; +HTTPServer svr; + +int main() { + Base::add_rpc_class<AnalogIn>(); + Base::add_rpc_class<AnalogOut>(); + Base::add_rpc_class<DigitalIn>(); + Base::add_rpc_class<DigitalOut>(); + Base::add_rpc_class<PwmOut>(); + Base::add_rpc_class<Timer>(); + Base::add_rpc_class<BusOut>(); + Base::add_rpc_class<BusIn>(); + + printf("Setting up...\n"); + EthernetErr ethErr = eth.setup(); + if(ethErr) + { + printf("Error %d in setup.\n", ethErr); + return -1; + } + printf("Setup OK\n"); + + FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path + FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path + + svr.addHandler<SimpleHandler>("/hello"); + svr.addHandler<RPCHandler>("/rpc"); + svr.addHandler<FSHandler>("/files"); + svr.addHandler<FSHandler>("/"); //Default handler + //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm + + svr.bind(80); + + printf("Listening...\n"); + + Timer tm; + tm.start(); + //Listen indefinitely + while(true) + { + Net::poll(); + if(tm.read()>.5) + { + led1=!led1; //Show that we are alive + tm.start(); + } + } + + return 0; + +} \ No newline at end of file
diff -r 000000000000 -r d020b026a3f5 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jun 06 08:28:43 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da