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
Diff: main.cpp
- Revision:
- 3:d1d4b7d317d1
- Parent:
- 1:31e50fea8be8
- Child:
- 4:79f9caf3d109
--- 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