An example program that uses a Wifly module to send messages over web sockets
Dependencies: WebSocketClient WiflyInterface mbed LM75B MMA7660
Fork of Websocket_Wifly_HelloWorld by
Revision 3:d1d4b7d317d1, committed 2012-10-26
- Comitter:
- chris
- Date:
- Fri Oct 26 12:39:09 2012 +0000
- Parent:
- 2:c69a06fe81c0
- Child:
- 4:79f9caf3d109
- Commit message:
- First commit;
Changed in this revision
WebSocketClient.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/WebSocketClient.lib Fri Aug 24 14:06:31 2012 +0000 +++ b/WebSocketClient.lib Fri Oct 26 12:39:09 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a +http://mbed.org/users/samux/code/WebSocketClient/#86e89a0369b9
--- a/main.cpp Fri Aug 24 14:06:31 2012 +0000 +++ b/main.cpp Fri Oct 26 12:39:09 2012 +0000 @@ -5,24 +5,35 @@ /* wifly interface: * - p9 and p10 are for the serial communication -* - p19 is for the reset pin -* - p26 is for the connection status +* - p30 is for the reset pin +* - p29 is for the connection status * - "mbed" is the ssid of the network * - "password" is the password * - WPA is the security */ -WiflyInterface wifly(p9, p10, p19, p26, "mbed", "password", WPA); + +WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA); -int main() { +int main() +{ + int i=0; + char mystr[32]; + wifly.init(); //Use DHCP while (!wifly.connect()); printf("IP Address is %s\n\r", wifly.getIPAddress()); - Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo"); + Websocket ws("ws://sockets.mbed.org:443/ws/app-board/wo"); + // See the output on http://sockets.mbed.org/app-board/viewer while (!ws.connect()); + ws.send("mbed application board"); + ws.send("Hello world!"); + while (1) { - ws.send("WebSocket Hello World over Wifly"); - wait(1.0); + sprintf(mystr,"%d",i); + ws.send(mystr); + wait(1.0); + i++; } } \ No newline at end of file