This is a modification of the NTPClient_HelloWorld to use the wifly link instead of the eth link

Dependencies:   mbed LM75B NTPClient WiflyInterface MMA7660 WebSocketClient

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Feb 08 12:09:33 2013 +0000
Parent:
3:d1d4b7d317d1
Child:
5:ab84dbbe7366
Commit message:
websocket demo using wifly and on board sensors (app board) (acc - temp)

Changed in this revision

LM75B.lib Show annotated file Show diff for this revision Revisions of this file
MMA7660.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Fri Feb 08 12:09:33 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Fri Feb 08 12:09:33 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#a8e20db7901e
--- a/WiflyInterface.lib	Fri Oct 26 12:39:09 2012 +0000
+++ b/WiflyInterface.lib	Fri Feb 08 12:09:33 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863
+http://mbed.org/users/mbed_official/code/WiflyInterface/#0bcec6272784
--- a/main.cpp	Fri Oct 26 12:39:09 2012 +0000
+++ b/main.cpp	Fri Feb 08 12:09:33 2013 +0000
@@ -1,6 +1,8 @@
 #include "mbed.h"
 #include "WiflyInterface.h"
 #include "Websocket.h"
+#include "LM75B.h"
+#include "MMA7660.h"
 
 
 /* wifly interface:
@@ -14,26 +16,34 @@
 
 WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA);
 
+// accelerometer
+MMA7660 acc(p28, p27);
+
+// temperature sensor
+LM75B tmp(p28,p27);
+
+
 int main()
 {
-    int i=0;
-    char mystr[32];
+    char json_str[100];
 
     wifly.init(); //Use DHCP
     while (!wifly.connect());
     printf("IP Address is %s\n\r", wifly.getIPAddress());
 
-    Websocket ws("ws://sockets.mbed.org:443/ws/app-board/wo");
     // See the output on http://sockets.mbed.org/app-board/viewer
+    Websocket ws("ws://sockets.mbed.org:443/ws/sensors/wo");
+    
+    // connect WS server
     while (!ws.connect());
 
-    ws.send("mbed application board");
-    ws.send("Hello world!");
-
     while (1) {
-        sprintf(mystr,"%d",i);
-        ws.send(mystr);
-        wait(1.0);
-        i++;
+        // create json string with acc/tmp data
+        sprintf(json_str, "{\"id\":\"app_board_EW2013\",\"ax\":%d,\"ay\":%d,\"az\":%d, \"tmp\":%d}", (int)(acc.x()*360), (int)(acc.y()*360), (int)(acc.z()*360), (int)tmp.read());
+        
+        // send str
+        ws.send(json_str);
+        
+        wait(0.1);
     }
 }
\ No newline at end of file