Chat freely about anything...

User avatar
By kirkelton
#34506 Hi all,

I am starting to experiment with the esp8266. I tried to implement a simple wifi scanner, which should scan every 30 secs for all AccessPoints. But i cant get it running. It seems that the ESP crashes after arming the timer. As mentioned in the topic it raises "Fatal exception (9)". Below you can find the code and the UART communication. I hope you guys can help me out. I am sure it is a rookie mistake but I tried for hours and dont know whats wrong.

void user_init(void)
{
uart_init(BIT_RATE_115200, BIT_RATE_115200);
INFO("\r\nUART enabled ...\r\n");
os_delay_us(100000);
//wifi_set_opmode(STATION_MODE);
INFO("System started ...\r\n");
gpio_user_init();
CFG_Load();
os_timer_t timer;
os_timer_disarm(&timer);
uint32_t timespan = 30000;
INFO("Timer config ...\r\n");
os_timer_setfn(&timer, timer_cb, NULL);
INFO("Timer callback set ...\r\n");
os_timer_arm(&timer, timespan, 1);
INFO("Timer armed ...\r\n");
}

void gpio_user_init(void){
gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);

PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
}

void ICACHE_FLASH_ATTR scan_cb(void *arg, STATUS status)
{
INFO("Scan callback ...\r\n");
if(status==OK) {
INFO("Scan Status OK ...\r\n");
struct bss_info *info;
info = (struct bss_info*)arg;
// skip the first in the chain ... it is invalid
info = STAILQ_NEXT(info, next);
while(info != NULL) {
INFO("ssid: %s\n", info->ssid);
info = STAILQ_NEXT(info, next);
}
}
}

void ICACHE_FLASH_ATTR timer_cb(void *arg)
{
INFO("Scanning ...\r\n");
wifi_station_scan(NULL, scan_cb);


########UART OUTPUT############
b��`��뢁use rtc mem data
rlS
UART enabled ...
System started ...

load ...
Timer config ...
Timer callback set ...
Timer armed ...
mode : sta(18:fe:34:f5:37:25)
add if0
Fatal exception (9):
epc1=0x40100751, epc2=0x00000000, epc3=0x00000000, excvaddr=0x40241842, depc=0x00000000

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

load 0x40100000, len 25404, room 16
tail 12
chksum 0x24
ho 0 tail 12 room 4
load 0x3ffe8000, len 848, room 12
tail 4
chksum 0x09
load 0x3ffe8350, len 528, room 4
tail 12
chksum 0xbd
csum 0xbd