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
main.cpp@0:c20da8fd007a, 2017-04-14 (annotated)
- Committer:
- Frostworks
- Date:
- Fri Apr 14 13:47:37 2017 +0000
- Revision:
- 0:c20da8fd007a
I tried to switch a led on and off with rcp for mbed frdm k64f, it does compile but it doesn't change the ip to 192.168.1.101 and both the weburl http://192.168.1.101/rpc/led2/write0 and; http://192.168.1.27/rpc/led2/write1 give an httpserver error
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Frostworks | 0:c20da8fd007a | 1 | #include "mbed.h" |
Frostworks | 0:c20da8fd007a | 2 | #include "EthernetInterface.h" |
Frostworks | 0:c20da8fd007a | 3 | #include "HTTPServer.h" |
Frostworks | 0:c20da8fd007a | 4 | #include "mbed_rpc.h" |
Frostworks | 0:c20da8fd007a | 5 | #include "RpcHandler.h" |
Frostworks | 0:c20da8fd007a | 6 | |
Frostworks | 0:c20da8fd007a | 7 | RpcDigitalOut led2(LED2, "led2"); // define Rpc digital output object |
Frostworks | 0:c20da8fd007a | 8 | HTTPServer svr; // define HTTP server object |
Frostworks | 0:c20da8fd007a | 9 | EthernetInterface eth; // create ethernet interface |
Frostworks | 0:c20da8fd007a | 10 | Serial pc(USBTX, USBRX); |
Frostworks | 0:c20da8fd007a | 11 | |
Frostworks | 0:c20da8fd007a | 12 | int main(){ |
Frostworks | 0:c20da8fd007a | 13 | |
Frostworks | 0:c20da8fd007a | 14 | pc.baud(115200); |
Frostworks | 0:c20da8fd007a | 15 | pc.printf("does it work? "); |
Frostworks | 0:c20da8fd007a | 16 | |
Frostworks | 0:c20da8fd007a | 17 | RPC::add_rpc_class<RpcDigitalOut>(); |
Frostworks | 0:c20da8fd007a | 18 | 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") |
Frostworks | 0:c20da8fd007a | 19 | eth.connect(); // connect and open communications |
Frostworks | 0:c20da8fd007a | 20 | pc.printf("IP Address is %s\n", eth.getIPAddress()); // display IP address |
Frostworks | 0:c20da8fd007a | 21 | svr.addHandler<HTTPRpcRequestHandler>("/rpc"); // add handler to server object |
Frostworks | 0:c20da8fd007a | 22 | svr.start(80, ð); // bind server to port 80 |
Frostworks | 0:c20da8fd007a | 23 | |
Frostworks | 0:c20da8fd007a | 24 | while(1) |
Frostworks | 0:c20da8fd007a | 25 | { |
Frostworks | 0:c20da8fd007a | 26 | svr.poll(); // continuously poll for Ethernet messages to server |
Frostworks | 0:c20da8fd007a | 27 | } |
Frostworks | 0:c20da8fd007a | 28 | } |
Frostworks | 0:c20da8fd007a | 29 |