WiFi DipCortex / CC3000 Demo - Contains a menu driven set of tests to initalise and control the CC3000 radio. Also allowing you to test various TCP and UDP connections.

Dependencies:   NTPClient WebSocketClient cc3000_hostdriver_mbedsocket mbed HTTPClient

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

Please Note, this example uses the serial port so you will need an external RS232 TTL to USB adapter.

Files at this revision

API Documentation at this revision

Comitter:
SolderSplashLabs
Date:
Tue Oct 08 22:42:04 2013 +0000
Parent:
2:3adf4a0475d7
Child:
4:4e5e094a81c0
Commit message:
Added smartconfig, profile deleting

Changed in this revision

cc3000_hostdriver_mbedsocket.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
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/cc3000_hostdriver_mbedsocket.lib	Tue Oct 08 00:03:54 2013 +0000
+++ b/cc3000_hostdriver_mbedsocket.lib	Tue Oct 08 22:42:04 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/SolderSplashLabs/code/cc3000_hostdriver_mbedsocket/#e62d7252401e
+http://mbed.org/users/SolderSplashLabs/code/cc3000_hostdriver_mbedsocket/#1d374a7f0c0d
--- a/main.cpp	Tue Oct 08 00:03:54 2013 +0000
+++ b/main.cpp	Tue Oct 08 22:42:04 2013 +0000
@@ -22,7 +22,6 @@
 
 #define SERIAL_BAUD_RATE    115200
 Serial pc(p19, p20);
-extern cc3000 wifi;
 //Serial pc(USBTX, USBRX);
 
 const char* ECHO_SERVER_ADDRESS = "192.168.0.10";
@@ -32,14 +31,6 @@
 char hello[] = "Hello World\r\n";
 const char WEB_SOCKET_URL[] = {"ws://sockets.mbed.org/ws/SolderSplashLabs/wo"};
 
-typedef enum MENU_LEVEL
-{
-    MENU_TOP = 0,
-    MENU_CONNECTION,
-    MENU_TCP,
-    MENU_UDP    
-} MENU_LEVEL;
-
 MENU_LEVEL currentMenu = MENU_TOP;
 
 // ------------------------------------------------------------------------------------------------------------
@@ -207,7 +198,7 @@
                 break;
             }
             
-            wait_ms(250);
+            wait_ms(50);
             
             // Should we stop?
             if ( pc.readable() )
@@ -380,6 +371,10 @@
         printf("|   SSID : %-33s|\r\n", ipinfo.uaSSID);
         printf("|   IP : %d.%d.%d.%d                        |\r\n", ipinfo.aucIP[3], ipinfo.aucIP[2], ipinfo.aucIP[1], ipinfo.aucIP[0]);   
     }
+    else if ( wifi.is_connected() )
+    {
+        printf("|   Connecting, waiting for DHCP             |\r\n"); 
+    }
     else
     {
         printf("|   Not Connected                           |\r\n");   
@@ -414,6 +409,22 @@
 
 // ------------------------------------------------------------------------------------------------------------
 /*!
+    @brief Configure the module for smart connect mode allow configuration over the air
+*/
+// ------------------------------------------------------------------------------------------------------------
+void SmartConfig ( void )
+{
+    // We dont want to auto reconnect to an access point
+    wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
+    
+    // start smart config will disconnect, set the prefix
+    // wait for a message via a SmartConfig app, store it to the profile list
+    // finally it will reenable auto connection, triggering the module to connect to the new access point
+    wifi.start_smart_config(0);
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
     @brief Control the wifi connection
 */
 // ------------------------------------------------------------------------------------------------------------
@@ -424,7 +435,9 @@
     printf(" 2 - Disable auto connect \r\n");
     printf(" 3 - Connect to %s \r\n", SSID);
     printf(" 4 - Disconnect \r\n");
-    printf(" 5 - Get Status \r\n");
+    printf(" 5 - Start SmartConfig \r\n");  
+    printf(" 6 - Erase profiles \r\n");  
+    printf(" 7 - Get Status \r\n");
     printf(" x - Top Menu \r\n");
     
     printf("\r\n");
@@ -441,7 +454,12 @@
         break;
         
         case '3':     
-            //wifi.start(0); 
+        
+            //wifi.start(0);
+            
+            // Enable DHCP
+            wifi._netapp.dhcp(0, 0, 0, 0);
+            
             if ( AP_SECURITY == NONE )
             {
                 connect_to_ssid((uint8_t *)SSID);
@@ -458,6 +476,14 @@
         break;
         
         case '5' :
+            SmartConfig();
+        break;
+        
+        case '6' :
+            wifi._wlan.ioctl_del_profile(255);
+        break;
+        
+        case '7' :
             print_cc3000_info();
         break;
         
--- a/main.h	Tue Oct 08 00:03:54 2013 +0000
+++ b/main.h	Tue Oct 08 22:42:04 2013 +0000
@@ -2,6 +2,14 @@
 #ifndef MAIN_H
 #define MAIN_H
 
+typedef enum MENU_LEVEL
+{
+    MENU_TOP = 0,
+    MENU_CONNECTION,
+    MENU_TCP,
+    MENU_UDP    
+} MENU_LEVEL;
+
 extern cc3000 wifi;
 
 #endif