updated RPC command to match javascripting language
Dependencies: EthernetInterface HTTPServerExample mbed-rpc mbed-rtos mbed
Fork of EthHTTPServer by
main.cpp
- Committer:
- leihen
- Date:
- 2013-08-17
- Revision:
- 5:c5c2f7026638
- Parent:
- 1:6cbd17e628f1
- Child:
- 6:fde802d0f163
File content as of revision 5:c5c2f7026638:
#include "mbed.h" #include "HTTPServer.h" #include "FsHandler.h" #include "LocalFileSystem.h" #include "RpcHandler.h" #include "mbed_rpc.h" #define ALTERNATIVE //#undef ALTERNATIVE // Use LED1 to indicate that the main loop is still executing DigitalOut myled(LED1); // Use the serial connection 'pc' to dump debug information Serial pc(USBTX, USBRX, "pc"); // Instantiate a HTTPServer to handle incoming requests HTTPServer svr; // Instantiate a local file system handler named 'local' which will be used later to access files on the mbed. LocalFileSystem local("local"); #ifdef ALTERNATIVE // Create the EthernetInterface. This is optional, please see the documentation of HTTP Server's start method. EthernetInterface eth; #endif int main() { pc.baud(460800); RPC::add_rpc_class<RpcDigitalOut>(); HTTPFsRequestHandler::mount("/local/", "/"); svr.addHandler<HTTPFsRequestHandler>("/"); svr.addHandler<HTTPRpcRequestHandler>("/RPC"); #ifdef ALTERNATIVE // Initialize the EthernetInterface and initiate a connection using DHCP. eth.init(); eth.connect(); if (!svr.start(80, ð)) { #else if (!svr.start()) { #endif error("Server not starting !"); exit(0); } while(1) { svr.poll(); myled = 1; wait(0.2); myled = 0; wait(0.2); } }