websocket over 3g using VodafoneUSBModem and app-board on-board sensors (acc - tmp)

Dependencies:   LM75B MMA7660 VodafoneUSBModem WebSocketClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Feb 08 12:34:40 2013 +0000
Child:
1:89d8a05a8f4d
Commit message:
websocket over 3g using VodafoneUSBModem and app-board on-board sensors (acc - tmp)

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
VodafoneUSBModem.lib Show annotated file Show diff for this revision Revisions of this file
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
mbed-rtos.lib 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/LM75B.lib	Fri Feb 08 12:34:40 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:34:40 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#a8e20db7901e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VodafoneUSBModem.lib	Fri Feb 08 12:34:40 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/VodafoneUSBModem/#07ac4e1ea5b0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Fri Feb 08 12:34:40 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 08 12:34:40 2013 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+#include "VodafoneUSBModem.h"
+#include "Websocket.h"
+#include "LM75B.h"
+#include "MMA7660.h"
+
+// accelerometer
+MMA7660 acc(p28, p27);
+
+// temperature sensor
+LM75B tmp(p28,p27);
+
+Serial pc(USBTX, USBRX);
+
+void test(void const*)
+{
+    char json_str[100];
+
+    VodafoneUSBModem modem;
+    Websocket ws("ws://sockets.mbed.org:443/ws/sensors/wo");
+    
+
+    int ret = modem.connect("pp.vodafone.co.uk");
+    if(ret) {
+        printf("Could not connect\n");
+        return;
+    }
+
+    bool c = ws.connect();
+    printf("Connect result: %s\n", c?"OK":"Failed");
+
+    while(1) {
+        sprintf(json_str, "{\"id\":\"3g_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
+        ret = ws.send(json_str);
+        
+        if(ret<0) {
+            printf("Timeout\n");
+            ws.close();
+            c = ws.connect();
+            printf("Connect result: %s\n", c?"OK":"Failed");
+        }
+        
+        Thread::wait(100);
+    }
+
+    modem.disconnect();
+
+    while(1) {
+    }
+}
+
+
+int main()
+{
+    pc.baud(921600);
+    Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
+    DigitalOut led(LED1);
+    while(1) {
+        led=!led;
+        Thread::wait(1000);
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Feb 08 12:34:40 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 08 12:34:40 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file