
An example HTTP Server using new Ethernet Interface and localfilesystem.
Dependencies: EthernetInterface HttpServer mbed-rpc mbed-rtos mbed
Fork of giken9_HTMLServer_Sample by
main.cpp
- Committer:
- mkilivan
- Date:
- 2014-12-23
- Revision:
- 5:d98cf6df5187
- Parent:
- 3:f0c16cc3a4ef
- Child:
- 6:116ca781e161
File content as of revision 5:d98cf6df5187:
//#define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */ #include "mbed.h" #include "rtos.h" #include "EthernetInterface.h" #include "HTTPServer.h" #include "mbed_rpc.h" EthernetInterface eth; LocalFileSystem local("local"); DigitalOut led4(LED4); void LcdWrite(Arguments* arg, Reply* r);void LcdWrite(Arguments* arg, Reply* r); void aliveState(void const *args) { while (true) { led4 = !led4; Thread::wait(1000); } } int main() { printf("********* PROGRAM START ***********\r\n"); Thread thread(aliveState); printf("********* RPC Initialize ***********\r\n"); RPC::add_rpc_class<RpcDigitalOut>(); RPC::construct<RpcDigitalOut, PinName, const char*>(LED1, "led1"); RPC::construct<RpcDigitalOut, PinName, const char*>(LED2, "led2"); RPC::construct<RpcDigitalOut, PinName, const char*>(LED3, "led3"); RPCFunction rpcFunc(LcdWrite, "LcdWrite"); printf("EthernetInterface Setting up...\r\n"); if(eth.init()!=0) { //for DHCP Server printf("EthernetInterface Initialize Error \r\n"); return -1; } if(eth.connect()!=0) { printf("EthernetInterface Connect Error \r\n"); return -1; } printf("IP Address is %s\r\n", eth.getIPAddress()); printf("NetMask is %s\r\n", eth.getNetworkMask()); printf("Gateway Address is %s\r\n", eth.getGateway()); printf("Ethernet Setup OK\r\n"); FSHandler::mount("/local","/"); HTTPServerStart(80); }