Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HTTPServer WIZnetInterface mbed-rpc DHT mbed-src
Diff: main.cpp
- Revision:
- 0:ca442200bc8a
- Child:
- 1:cffa64d79a8b
diff -r 000000000000 -r ca442200bc8a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 22 09:41:02 2015 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "HTTPServer.h" +#include "mbed_rpc.h" + +RpcDigitalOut led1(LED1,"led1"); + +EthernetInterface eth; +HTTPServer svr; + +int main() { + //Turn the LEDs off + uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x00, 0x00}; + led1.write(1); + + RPC::add_rpc_class<RpcDigitalOut>(); + + printf("Setting up...\n"); + eth.init(mac_addr); + int ethErr = eth.connect(); + if(ethErr < 0) + { + printf("Error %d in setup.\n", ethErr); + return -1; + } + + svr.addHandler<HTTPRpcRequestHandler>("/rpc"); + + //attach server to port 80 + svr.start(80, ð); + + printf("Listening...\n"); + + Timer tm; + tm.start(); + //Listen indefinitely + while(true) + { + svr.poll(); + if(tm.read()>.5) + { + tm.start(); + } + } +} \ No newline at end of file