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: Application gets hanged when we call Network_IF_DisconnectFromAP() function.

Part Number: CC3220SF

Hi,

We are using AWS FreeRTOS and we have a custom hardware (CC3220SF). When the device wants to switch off the Wi-Fi and before that we are trying to disconnect from AP the application gets hanged in Network_IF_DisconnectFromAP() function. After going through the code of Network_IF_DisconnectFromAP() function there is while loop which checks if the device is disconnected or not for every 1 second as shown below. I feel if the NWP disconnects and connects back within 1 second it is not coming out of the while loop.

 long Network_IF_DisconnectFromAP(void)

{

    long lRetVal = 0;

   

    if (IS_CONNECTED(g_ulStatus))

    {

        lRetVal = sl_WlanDisconnect();

        if (0 == lRetVal)

        {

            while (IS_CONNECTED(g_ulStatus))

            {

                usleep(1000);

            }

            return lRetVal;

        }

        else

        {

            return lRetVal;

        }

    }

    else

    {

        return lRetVal;

    }

}   

  

Device

Amazon FreeRTOS -> 202002

FreeRTOS kernel V10.3.0

FreeRTOS OTA V1.1.1

NA

FreeRTOS MQTT V2.1.1

SL Host Driver Version 2.0.1.27

sp_3.14.0.0_2.0.0.0_2.2.0.7.bin

sp_3.14.0.0_2.0.0.0_2.2.0.7.bin

v2_10_00_04

 

 

Please suggest a solution for this, also check the logs pasted below. The application gets hanged after Post connectionAsyncEvent below.

 

411072.689 - 16 1491 [Tmr Svc] [INFO ][DEMO][1491] [Debug] Post connectionAsyncEvent

411078.689 - 17 1502 [Tmr Svc] [INFO ][DEMO][1501] Device disconnected from the AP on application's request

411078.689 -

411078.689 -

411307.689 - 18 1774 [Tmr Svc] [INFO ][DEMO][1774] Device disconnected from the AP on an ERROR..!!

411307.689 -

411307.689 -

411594.689 - 19 2061 [Tmr Svc] [INFO ][DEMO][2061] [WLAN EVENT] STA Connected to the AP: BSIoT , BSSID: 18:64:72:5c:b2:4d

411594.689 -

411594.689 -

411609.689 - 20 2075 [Tmr Svc] [INFO ][DEMO][2075] [NETAPP EVENT] IP Acquired: IP=172.26.253.153 , Gateway=172.26.0.1

411609.689 -

411609.689 -

411619.689 - 21 2076 [Tmr Svc] [INFO ][DEMO][2076] [Debug] Post connectionAsyncEvent

  • The polling is done every 1 msec (1000 microsec, so not 1 sec) but anyway it looks like a bug. My fix would be to remove this check at all.

    If the value return from wlanDisconnect() is ok, then you should be fine.

    Note that if auto-connect is being used (ie. device gets connected based on a stored profile), then wlanDisconnect is only disconnecting temporarily - as soon as it will disconnect, it will try to reconnect. so wlanDisconnect only really makes sense after connecting with wlanConnect.

    sl_Stop will take care of the disconnection.

  • Hi Kobi, 

    Thanks for quick response, yes we are using Auto connect and I can sense that is the reason why it is connecting back again, from your comments i understand that sl_WlanDisconnect() or Network_IF_DisconnectFromAP is not required as sl_Stop() will take care of it. is my understanding correct ?