How to scan networks with FreeRTOS SDK?
Posted: Mon Jan 05, 2015 1:39 pm
Hello everyone! I have written the code to get list of available networks, but it isn't working... The function wifi_station_scan always returns false. What am I doing wrong?
Code: Select all
#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);
}