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 Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Aug 17 12:01:03 2012 +0000
Child:
1:31e50fea8be8
Commit message:
websocket with the new wifly interface

Changed in this revision

WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
WiflyInterface.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Fri Aug 17 12:01:03 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#9589afa4712e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WiflyInterface.lib	Fri Aug 17 12:01:03 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WiflyInterface/#6ffb0aeb3972
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 17 12:01:03 2012 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "Websocket.h"
+
+
+/* wifly interface:
+*     - p9 and p10 are for the serial communication
+*     - p25 is for the reset pin
+*     - p26 is for the connection status
+*     - "mbed" is the ssid of the network
+*     - "password" is the password
+*     - true means that the security of the network is WPA
+*/
+WiflyInterface wifly(p9, p10, p25, p26, "mbed", "password", true);
+
+int main() {
+    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");
+    while (!ws.connect());
+
+    while (1) {
+            ws.send("WebSocket Hello World over Wifly");
+            wait(1.0);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Aug 17 12:01:03 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6
\ No newline at end of file