An example program that establishes a read-only web socket connection, and echos everything it sees to the LCD

Dependencies:   C12832_lcd SprintUSBModem WebSocketClient mbed-rtos mbed

Fork of SprintUSBModemWebsocketTest-Temp by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Thu Nov 01 03:45:23 2012 +0000
Parent:
2:72c06f2902d5
Commit message:
First commit;

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 72c06f2902d5 -r 7d9749651663 C12832_lcd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Thu Nov 01 03:45:23 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#468cdccff7af
diff -r 72c06f2902d5 -r 7d9749651663 LM75B.lib
--- a/LM75B.lib	Thu Nov 01 03:00:53 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
diff -r 72c06f2902d5 -r 7d9749651663 main.cpp
--- a/main.cpp	Thu Nov 01 03:00:53 2012 +0000
+++ b/main.cpp	Thu Nov 01 03:45:23 2012 +0000
@@ -1,18 +1,16 @@
 #include "mbed.h"
 #include "SprintUSBModem.h"
 #include "Websocket.h"
-#include "LM75B.h"
+#include "C12832_lcd.h"
 
 void test(void const*)
 {
-    LM75B tmp(p28,p27);
 
     SprintUSBModem modem;
-    // view at http://sockets.mbed.org/demo/viewer
-    Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
+    // Send messages at http://sockets.mbed.org/demo/sender
+    Websocket ws("ws://sockets.mbed.org:443/ws/demo/ro");
 
     char recv[128];
-    char msg[32];
 
     modem.power(true);
 
@@ -25,18 +23,19 @@
     bool c = ws.connect();
     printf("Connect result: %s\r\n", c?"OK":"Failed");
 
+    C12832_LCD lcd;
+    lcd.cls();
+
     while (1) {
 
-        sprintf(msg, "Temp = %.1f",tmp.read());
-        int ret = ws.send(msg);
-        if(ret<0) {
-            printf("Timeout\r\n");
-            ws.close();
-            c = ws.connect();
-            printf("Connect result: %s\r\n", c?"OK":"Failed");
+        if (ws.read(recv)) {
+            printf("rcv: %s\r\n", recv);
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf(recv);
         }
+
         Thread::wait(1000);
-
     }
 
     modem.disconnect();
@@ -47,8 +46,6 @@
 
     printf("Powered off\r\n");
 
-    while(1) {
-    }
 }