#include <espressif/esp_common.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <lwip/sockets.h>
#include <lwip/dns.h>
#include <lwip/netdb.h>
#include <udhcp/dhcpd.h>
void ICACHE_FLASH_ATTR scan_done_callback(void *arg, STATUS status)
{
struct bss_info *bss = arg;
bss = STAILQ_NEXT(bss, next); // ignore first
while (bss)
{
printf("%s %d %d %d\n", bss->ssid, bss->channel, bss->rssi, bss->authmode);
bss = STAILQ_NEXT(bss, next);
}
}
void ICACHE_FLASH_ATTR scanner(void *pvParameters)
{
printf("Starting scanning...");
if (wifi_station_scan(NULL, scan_done_callback))
{
printf("OK!");
}
else
{
printf("Error...");
}
vTaskDelete(NULL);
}
void ICACHE_FLASH_ATTR user_init(void)
{
wifi_set_opmode(STATION_MODE);
wifi_station_set_auto_connect(FALSE);
xTaskCreate(scanner, "scanner", 128, NULL, 2, NULL);
}
Please try something like this.
void ICACHE_FLASH_ATTR init_done(void)
{
xTaskCreate(scanner, "scanner", 128, NULL, 2, NULL);
}
void ICACHE_FLASH_ATTR user_init(void)
{
wifi_set_opmode(STATION_MODE);
wifi_station_set_auto_connect(FALSE);
system_init_done_cb(init_done);
}
crazyferajna wrote:Thank you for your reply. Unfortunately, in FreeRTOS version of the SDK this function is unavailable.
A bit late but i had the same issue as you. The code from the link will help you.
In sort you have to create a task and do the wifi scan in that task. For me it works great.
http://bbs.espressif.com/viewtopic.php?t=974