TI's CC3100. A test demo with very little testing done!
Revision 4:5af740da0a59, committed 2015-02-23
- Comitter:
- dflet
- Date:
- Mon Feb 23 21:10:13 2015 +0000
- Parent:
- 3:b89198ac2efe
- Child:
- 5:d3b320ebd469
- Commit message:
- Added eye candy in some of the event handlers, made a few changes to SL_IPV4_BYTE to correct errors.
Changed in this revision
--- a/G_functions/fPtr_func.cpp Sun Feb 22 18:33:10 2015 +0000
+++ b/G_functions/fPtr_func.cpp Mon Feb 23 21:10:13 2015 +0000
@@ -524,14 +524,30 @@
#if (defined(sl_WlanEvtHdlr))
void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent)
{
-
+ unsigned char g_ucConnectionSSID[32+1]; //Connection SSID
+ unsigned char g_ucConnectionBSSID[6]; //Connection BSSID
+
if(pWlanEvent == NULL)
printf(" [WLAN EVENT] NULL Pointer Error \n\r");
switch(pWlanEvent->Event) {
case SL_WLAN_CONNECT_EVENT: {
_cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION);
-
+
+ // Copy new connection SSID and BSSID to global parameters
+ memcpy(g_ucConnectionSSID,pWlanEvent->EventData.
+ STAandP2PModeWlanConnected.ssid_name,
+ pWlanEvent->EventData.STAandP2PModeWlanConnected.ssid_len);
+ memcpy(g_ucConnectionBSSID,
+ pWlanEvent->EventData.STAandP2PModeWlanConnected.bssid,
+ SL_BSSID_LENGTH);
+
+ printf("[WLAN EVENT] STA Connected to the AP: %s ,"
+ "BSSID: %x:%x:%x:%x:%x:%x\n\r",
+ g_ucConnectionSSID,g_ucConnectionBSSID[0],
+ g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
+ g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
+ g_ucConnectionBSSID[5]);
/*
* Information about the connected AP (like name, MAC etc) will be
* available in 'slWlanConnectAsyncResponse_t' - Applications
@@ -554,10 +570,22 @@
/* If the user has initiated 'Disconnect' request, 'reason_code' is SL_USER_INITIATED_DISCONNECTION */
if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code) {
- printf(" Device disconnected from the AP on application's request \n\r");
+ printf("[WLAN EVENT]Device disconnected from the AP: %s,"
+ "BSSID: %x:%x:%x:%x:%x:%x on application's request \n\r",
+ g_ucConnectionSSID,g_ucConnectionBSSID[0],
+ g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
+ g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
+ g_ucConnectionBSSID[5]);
} else {
- printf(" Device disconnected from the AP on an ERROR..!! \n\r");
+ printf("[WLAN ERROR]Device disconnected from the AP AP: %s,"
+ "BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r",
+ g_ucConnectionSSID,g_ucConnectionBSSID[0],
+ g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
+ g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
+ g_ucConnectionBSSID[5]);
}
+ memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID));
+ memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID));
}
break;
@@ -573,7 +601,7 @@
break;
default: {
- printf(" [WLAN EVENT] Unexpected event \n\r");
+ printf("[WLAN EVENT] Unexpected event [0x%x]\n\r",pWlanEvent->Event);
}
break;
}
@@ -607,6 +635,16 @@
pEventData = &pNetAppEvent->EventData.ipAcquiredV4;
g_GatewayIP = pEventData->gateway;
+ printf("[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , ""Gateway=%d.%d.%d.%d\n\r",
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,3),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,2),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,1),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,0),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,3),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,2),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,1),
+ _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,0));
+
}
break;
@@ -618,7 +656,7 @@
break;
default: {
- printf(" [NETAPP EVENT] Unexpected event \n\r");
+ printf("[NETAPP EVENT] Unexpected event [0x%x] \n\r",pNetAppEvent->Event);
}
break;
}
@@ -657,13 +695,13 @@
printf(" [SOCK EVENT] Close socket operation, failed to transmit all queued packets\n\r");
break;
default:
- printf(" [SOCK EVENT] Unexpected event \n\r");
+ printf("[SOCK ERROR] - TX FAILED : socket %d , reason""(%d) \n\n", pSock->EventData.sd, pSock->EventData.status);
break;
}
break;
default:
- printf(" [SOCK EVENT] Unexpected event \n\r");
+ printf("[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event);
break;
}
}
@@ -706,7 +744,7 @@
* Most of the general errors are not FATAL are are to be handled
* appropriately by the application
*/
- printf(" [GENERAL EVENT] \n\r");
+ printf("[GENERAL EVENT] - ID=[%d] Sender=[%d]\n\n", pDevEvent->EventData.deviceEvent.status, pDevEvent->EventData.deviceEvent.sender);
}
#endif
--- a/simplelink/cc3100_netcfg.cpp Sun Feb 22 18:33:10 2015 +0000
+++ b/simplelink/cc3100_netcfg.cpp Mon Feb 23 21:10:13 2015 +0000
@@ -99,9 +99,9 @@
return((((uint32_t)add_3 << 24) & 0xFF000000) | (((uint32_t)add_2 << 16) & 0xFF0000) | (((uint32_t)add_1 << 8) & 0xFF00) | ((uint32_t)add_0 & 0xFF) );
}
-uint8_t cc3100_netcfg::SL_IPV4_BYTE(uint8_t val,uint8_t index){
+uint8_t cc3100_netcfg::SL_IPV4_BYTE(uint32_t val,uint8_t index){
- return( (val >> (index*8)) & 0xFF );
+ return( (val >>= (index*8)) & 0xFF );
}
/*****************************************************************************/
--- a/simplelink/cc3100_netcfg.h Sun Feb 22 18:33:10 2015 +0000 +++ b/simplelink/cc3100_netcfg.h Mon Feb 23 21:10:13 2015 +0000 @@ -265,7 +265,7 @@ #endif uint32_t SL_IPV4_VAL(uint8_t add_3,uint8_t add_2,uint8_t add_1,uint8_t add_0); -uint8_t SL_IPV4_BYTE(uint8_t val,uint8_t index); +uint8_t SL_IPV4_BYTE(uint32_t val,uint8_t index); private: