Websocket Hello World over a wifi network
Dependencies: EthernetNetIf mbed DNSResolver
Revision 7:1c874f214a98, committed 2011-10-25
- Comitter:
- samux
- Date:
- Tue Oct 25 06:54:31 2011 +0000
- Parent:
- 6:b9bf734842db
- Child:
- 8:02df37981408
- Commit message:
Changed in this revision
--- a/Websocket.lib Thu Sep 01 15:15:29 2011 +0000 +++ b/Websocket.lib Tue Oct 25 06:54:31 2011 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/Websocket/#c5ac3e26998f +http://mbed.org/users/samux/code/Websocket/#ca8c5ad59850
--- a/Wifly.lib Thu Sep 01 15:15:29 2011 +0000 +++ b/Wifly.lib Tue Oct 25 06:54:31 2011 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/Wifly/#984c1436dd42 +http://mbed.org/users/samux/code/Wifly/#92ee976db7b9
--- a/main.cpp Thu Sep 01 15:15:29 2011 +0000 +++ b/main.cpp Tue Oct 25 06:54:31 2011 +0000 @@ -12,9 +12,9 @@ //"mbed" network, password "password", and we are using WPA. Wifly wifly(p9, p10, p21, "mbed", "password", true); -//Here, we create a Websocket instance in 'w' (write) mode +//Here, we create a Websocket instance in 'wo' (write) mode //on the 'samux' channel -Websocket ws("ws://sockets.mbed.org/ws/chan1/wo", &wifly); +Websocket ws("ws://sockets.mbed.org/ws/samux/wo", &wifly); int main() { char json_str[100]; @@ -40,7 +40,7 @@ while (1) { while (1) { - while (!wifly.Join()) //we connect to the network + while (!wifly.join()) //we connect to the network wifly.reset(); if (!ws.connect()) //we connect to the server @@ -58,7 +58,7 @@ //Here, we format the string we will be sending to the server //the format we are sending in is JSON sprintf(json_str, "{\"id\":\"wifly_acc\",\"ax\":\"%d\",\"ay\":\"%d\",\"az\":\"%d\"}", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]); - ws.Send(json_str); //And we send the string + ws.send(json_str); //And we send the string } } } \ No newline at end of file