This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF: Wi-Fi does not reconnect automatically

Part Number: CC3220SF


Dear Team,

I would like to set the reconnect flag to the nwp to allow reconnection to a Wi-Fi network.

In my ConfigureSimplelinkToDefaultState() function, sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION, SL_WLAN_CONNECTION_POLICY(1, 0 , 0, 0), NULL, 0) is called. A set of commands like entering softAP, setting of network info and connect to a profile are done successfully. 

After this, a power cycle is done. At this point, the device does not automatically reconnect to the stored profile. sl_WlanProfileGet(...) function returns 2 with the arguments updated correctly with the stored profile info.

Is it required to issue a command to connect to a profile ?

Thanks and Regards

Sneha

  • Hi Sneha,

    I have assigned this post to one of our SW experts, please give them some time to look into this and provide feedback.

  • Hi,

    There is no need to connect manually if you have the automatic mode enabled.

    From your description, it looks OK.

    Can you share the ConfigureSimplelinkToDefaultState()? what SP are you using?

    Regards,

    Shlomi

  • Hi Shlomi,

    Here is my snippet of function. sp_3.22.0.1_2.7.0.0_2.2.0.7.bin is used

    int ConfigureSimplelinkToDefaultState(void)
    {
    SlWlanRxFilterOperationCommandBuff_t RxFilterIdMask;
    uint16_t BitMap = 0;
    uint8_t TxPower = 0;
    int16_t ConfigRet = -1;
    int ret = -1;

    memset(& RxFilterIdMask,0,sizeof(SlWlanRxFilterOperationCommandBuff_t));ConfigRet = sl_Start();
    if((0 == ConfigRet) || (SL_RET_CODE_DEV_ALREADY_STARTED == ConfigRet))
    {
    if (0 != sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION, SL_WLAN_CONNECTION_POLICY(1, 0 , 0, 0), NULL, 0))
    {
    return -1;
    }

    if (0 != sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP, 0, 0))
    {
    return -1;
    }

    BitMap = 0;
    if (0 != sl_NetCfgSet(SL_NETCFG_IF, SL_NETCFG_IF_STATE, sizeof(BitMap), (uint8_t *)& BitMap))
    {
    return -1;
    }

    if (0 != sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_SCAN_POLICY(0, 0), NULL, 0))
    {
    return -1;
    }

    TxPower = 0;
    if (0 != sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, SL_WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (uint8_t *)&TxPower))
    {
    return -1;
    }

    if (0 != sl_WlanPolicySet(SL_WLAN_POLICY_PM, SL_WLAN_NORMAL_POLICY, NULL, 0))
    {
    return -1;
    }

    if (0 != sl_NetAppMDNSUnRegisterService(0, 0, 0))
    {
    return -1;
    }

    memset(RxFilterIdMask.FilterBitmap, WLAN_CONFIG_DISABLE_RX_FILTER, WLAN_CONFIG_NR_OF_FILTERS);
    if (0 != sl_WlanSet(SL_WLAN_RX_FILTERS_ID, SL_WLAN_RX_FILTER_REMOVE, sizeof(SlWlanRxFilterOperationCommandBuff_t), (uint8_t *)&RxFilterIdMask))
    {
    return -1;
    }

    if (0 == sl_Stop(200))
    {
    return 0;
    }
    }

    return 0;
    }

  • Hi,

    and if you try to get the policy back, what do you get?

    something like: 

    ret = sl_WlanPolicyGet(SL_WLAN_POLICY_CONNECTION ,&Policy,0,(_u8*)&length);

    Shlomi

  • Hi,

    ret = sl_WlanPolicyGet(SL_WLAN_POLICY_CONNECTION ,&Policy,0,(_u8*)&length); returns 0

    The value of Policy is 1 and length is 1.

    This is the value as soon as the auto reconnect is set.

  • yes, so it means that the settings is OK.

    In this case, I do not see a reason why it should not work.

    can you show me how you add the profile?

  • Hi Shlomi,

    This is the code snippet to connect to AP

    long Network_IF_ConnectAP(char *pcSsid, char *pcMacAddress, SlWlanSecParams_t SecurityParams)
    {
    char acCmdStore[128];
    unsigned short usConnTimeout;
    unsigned char ucRecvdAPDetails;
    long lRetVal;
    unsigned long ulIP = 0;
    unsigned long ulSubMask = 0;
    unsigned long ulDefGateway = 0;
    unsigned long ulDns = 0;

    g_usConnectIndex = 0;

    /* Disconnect from the AP */
    Network_IF_DisconnectFromAP();

    CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION);
    CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_ACQUIRED);

    /* Continue only if SSID is not empty */
    if(pcSsid != NULL)
    {
    lRetVal = sl_WlanSetMode(ROLE_STA);
    ASSERT_ON_ERROR(lRetVal);

    lRetVal = sl_Stop(SL_STOP_TIMEOUT);
    lDeviceStatus = sl_Start(0, 0, 0);
    ASSERT_ON_ERROR(lDeviceStatus);

    /* This triggers the CC32xx to connect to a specific AP. */
    lRetVal =
    sl_WlanConnect((signed char *) pcSsid, strlen((const char *) pcSsid),
    NULL, &SecurityParams, NULL);
    ASSERT_ON_ERROR(lRetVal);

    /* Wait for ~10 sec to check if connection to desire AP succeeds */
    lRetVal = -2;
    while(g_usConnectIndex < 10)
    {
    sleep(1);

    if(IS_CONNECTED(g_ulStatus) && IS_IP_ACQUIRED(g_ulStatus))
    {
    lRetVal = 0;
    break;
    }
    g_usConnectIndex++;
    }
    }
    else
    {
    UART_PRINT("Empty SSID, Could not connect\n\r");
    return(-1);
    }

    /* Put message on UART */
    if (0 == lRetVal)
    {
    UART_PRINT("\n\rDevice has connected to %s\n\r", pcSsid);

    /* Get IP address */
    lRetVal = Network_IF_IpConfigGet(&ulIP, &ulSubMask, &ulDefGateway, &ulDns);
    ASSERT_ON_ERROR(lRetVal);

    /* Send the information */
    UART_PRINT("Device IP Address is %d.%d.%d.%d \n\r\n\r",
    SL_IPV4_BYTE(ulIP, 3), SL_IPV4_BYTE(ulIP, 2), SL_IPV4_BYTE(ulIP,
    1),
    SL_IPV4_BYTE(ulIP, 0));

    /// currently only one profile allowed
    lRetVal = sl_WlanProfileDel(SL_WLAN_DEL_ALL_PROFILES);
    lRetVal |= sl_WlanProfileAdd((const int8_t*)pcSsid, (int16_t)strlen((const char *) pcSsid), (const uint8_t*)pcMacAddress, &SecurityParams, NULL, 15, 0);
    }
    else if (-2 == lRetVal)
    {
    UART_PRINT("\n\r Could not connect to the given router \n\r");
    }
    return(lRetVal);
    }

  • what is the pcMacAddress set to?

    what MAC address is it?

  • yes - the MAC address of the chipset

  • which chipset? the cc3220 itself?

  • so this is your issue. The MAC address is the one of the AP in case you have few APs with the same SSID and then you need to populate the MAC address of the AP to connect to a specific one. This is called BSSID. Please leave it NULL and retry.