Tried to switch a led on and of through rpc but IP adress stays unchanged and the url to write the led gives a httpserver error

Dependencies:   EthernetInterface HTTPServer mbed-rpc mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 #include "HTTPServer.h"
00004 #include "mbed_rpc.h"
00005 #include "RpcHandler.h"
00006 
00007 RpcDigitalOut led2(LED2, "led2");   // define Rpc digital output object
00008 HTTPServer svr;         //  define HTTP server object
00009 EthernetInterface eth;  // create ethernet interface
00010 Serial pc(USBTX, USBRX);
00011 
00012 int main(){
00013 
00014     pc.baud(115200);
00015     pc.printf("does it work? ");
00016     
00017     RPC::add_rpc_class<RpcDigitalOut>();
00018     eth.init("192.168.1.101"," 255.255.255.0"," 192.168.1.27");  // initialise interface with DCHP ("192.168.1.101"," 255.255.255.0"," 192.168.1.27")
00019     eth.connect();      // connect and open communications
00020     pc.printf("IP Address is %s\n", eth.getIPAddress());   // display IP address
00021     svr.addHandler<HTTPRpcRequestHandler>("/rpc");  // add handler to server object
00022     svr.start(80, &eth); // bind server to port 80
00023     
00024         while(1)
00025         {
00026             svr.poll(); // continuously poll for Ethernet messages to server
00027         }
00028 }
00029