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.

Revision:
5:506f580e7ead
Parent:
4:4e5e094a81c0
--- a/main.cpp	Wed Oct 09 00:59:47 2013 +0000
+++ b/main.cpp	Sat Oct 12 22:10:17 2013 +0000
@@ -136,8 +136,11 @@
                 break;
             }
         }
-        
-        socket.close();
+
+        if ( wifi.is_connected() )
+        {        
+            socket.close();
+        }
     }
     else
     {
@@ -186,7 +189,7 @@
 // ------------------------------------------------------------------------------------------------------------
 void Menu_PrintHeader ( void )
 {
-    if ( wifi.is_dhcp_configured() ) 
+    if (( wifi.is_enabled() ) && ( wifi.is_dhcp_configured() ))
     {
         wifi.get_ip_config(&ipinfo);
     }
@@ -195,14 +198,18 @@
     printf("+-------------------------------------------+\r\n");
     printf("|   WiFi DipCortex / CC3000 Kitchen Sink    |\r\n");
     printf("+-------------------------------------------+\r\n");
-    if ( wifi.is_dhcp_configured() ) 
+    if (! wifi.is_enabled() )
+    {
+        printf("|   CC3000 Disabled                         |\r\n"); 
+    }
+    else if ( wifi.is_dhcp_configured() ) 
     {
         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]);   
+        printf("|   IP : %-35s|\r\n", wifi.getIPAddress());   
     }
     else if ( wifi.is_connected() )
     {
-        printf("|   Connecting, waiting for DHCP             |\r\n"); 
+        printf("|   Connecting, waiting for DHCP            |\r\n"); 
     }
     else
     {
@@ -259,6 +266,7 @@
 // ------------------------------------------------------------------------------------------------------------
 void Menu_ConnectionControl ( void )
 {
+uint32_t ip = 0;
     Menu_PrintHeader();
     printf(" 1 - Enable auto connect to any previous access point\r\n");
     printf(" 2 - Disable auto connect \r\n");
@@ -287,21 +295,25 @@
             //wifi.start(0);
             
             // Enable DHCP
-            wifi._netapp.dhcp(0, 0, 0, 0);
+            wifi._netapp.dhcp(&ip, &ip, &ip, &ip);
             
             if ( AP_SECURITY == NONE )
             {
-                connect_to_ssid((uint8_t *)SSID);
+                wifi.connect_non_blocking((uint8_t *)SSID, 0, AP_SECURITY);
             }
             else
             {
-                connect_to_ssid(SSID,AP_KEY,AP_SECURITY);
+                printf("\r\n Connecting to : %s key : %s", SSID, AP_KEY );
+                wifi.connect_non_blocking((uint8_t *)SSID, (uint8_t *)AP_KEY, AP_SECURITY);
+                
             }      
         break;
         
         case '4' :
+            // Stop the module re-connecting
+            wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
+            // Then disconnect
             wifi.disconnect();
-            wifi.stop();
         break;
         
         case '5' :
@@ -316,6 +328,10 @@
             print_cc3000_info();
         break;
         
+        case '8':
+            //wifi._spi.manualIrqCheck();
+        break;
+        
         case 'x':      
             currentMenu = MENU_TOP;
         break;
@@ -465,11 +481,25 @@
         break;
         
         case MENU_TCP :
-            if (connected) Menu_TcpControl();
+            if (connected) 
+            {
+                Menu_TcpControl();
+            }
+            else
+            {
+                currentMenu = MENU_TOP;
+            }
         break;
         
         case MENU_UDP :
-            if (connected) Menu_UdpControl();
+            if (connected) 
+            {
+                Menu_UdpControl();
+            }
+            else
+            {
+                currentMenu = MENU_TOP;
+            }
         break;
         
         default :
@@ -487,8 +517,13 @@
 {   
     // Initalise the WiFi Module
     init(); 
+    
     pc.baud(SERIAL_BAUD_RATE);
+    
+    wait(1);
     wifi.start(0);
+    
+    wait_ms(750);
 
     while (1)
     {