Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Revision:
155:582462821bd7
Parent:
154:6e60f310ab78
Child:
157:33db0c5e0bd8
--- a/main.cpp	Thu Apr 03 00:50:36 2014 +0000
+++ b/main.cpp	Mon Apr 07 03:14:54 2014 +0000
@@ -110,22 +110,58 @@
  #ifdef CELLULAR_NETWORK
  int _ublox_cell_connect_status = 0;
  int getUbloxConnectStatus() { return _ublox_cell_connect_status; }
+ C027 c027;
+ 
+ /*
+ #include "Websocket.h"
+ 
+ void ublox_test_modem(int index) {
+    // See the output on http://sockets.mbed.org/demo/viewer
+    char *url = "ws://sockets.mbed.org:443/ws/demo/rw";
+    Websocket ws(url);
+
+    pc.printf("connecting to websocket: %s\r\n",url);
+    bool c = ws.connect();
+    pc.printf("Connect result: %s\n", c?"OK":"Failed");
+    
+    char msg[512];
+    memset(msg,0,512);
+    sprintf(msg,"testing mbed websockets...123...%d",index);
+    
+    pc.printf("Sending data...\r\n");
+    ws.send(msg);    
+    wait(0.5f);
+    memset(msg,0,512);
+        
+    pc.printf("Receiving data...\r\n");
+    if (ws.read(msg))
+        pc.printf("Websocket Receive: [%s]\r\n", msg);
+    else
+        pc.printf("Error in reading from websocket!\r\n");
+        
+    pc.printf("closing websockets.");
+    ws.close();
+}
+*/
+
  #endif
  
  // main entry point
  int main() {      
 #ifdef CELLULAR_NETWORK
-    C027 c027;
     c027.mdmUsbEnable(true);
     c027.mdmPower(true);
     c027.mdmReset();
     c027.mdmWakeup();
     UBLOX_MODEM modem(NC,true,1);
     modem.power(true);
-    Thread::wait(1000);
+    Thread::wait(3000);
     _ublox_cell_connect_status = modem.connect("internet");
     if (_ublox_cell_connect_status) pc.printf("Unable to connect cell modem\r\n");
     else pc.printf("Cell modem connected!\r\n");
+    //ublox_test_modem(1);
+    //ublox_test_modem(2);
+    //ublox_test_modem(3);
 #endif
 #ifdef NETWORK_MUTEX
     network_mutex = new Mutex();