WiFi DipCortex USB CDC

Dependencies:   HTTPClient NTPClient USBDevice WebSocketClient cc3000_hostdriver_mbedsocket mbed

Fork of WiFiDip-UsbKitchenSink by Carl - SolderSplash Labs

http://www.soldersplash.co.uk/products/wifi-dipcortex/

Demo shows you how to implement the CC3000 library with the WiFi DipCortex.

The demo shows :

  • USB CDC ( Serial ) Menu system allow control of the module and starting each example
  • Smart Connect
  • Manual connect
  • Connection status
  • Ping
  • TCP Client
  • TCP Server
  • Web Socket read/write to sockets.mbed.org
  • HTTP Client test Post, Put, Delete
  • Posting ADC data to Xively every 1 second
  • UDP Client
  • UDP Server
  • NTP Example, contacts time server to get the current time

You will need a Driver for the USB CDC port which can be found here : http://www.soldersplash.co.uk/docs/DipCortex-USB-CDC.zip

Please refer to : http://mbed.org/users/SolderSplashLabs/notebook/dipcortex---getting-started-with-mbed/ as well as the SolderSplash Forum for support http://forum.soldersplash.co.uk/viewforum.php?f=15

Revision:
2:8f5776c287c5
Parent:
1:6f4eaec531c4
Child:
3:15828ac052f1
--- a/tcpTests.cpp	Mon Nov 04 22:18:14 2013 +0000
+++ b/tcpTests.cpp	Tue Nov 12 09:19:13 2013 +0000
@@ -256,6 +256,79 @@
 
 // ------------------------------------------------------------------------------------------------------------
 /*!
+    @brief Open a WebSocket, send a string
+*/
+// ------------------------------------------------------------------------------------------------------------
+void WebSocketReadTest ( void )
+{
+
+int res = 0;
+uint16_t counter = 0;
+uint16_t reconnects = 0;
+uint8_t myMAC[8];
+
+    wifi.get_mac_address(myMAC);
+    
+    Websocket ws((char *)WEB_SOCKET_URL);
+    if ( ws.connect() )
+    {
+        pc.printf("Connected to websocket server.\r\n");
+        
+        pc.printf("\r\n!! Press any key to stop receiving !!\r\n\r\n");
+        while (1)
+        {   
+            counter ++;
+            //sprintf(tmpBuffer, "WiFi DipCortex / CC3000 - %05d - %02x:%02x:%02x:%02x:%02x:%02x\r\n", counter, myMAC[0], myMAC[1], myMAC[2], myMAC[3], myMAC[4], myMAC[5]);
+            
+            if ( wifi.is_connected() )
+            {
+                res = ws.read(tmpBuffer);
+                
+                if ( res )
+                {
+                    pc.printf("Websocket Received : %s (Reconnects : %05d, Messages Recv : %05d)\r\n", tmpBuffer, reconnects, counter);
+                }
+                
+                if ( ws.is_connected() )
+                {
+                
+                }
+                else
+                {
+                    pc.printf("Websocket Closed, reconnecting .... \r\n");
+                    ws.close();
+                    if ( ws.connect() )
+                    {
+                        // Reconnected
+                        reconnects ++;
+                    }
+                    else
+                    {
+                        // Failure!
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                pc.printf("WiFi Connection Lost .... \r\n");
+            }
+            
+            if ( pc.readable() )
+            {
+                pc.printf("Closing Socket \r\n");
+                pc.getc();
+                break;
+            }
+        }
+        
+        ws.close();
+        pc.printf("Websocket Closed \r\n");
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
     @brief Open a TCP port send a string and wait for a reply
 */
 // ------------------------------------------------------------------------------------------------------------