-->
Page 1 of 2

problem with wifi_station_scan()-SDK version:0.9.5-23-1-2015

PostPosted: Tue Mar 10, 2015 4:10 am
by 95tinu
hello,
I want to scan all available APs, So im calling wifi_station_scan(&config,scan_done).
and in config struct all variable I am putting NULL , bcoz in SDK development document I studied if config=NULL ,then only it will scan all available APs,
but this wifi_station_scan() function every time returning FAIL.(means every time its getting fail ).
and I have no idea why its happening like that?
please help me :) :)

Thank you !
herr I am putting my code is anything wrong?
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void user_init(void)
{

config.ssid = NULL;
config.bssid = NULL;
config.channel = 0;
bool chat=0;
uint8 ch;
os_printf("SDK version:%s\n", system_get_sdk_version());
// wifi_station_scan(NULL,scan_done);
// scan_done;
os_printf("before wifi get mode\n");
// wdt_feed();
os_printf("mode=%u\n",wifi_get_opmode());
os_printf("set mode=%u\n", wifi_set_opmode(STATION_MODE));
os_printf("mode_afterset=%u\n",wifi_get_opmode());
os_printf("scan_result=%u\n",wifi_station_scan(NULL,scan_done));
if(wifi_station_scan(&config, scan_done))
{
os_printf("chat=%c\n sid=%s\n bsid=%s\n ch=%d \n",chat,config.ssid,config.bssid,config.channel);
// specialAtState = FALSE;
os_printf("sucess\n");
}
else
{
// at_backError;
os_printf("\r\nERROR\r\n");
// scan_done(&arg,stat);
}

}

static void ICACHE_FLASH_ATTR
scan_done(void* arg,STATUS status)
{
os_printf("enter_scan\n");
uint8 ssid[33];
char temp[128];

if (status == OK)
{
struct bss_info *bss_link = (struct bss_info *)arg;
bss_link = bss_link->next.stqe_next;//ignore first

while (bss_link != NULL)
{
os_memset(ssid, 0, 33);
if (os_strlen(bss_link->ssid) <= 32)
{
os_memcpy(ssid, bss_link->ssid, os_strlen(bss_link->ssid));
}
else
{
os_memcpy(ssid, bss_link->ssid, 32);
}
os_sprintf(temp,"+CWLAP:(%d,\"%s\",%d,\""MACSTR"\",%d)\r\n",
bss_link->authmode, ssid, bss_link->rssi,
os_printf("info=%s\n",temp);
bss_link = bss_link->next.stqe_next;
}
//at_backOk;
os_printf("\nOK\n");
}
else
{

os_printf("\nERROR\n");
//at_backError;
}
// specialAtState = TRUE;
// at_state = at_statIdle;
}


AND OUTPUT:

ets Jan 8 2013,rst cause:2, boot mode:(3,3)

load 0x40100000, len 25616, room 16
tail 0
chksum 0xd1
load 0x3ffe8000, len 2500, room 8
tail 12
chksum 0x5b
ho 0 tail 12 room 4
load 0x3ffe89d0, len 1100, room 12
tail 0
chksum 0x54
csum 0x54
SDK ver: 0.9.5 compiled @ Jan 23 2015 20:38:12
phy ver: 313, pp ver: 8.0

SDK version:0.9.5
before wifi get mode
mode=1
set mode=1
mode_afterset=1
scan_result=0

ERROR :roll: :roll:

Re: problem with wifi_station_scan()-SDK version:0.9.5-23-1-

PostPosted: Thu Mar 12, 2015 7:30 pm
by greggl
You're not alone -- I've been struggling with the exact same problem all day! I also started with the same code routine you pulled from the SDK AT files. I've tried adding start up delays, using different values for wifi_set_opmode, scanning for a single channel, rather than all channels -- all with a FALSE return from wifi_station_scan.

Does anyone have this working? An example of code that does work would be greatly appreciated!

Re: problem with wifi_station_scan()-SDK version:0.9.5-23-1-

PostPosted: Fri Mar 13, 2015 8:38 am
by greggl
I moved the wifi_station_scan() call out of user_init() and into the OS Task and it now works. Perhaps there are limitations on which APIs can be used within user_init()?

Re: problem with wifi_station_scan()-SDK version:0.9.5-23-1-

PostPosted: Tue Nov 03, 2015 5:52 am
by scargill
HI

This just doesn't work...

I fixed the missing ) in the first function - but the config struct - which already exists apparently - I does not appear to have SSID as a member.... anyone have any joy with this? Or am I missing something?