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

CCS/CC3220: SDK WLAN scan BUG report

$
0
0

Part Number:CC3220

Tool/software: Code Composer Studio

Hello.

I'm using CC3220MOD with "CC32XX SDK 2.30.00.05" and "sp_3.9.0.6_2.0.0.0_2.2.0.6.bin" service pack, and I encountered a bug during development regarding WLAN scan.

Device is setup in AP mode and scan interval is set to 10 seconds (I won't post the whole project code, focusing only on the bug here).

If "sl_WlanGetNetworkList" is called after a scan has bit initiated, the function should return the number of scanned WLANs or "SL_ERROR_WLAN_GET_NETWORK_LIST_EAGAIN" (which means scan results are not ready yet, and the function should be called again), but some problems happened with this function.

I used the following code (simplified version here) during development for retrieving scan results.

void wlan_scan_test()
{
    int32_t f_result;
    
    uint32_t scan_timeout_ms, elapsed_time_ms;

    SlWlanNetworkEntry_t scanned_wlan_info[30];
    
    bool scan_finished;

    scan_finished = false;
    
    number_of_scanned_wlans = 0;
    
    scan_timeout_ms = 8000;
    
    elapsed_time_ms = 0;
    
    do
    {
        f_result = sl_WlanGetNetworkList(0, 30, scanned_wlan_info);

        switch(f_result)
        {
            case(SL_ERROR_WLAN_GET_NETWORK_LIST_EAGAIN):
            {
                f_result = 0;
            
                continue;
            }
        }

        if(f_result < 0)
        {
            while(1); //NWP error
        }
        
        if(elapsed_time_ms >= scan_timeout_ms)
        {
            //Scan timeout elapsed. Finish.
        
            scan_finished = true;
        }
        else if((0 != number_of_scanned_wlans) &&
        (f_result == number_of_scanned_wlans))
        {
            //Scan fond at least 1 network and last retrieved
            //scanned network list is same as current retrieved network list.
            //Thereof scan has probably finished and enough data is collected.
        
            scan_finished = true;
        }
        else
        {
            //Not networks found during scan or the number of scanned networks keeps expanding.
            //Continue retrieving scan results.
        
            vTaskDelay(1000); //FreeRTOS 1000 ticks timeout (each tick is 1 [ms])

            elapsed_time_ms += 1000;
        }
        
        number_of_scanned_wlans = f_result;
        
        f_result = 0;
    
    }while(!scan_finished);

    return;
}
    

This code worked fine until the device was tested in an area without any WLANs.
In the case without any WLANs, the function "sl_WlanGetNetworkList" would keep returning "SL_ERROR_WLAN_GET_NETWORK_LIST_EAGAIN" forever.
I assumed the function "sl_WlanGetNetworkList" should return a zero (0) if no WLANs have been found, but it didn't, my code got stuck.
The fix for the attached example is it to replace the "continue" statement with a "break" statement in the "switch" case, which would trigger a timeout and leave this function.

The scan function is implemented very poorly, regardless of my issue that "sl_WlanGetNetworkList" never returns 0 if no WLANs could be found,
the scanning process should report some event or set a flag when it completes.
With the current implementation we have to keep pooling scanned network lists and assume at some point that scan has finished, without knowing exactly if it has.

Regards.


Viewing all articles
Browse latest Browse all 262198

Trending Articles



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