cc3000 hostdriver with the mbed socket interface

Dependents:   cc3000_hello_world_demo cc3000_simple_socket_demo cc3000_ntp_demo cc3000_ping_demo ... more

Files at this revision

API Documentation at this revision

Comitter:
SolderSplashLabs
Date:
Sat Oct 12 21:03:45 2013 +0000
Parent:
40:acb9324640c4
Child:
42:bd2c631a031a
Commit message:
Removed a debug timer, added debug messages to callback function

Changed in this revision

cc3000.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_event.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/cc3000.cpp	Sat Oct 12 20:51:05 2013 +0000
+++ b/cc3000.cpp	Sat Oct 12 21:03:45 2013 +0000
@@ -133,12 +133,14 @@
 void cc3000::usync_callback(int32_t event_type, uint8_t * data, uint8_t length) {
     if (event_type == HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE)
     {
+        DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE");
         _status.smart_config_complete = 1;
         _status.stop_smart_config = 1;
     }
 
     if (event_type == HCI_EVNT_WLAN_UNSOL_CONNECT)
     {
+        DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_CONNECT");
         _status.connected = 1;
         // Connect message is always followed by a DHCP message, connection is not useable until then
         _status.dhcp      = 0;
@@ -146,6 +148,7 @@
 
     if (event_type == HCI_EVNT_WLAN_UNSOL_DISCONNECT)
     {
+        DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DISCONNECT");
         _status.connected = 0;
         _status.dhcp      = 0;
         _status.dhcp_configured = 0;
@@ -153,35 +156,41 @@
 
     if (event_type == HCI_EVNT_WLAN_UNSOL_DHCP)
     {
-      #ifdef CC3000_ETH_COMPAT
-    
-      inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_IP_OFFSET]))), ip_addr, 17);
-      inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_GW_OFFSET]))), gateway, 17);
-      inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_SUBNET_OFFSET]))), networkmask, 17);
-      inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_MAC_OFFSET]))), mac_addr, 19);
-    
-      #endif
-      
-      if ( *(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) {
-          _status.dhcp = 1;
-      } else {
-          _status.dhcp = 0;
-      }
+        #ifdef CC3000_ETH_COMPAT
+        
+        inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_IP_OFFSET]))), ip_addr, 17);
+        inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_GW_OFFSET]))), gateway, 17);
+        inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_SUBNET_OFFSET]))), networkmask, 17);
+        inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_MAC_OFFSET]))), mac_addr, 19);
+        
+        #endif
+        
+        if ( *(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) {
+            _status.dhcp = 1;
+            DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP %i.%i.%i.%i", data[3], data[2], data[1], data[0]);
+        } else {
+            DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP - Disconnected");
+            _status.dhcp = 0;
+        }
     }
 
     if (event_type == HCI_EVENT_CC3000_CAN_SHUT_DOWN)
     {
+        // Note this means the moudles is idle, so it could be shutdown..
+        //DBG_CC("Callback : HCI_EVENT_CC3000_CAN_SHUT_DOWN");
         _status.ok_to_shut_down = 1;
     }
 
     if (event_type == HCI_EVNT_WLAN_ASYNC_PING_REPORT)
     {
+        DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_PING_REPORT");
         memcpy(&_ping_report, data, length);
     }
 
     if (event_type == HCI_EVNT_BSD_TCP_CLOSE_WAIT) {
         uint8_t socketnum;
         socketnum = data[0];
+        DBG_CC("Callback : HCI_EVNT_BSD_TCP_CLOSE_WAIT - Socket : %d", socketnum);
         if (socketnum < MAX_SOCKETS) {
             _closed_sockets[socketnum] = true; /* clients socket is closed */
         }
--- a/cc3000_event.cpp	Sat Oct 12 20:51:05 2013 +0000
+++ b/cc3000_event.cpp	Sat Oct 12 21:03:45 2013 +0000
@@ -198,7 +198,6 @@
 #endif
 }
 
-Timer timer;
 uint8_t *cc3000_event::hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen) {
     uint8_t *received_data, argument_size;
     uint16_t length;
@@ -207,11 +206,7 @@
     uint32_t return_value;
     uint8_t * RecvParams;
     uint8_t *RetParams;
-    
-    
-    timer.reset();
-    timer.start();
-    
+        
     while (1)
     {
         if (_simple_link.get_data_received_flag() != 0)
@@ -450,12 +445,6 @@
                 return NULL;
             }
         }
-        
-        if ( timer.read_ms() > 10000)
-        {
-            DBG_HCI("TIMEOUT Waiting for CC3000 Event - BAD");
-            break;
-        }
     }
 }