Simple example using WebSocket to send accelerometer data

Dependencies:   EthernetInterface MMA7660 WebSocketClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Oct 26 09:11:00 2012 +0000
Commit message:
send accelerometer data over websocket

Changed in this revision

EthernetInterface.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
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
diff -r 000000000000 -r 11bb5faeb547 EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
diff -r 000000000000 -r 11bb5faeb547 MMA7660.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#a8e20db7901e
diff -r 000000000000 -r 11bb5faeb547 WebSocketClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#86e89a0369b9
diff -r 000000000000 -r 11bb5faeb547 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "Websocket.h"
+#include "MMA7660.h"
+
+MMA7660 MMA(p28, p27);
+
+DigitalOut l1(LED1);
+ 
+int main() {
+    char json_str[100];
+    
+    if (MMA.testConnection())
+        l1 = 1;
+ 
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n\r", eth.getIPAddress());
+ 
+    Websocket ws("ws://sockets.mbed.org/ws/demo/wo");
+    ws.connect();
+ 
+    while (1) {
+        sprintf(json_str, "{\"id\":\"app_board_acc\",\"ax\":\"%d\",\"ay\":\"%d\",\"az\":\"%d\"}", (int)(MMA.x()*200), (int)(MMA.y()*200), (int)(MMA.z()*200));
+        ws.send(json_str);
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 11bb5faeb547 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90
diff -r 000000000000 -r 11bb5faeb547 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 26 09:11:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file