Invalid first entry in list of bss_info structures

User avatar
kolban
Posts: 131
Joined: Tue Jun 16, 2015 1:09 pm
Location: Fort Worth, Texas, USA

Invalid first entry in list of bss_info structures

Postby kolban » Tue Jul 07, 2015 3:30 am

Looking at this forum post, viewtopic.php?f=21&t=229 we are told that the first entry returned in the call to wifi_station_scan is invalid and should be skipped. Is this considered a bug? If not, why are we being returned an invalid structure just to skip over it?

doswork
Posts: 6
Joined: Wed May 20, 2015 3:20 pm

Re: Invalid first entry in list of bss_info structures

Postby doswork » Wed Jul 08, 2015 9:55 am

Actually the first arg of scan_done is pointed to the list head, not the first entry.
u can get more detail from user_webserver.c in the SDK example.

Code: Select all

wifi_station_scan(NULL, json_scan_cb);
LOCAL void ICACHE_FLASH_ATTR json_scan_cb(void *arg, STATUS status)
{
    pscaninfo->pbss = arg;
....
}

struct bss_info *bss = NULL;
bss = STAILQ_FIRST(pscaninfo->pbss);


geo.espressif
Posts: 28
Joined: Tue Mar 31, 2015 7:27 pm

Re: Invalid first entry in list of bss_info structures

Postby geo.espressif » Fri Nov 13, 2015 6:11 pm

Realise this is old, but I've been wrangling with it today. I had been using the queue macros as doswork advised, but it is important to NULL check void* arg, which crucially the reference code in IoTDemo / user_webserver.c does not. About 1 scan in 20 seems to come back with this as NULL, and it depends on how frequently I perform the scan. Anyway here's my code culled to the iteration bits:

Code: Select all

   
    scaninfo pscaninfo;   
    pscaninfo.pbss = arg;

    if (( arg != NULL ) && ( status == OK ))
    {
   bss = STAILQ_FIRST( pscaninfo.pbss );
   while ( bss != NULL )
   {
       os_printf ( "Station MAC: " MACSTR ", ssid: %.32s, channel: %d, rssi: %d\n", MAC2STR(bss->bssid),
         bss->ssid,
         bss->channel,
         bss->rssi );

       // get nexts
       bss = STAILQ_NEXT( bss, next );
    }
    else
    {
   // empty the list
   os_printf ( "Failed to scan\n" );
    }

Who is online

Users browsing this forum: No registered users and 1 guest