tes
Dependencies: ASyncTicker EthernetInterface WebSocketClient mbed-rtos mbed MbedJSONValue xbee_lib
Revision 0:d73af3f5c81d, committed 2014-01-27
- Comitter:
- ammanvedi
- Date:
- Mon Jan 27 21:50:20 2014 +0000
- Child:
- 1:6c1df6c9be4d
- Commit message:
- initial
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ASyncTicker.lib Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/hlipka/code/ASyncTicker/#13db8277ce26
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebSocketClient.lib Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,58 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include <stdio.h> +#include <string.h> +#include "Websocket.h" +#include "Updateable.h" +#include "ASyncTicker.h" +#define PORT 80 + + +EthernetInterface ethernet; +Websocket ws("ws://192.168.0.4:8080/"); +Ticker pull_ticker; + + + +void pull_updates(){ + wait(0.1f); + printf("%s", "hello"); + +} + +int main () +{ + + ethernet.init(); // connect with DHCP + int ret_val = ethernet.connect(); + + if (0 == ret_val) { + printf("IP Address: %s\n\r", ethernet.getIPAddress()); + } else { + error("ethernet failed to connect: %d.\n\r", ret_val); + } + + + ws.connect(); + + char str[100]; + // string with a message + sprintf(str, "PU"); + ws.send(str); + + // clear the buffer and wait a sec... + memset(str, 0, 100); + wait(0.5f); + + // websocket server should echo whatever we sent it + if (ws.read(str)) { + printf("rcv'd: %s\n\r", str); + } + ws.close(); + pull_ticker.attach(&pull_updates, 5.0); + while(1){ + + wait(0.1f); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#f88660a9bed1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 27 21:50:20 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43 \ No newline at end of file