Wifi scan available access points -program hangs during scan
Posted: Mon Dec 07, 2015 1:22 am
Can someone help me figure our what I am doing incorrectly here? Below is my code to scan for available APs. I'm trying to display all available APs to console (there are a total of 7) but the program never fully prints out the 3rd AP (see console output below). I've tried different examples of the scan_done_callback function (examples in these forums and some of the espressif SDK partial examples) but each one also seems to hang. No WDT resets occur. the program seems to be stuck in the while loop as Scan Done never prints to console. How do I print out all available Access Points? Does anyone have working examples for sdk_v1.4.0?
The device I am trying to run this code on is an ESP-12 dev board as shown here http://tronixlabs.com/wireless/esp8266/ ... australia/
SDK version is esp_iot_sdk_v1.4.0
I'm using esptool.py to flash: python /esptools/tools/esptool.py -p /dev/tty.usbserial write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin (when I build the code the bin files default to those addresses. I'm not 100% sure if the 0x40000 is the correct address I should flash to for the ESP-12 however I was able to successfully run and test code to verify GPIO, PWM, ADC, and other functionality)
rl¦scan APs
mode :..¡18:fe:34:a2:cb:43)
add if0
f r0, scandone
1 : SSID:SSITH CH:1 RSSI:-60 Authmode:3
2 : SSID:Home CH:6 RSSI:-94 Authmode:3
3 : SSID:TG111BA2_RE CH:11 RSSI:-721
The device I am trying to run this code on is an ESP-12 dev board as shown here http://tronixlabs.com/wireless/esp8266/ ... australia/
SDK version is esp_iot_sdk_v1.4.0
I'm using esptool.py to flash: python /esptools/tools/esptool.py -p /dev/tty.usbserial write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin (when I build the code the bin files default to those addresses. I'm not 100% sure if the 0x40000 is the correct address I should flash to for the ESP-12 however I was able to successfully run and test code to verify GPIO, PWM, ADC, and other functionality)
rl¦scan APs
mode :..¡18:fe:34:a2:cb:43)
add if0
f r0, scandone
1 : SSID:SSITH CH:1 RSSI:-60 Authmode:3
2 : SSID:Home CH:6 RSSI:-94 Authmode:3
3 : SSID:TG111BA2_RE CH:11 RSSI:-721
Code: Select all
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "mem.h"
#include "ip_addr.h"
#include "espconn.h"
#include "user_interface.h"
#include "driver/uart.h"
#include "user_config.h"
#define user_procTaskPrio 0
#define user_procTaskQueueLen 1
os_event_t user_procTaskQueue[user_procTaskQueueLen];
uint8_t ssid_found;
// function declarations
static void scan_done_callback(void *arg, STATUS status);
static void initDone_cb();
//-------------------------------------------------------------------------------------------------
// loop function will be execute by "os" periodically
static void ICACHE_FLASH_ATTR loop(os_event_t *events)
{
os_delay_us(10);
}
// scan wifi callback
static void ICACHE_FLASH_ATTR scan_done_callback(void *arg, STATUS status)
{
struct bss_info *bss;
bss = (struct bss_info *)arg;
ssid_found = 0;
while (bss)
{
// The SSID may **NOT** be NULL terminated ... so handle that.
char ssid[sizeof(bss->ssid) + 1];
os_strncpy((char *)ssid, (char *)bss->ssid, sizeof(bss->ssid));
ssid[sizeof(ssid)-1] = '\0';
ssid_found++;
os_printf("%d : SSID:%s CH:%d RSSI:%d Authmode:%d\n", ssid_found, bss->ssid, bss->channel, bss->rssi, bss->authmode);
bss = STAILQ_NEXT(bss, next);
}
os_printf("Scan Done\r\n");
//ssid_scan_done;
}
static void ICACHE_FLASH_ATTR initDone_cb() {
// Ensure we are in station mode
wifi_set_opmode(STATION_MODE);
wifi_station_set_auto_connect(FALSE);
wifi_station_scan(NULL, scan_done_callback);
}
//-------------------------------------------------------------------------------------------------
//Init function
void ICACHE_FLASH_ATTR user_init()
{
// Initialize UART0 to use as debug
UART_init(BIT_RATE_115200, BIT_RATE_115200);
//Scan APs
os_printf("scan APs\r\n");
struct scan_config config;
os_memset(&config, 0, sizeof(struct scan_config));
system_init_done_cb(&initDone_cb);
}