Part Number: CC3100
Hi,
I use CC3100 with my mcu for a long time , and now need to integrate Smartconfig option.
I try to enable the smart config process like at the example "provisioning_smartconfig" of sdk 1.3.0 without success with the android APP Simplelink Startet Pro.
Please help,
This is my code on Hosted MCU
_WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0};
uint8_t val = 1;
uint8_t configOpt = 0;
uint8_t configLen = 0;
uint8_t power = 0;
int32_t retVal = -1;
int32_t mode;
mode = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(mode);
/* 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_connectionStatus))
{
osi_Sleep(1);
}
}
/* Switch to STA role and restart */
retVal = sl_WlanSetMode(ROLE_STA);
ASSERT_ON_ERROR(retVal);
retVal = sl_Stop(SL_STOP_TIMEOUT);
ASSERT_ON_ERROR(retVal);
retVal = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(retVal);
/* 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 */
ASSERT_ON_ERROR(DEVICE_NOT_IN_STATION_MODE);
}
}
/* Get the device's version-information */
configOpt = SL_DEVICE_GENERAL_VERSION;
configLen = sizeof(g_wifiVersion);
retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (_u8 *)(&g_wifiVersion));
ASSERT_ON_ERROR(retVal);
/* Set connection policy to Auto + SmartConfig (Device's default connection policy) */
retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
ASSERT_ON_ERROR(retVal);
#ifdef DEBUG_NRF_USER
ASSERT_ON_ERROR(cc3100_clear_profiles(0xFF));
#endif
/*
* 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
*/
cc3100_disconnect_from_ap();
/* Enable DHCP client*/
retVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&val);
ASSERT_ON_ERROR(retVal);
/* Disable scan */
configOpt = SL_SCAN_POLICY(0);
retVal = sl_WlanPolicySet(SL_POLICY_SCAN , configOpt, NULL, 0);
ASSERT_ON_ERROR(retVal);
/* Set Tx power level for station mode
Number between 0-15, as dB offset from max power - 0 will set maximum power */
power = 0;
retVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (_u8 *)&power);
ASSERT_ON_ERROR(retVal);
/* Set PM policy to normal */
retVal = sl_WlanPolicySet(SL_POLICY_PM , g_powerState, NULL, 0);
ASSERT_ON_ERROR(retVal);
/* Unregister mDNS services */
retVal = sl_NetAppMDNSUnRegisterService(0, 0);
ASSERT_ON_ERROR(retVal);
/* Remove all 64 filters (8*8) */
pal_Memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
retVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask,
sizeof(_WlanRxFilterOperationCommandBuff_t));
ASSERT_ON_ERROR(retVal);
retVal = sl_Stop(SL_STOP_TIMEOUT);
ASSERT_ON_ERROR(retVal);
cc3100_initialize_app_variables();
return retVal; /* Success */