Websocket example

Dependencies:   C027 UbloxUSBModem WebSocketClient mbed

Fork of VodafoneUSBModemWebsocketTest by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Mon Oct 21 15:41:42 2013 +0000
Parent:
6:1d5e4acc9f97
Child:
8:05a5c32037c2
Commit message:
draft version (untested)

Changed in this revision

C027.lib Show annotated file Show diff for this revision Revisions of this file
UbloxUSBModem.lib Show annotated file Show diff for this revision Revisions of this file
VodafoneUSBModem.lib 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 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/C027.lib	Mon Oct 21 15:41:42 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mazgch/code/C027/#67eca3673166
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UbloxUSBModem.lib	Mon Oct 21 15:41:42 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/UbloxUSBModem/#6e9d98f8c237
--- a/VodafoneUSBModem.lib	Tue Oct 30 10:26:24 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://mbed.org/users/mbed_official/code/VodafoneUSBModem/#bf3cf216235c
--- a/main.cpp	Tue Oct 30 10:26:24 2012 +0000
+++ b/main.cpp	Mon Oct 21 15:41:42 2013 +0000
@@ -1,44 +1,43 @@
 #include "mbed.h"
-#include "VodafoneUSBModem.h"
+#include "C027.h"
+#include "UbloxUSBGSMModem.h"
+#include "UbloxUSBCDMAModem.h"
+
 #include "Websocket.h"
 
-void test(void const*) 
+void test(void const*)
 {
-    VodafoneUSBModem modem;
+    UbloxUSBGSMModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
     Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
     char recv[128];
-    
-    int ret = modem.connect("pp.vodafone.co.uk");
-    if(ret)
-    {
-      printf("Could not connect\n");
-      return;
+
+    int ret = modem.connect("internet"); // eventaully set another apn here
+    if(ret) {
+        printf("Could not connect\n");
+        return;
     }
-    
+
     bool c = ws.connect();
     printf("Connect result: %s\n", c?"OK":"Failed");
-    
-    for(int i = 0; i < 10000; i++)
-    {
-        if(!(i%100))
-        {
-          int ret = ws.send("WebSocket Hello World over the Vodafone Network!");
-          if(ret<0)
-          {
-            printf("Timeout\n");
-            ws.close();
-            c = ws.connect();
-            printf("Connect result: %s\n", c?"OK":"Failed");
-          }
+
+    for(int i = 0; i < 10000; i++) {
+        if(!(i%100)) {
+            int ret = ws.send("WebSocket Hello World over the Vodafone Network!");
+            if(ret<0) {
+                printf("Timeout\n");
+                ws.close();
+                c = ws.connect();
+                printf("Connect result: %s\n", c?"OK":"Failed");
+            }
         }
-        
+
         if (ws.read(recv)) {
             printf("rcv: %s\r\n", recv);
         }
 
     }
-    
-    modem.disconnect();  
+
+    modem.disconnect();
 
     while(1) {
     }
@@ -47,13 +46,12 @@
 
 int main()
 {
-  Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
-  DigitalOut led(LED1);
-  while(1)
-  {
-    led=!led;
-    Thread::wait(1000);  
-  }
+    Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
+    DigitalOut led(A0);
+    while(1) {
+        led=!led;
+        Thread::wait(1000);
+    }
 
-  return 0;
+    return 0;
 }
--- a/mbed-rtos.lib	Tue Oct 30 10:26:24 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90
--- a/mbed.bld	Tue Oct 30 10:26:24 2012 +0000
+++ b/mbed.bld	Mon Oct 21 15:41:42 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file