Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Compiler/CC3100: After Acces Point congifuration, CC3100 connects with the AP with IP 0.0.0.0

$
0
0

Part Number: CC3100

Tool/software: TI C/C++ Compiler

Hi,

i am developing with cc3100, and i have encountered a strange behaviour.

When i change my Acess Point`s (Aerohive) password, or when i turn off and turn on the Acess Point, when CC3100 connects i can see in the AP`s log that the cc3100 IP is 0.0.0.0 :

- 1970-01-01 00:18:14 info    ah_auth: add new RT sta: MAC=74e1:822c:2145, IP=0.0.0.0, hostname=, username= on wifi0.1

I use static IP, with no DHCP.
If i wait for 3 mins between sends this behaviour still in time,  i use fast connect mode, beacause i only need to send data 2 o 4 times per day, so the rest of the time, cc3100 is in hibernate state.

Here is my configureSimpleLinkToDefaultStateProfilefunction:

_i32 configureSimpleLinkToDefaultStateProfile(void)
{
SlSecParams_t g_SecParams;
SlNetCfgIpV4Args_t ipV4;
SlVersionFull ver = {0};
_WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0};
_u8 configOpt = 0;
_u8 configLen = 0;
_u8 power = 0;
_i32 retVal = -1;
_i32 mode = -1;
_i8 *pConfig = NULL;

mode = sl_Start(0, pConfig, 0, PIN_WIFI_HIB);
// If the device is not in station-mode, try configuring it in station-mode
if (ROLE_STA != mode)
{
if (ROLE_AP == mode)
{
// If the device is in AP mode, we need to wait for this event before doing anything
while(!IS_IP_ACQUIRED(g_Status));
}

// Switch to STA role and restart
retVal = sl_WlanSetMode(ROLE_STA);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
retVal = sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
if (retVal != 0)
{
return NOK;
}
retVal = sl_Start(0, pConfig, 0, PIN_WIFI_HIB);
if (retVal < 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
// Check if the device is in station again
if (ROLE_STA != retVal)
{
// We don't want to proceed if the device is not coming up in station-mode
//(DEVICE_NOT_IN_STATION_MODE);
}
}
// Get the device's version-information
configOpt = SL_DEVICE_GENERAL_VERSION;
configLen = sizeof(ver);
retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (_u8 *)(&ver));
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
retVal = sl_WlanProfileDel(0xFF);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
g_SecParams.Key = staticWLanInfo.password;
g_SecParams.KeyLen = strlen((char*)staticWLanInfo.password);
g_SecParams.Type = staticWLanInfo.encryption;
retVal = sl_WlanProfileAdd(staticWLanInfo.ssid, strlen((char*)staticWLanInfo.ssid),myCurrentBssid, &g_SecParams, 0,7,0);// en lugar de 0 la mac
if (retVal < 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
//Connecting to the Access point
// Set connection policy to Auto // Esta configuracion Fast es la mejor opcion en cuanto a velocidad y fiabilidad, se conecta con el ultimo AP segun la MAC
// guardada, si se guarda el perfil con la mac y luego se apaga el ap falla hasta que se actualice el perfil de red
retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 1, 0, 0, 0), 0, 0); // PROFILE set fast

// sl_WlanPolicySet(SL_POLICY_CONNECTION , SL_CONNECTION_POLICY(1,0,0,0,0), 0, 0);//AUTO
//Reset
//sl_WlanPolicySet(SL_POLICY_CONNECTION , SL_CONNECTION_POLICY(0,0,0,0,0), 0, 0);
// sl_WlanPolicySet(SL_POLICY_CONNECTION , SL_CONNECTION_POLICY(0,0,0,0,1), 0, 0);//AUTO SMART CONFGI
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
// Device in station-mode. Disconnect previous connection if any
// The function returns 0 if 'Disconnected done', negative number if already disconnected
// Wait for 'disconnection' event if 0 is returned, Ignore other return-codes
retVal = sl_WlanDisconnect();
if(0 == retVal)
{
// Wait
while(IS_CONNECTED(g_Status)) {
_SlNonOsMainLoopTask();
}
}
// Enable statis IP
ipV4.ipV4 = netInfo.ip;
ipV4.ipV4Mask = netInfo.mask;
ipV4.ipV4Gateway = netInfo.gateway;
ipV4.ipV4DnsServer = SL_IPV4_VAL(0,0,0,0);
// After calling this API device will be configure for static IP address.
retVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,1, sizeof(SlNetCfgIpV4Args_t), (_u8 *)&ipV4);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);//alv
/* Unregister mDNS services */
// retVal = sl_NetAppMDNSUnRegisterService(0, 0);alv
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}

// Disable scan
configOpt = SL_SCAN_POLICY(0);
retVal = sl_WlanPolicySet(SL_POLICY_SCAN , configOpt, NULL, 0);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
// Set Tx power level for station mode
// Number between 0-15, as dB offset from max power - 0 will set maximum power
power = TX_POWER_LEVEL;
retVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (_u8 *)&power);
if (retVal < 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
// Set PM policy to normal
retVal = sl_WlanPolicySet(SL_POLICY_PM , SL_ALWAYS_ON_POLICY, NULL, 0);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
// Unregister mDNS services
retVal = sl_NetAppMDNSUnRegisterService(0, 0);
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
retVal = sl_NetAppStop(SL_NET_APP_MDNS_ID);
//if (retVal < 0) return NOK;

// Remove all 64 filters (8*8)
memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
retVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask,
sizeof(_WlanRxFilterOperationCommandBuff_t));
if (retVal != 0)
{
sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
return NOK;
}
retVal = sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);
if (retVal != 0)
{
return NOK;
}

return OK; // Success
}

Once this functions is called once i just do this to start a connection again :

startRetVal = sl_Start(0, pConfig, 0, PIN_WIFI_HIB);
if (startRetVal == SL_POOL_IS_EMPTY)
{
   sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);//MOD 1.X.38_MOD_5
   return NOK;
}
if ((startRetVal == ROLE_STA) || (startRetVal == ROLE_AP) || (startRetVal == ROLE_P2P))
{
   // OK
}
else
{
   sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);//MOD 1.X.38_MOD_5
   return NOK;
}
// Set Tx power level for station mode
startRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (_u8 *)&power);
if (startRetVal == 0)
{
  return OK;
}
else
{
  // CONF_ERROR (-1)
  // CONF_NVMEM_ACCESS_FAILED (-2)
  // CONF_OLD_FILE_VERSION (-3)
  // CONF_ERROR_NO_SUCH_COUNTRY_CODE (-4)
  sl_Stop(SL_STOP_TIMEOUT, PIN_WIFI_HIB);//MOD 1.X.38_MOD_5
  return NOK;
 }
}

In conclusion, i need to avoid this behaviour, i dont understand why IP 0.0.0.0 appears in the log of the Acces Point, i have been able to check in Wireshark that i can send tcp data with the correct static IP that i use,

but in the Acces Point´s log, this IP 0.0.0.0 Stills there, wich make no sense for me.

Best regards

Alvaro


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>