These are chat archives for SmingHub/Sming

24th
Aug 2016
psychegr
@psychegr
Aug 24 2016 02:27
Anyway to scan for available networks in SmingRTOS?
WifiStation.startScan(networkScanCompleted); returns always false.
hreintke
@hreintke
Aug 24 2016 06:54
@psychegr :
Looking into it I think it is a leftover from the Sming Conversion I did.
StartScan only can be called after the wifi network is ready and checking for that is different in the two Espressif SDK's -> The check for that is wrong.
Workaround for you for now changing the timing of the startscan.
I am out for a couple of days and will check further on it when I return.
psychegr
@psychegr
Aug 24 2016 12:28

@hreintke Ok i found the solution but still i dont know if this is the correct one.
I opened the HttpServer_ConfigNetwork example from Sming and I added the SmingRTOS includes. Then for the wifiscan to work i had to create a freertos task and put the WifiStation.startScan(networkScanCompleted); in the task.
Here is the additional code that i wrote and i am sure that it will help you.

void user_scan(void)
{
// wifi scan has to after system init done

if(wifi_get_opmode() == SOFTAP_MODE)
{
printf("ap mode can't scan !!!\r\n");
//return;
}

WifiStation.startScan(networkScanCompleted);

}

void scan_task(void *pvParameters)
{
printf("Hello, welcome to scan-task!\r\n");

user_scan();

while (1) {
}

}

and in

void user_init()
{
// Start AP for configuration
WifiAccessPoint.enable(true);
WifiAccessPoint.config("Sming Configuration", "", AUTH_OPEN);

// Run WEB server on system ready
startServers();


xTaskCreate(scan_task, (signed char *)"scantsk", 256, NULL, 2, NULL);

}

The post that helped me is this http://bbs.espressif.com/viewtopic.php?t=974