#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "ip_addr.h"
#include "espconn.h"
#include "user_config.h"
#include "user_interface.h"
//We need to include the uart driver
#include "driver/uart.h"
#define user_procTaskPrio 0
#define user_procTaskQueueLen 1
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static void loop(os_event_t *events);
//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
//os_printf("Hello\n\r");
os_delay_us(10000);
system_os_post(user_procTaskPrio, 0, 0 );
}
void wifi_cb(System_Event_t *evt)
{
os_printf("An event occurred: %x\n", evt->event);
}
//Init function
void ICACHE_FLASH_ATTR
user_init()
{
//Edited out my details
char ssid[32] = "MySSID";
char password[64] = "MyPassword";
struct station_config stationConf;
//Set station mode
wifi_set_opmode( 0x1 );
//Set up the UART, maaaybe?
uart_init(BIT_RATE_9600, BIT_RATE_9600);
//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
wifi_station_set_config(&stationConf);
//Hook up the call back for wifi stuff
wifi_set_event_handler_cb(wifi_cb);
//Start os task
system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
system_os_post(user_procTaskPrio, 0, 0 );
}
Until and unless you instruct the WiFi environment in your ESP8266 to perform some task, I wouldn't expect to see a callback to the WiFi event handler as no new WiFi events will have happened.
Might I suggest that in future ... when you post code, also document the intent and algorithms used. Not everyone will make the time to read through code line by line to see what might be going wrong.
When I run that EXACT code (with my network details) the output is
scandone
no shhh... found, reconnect after 1s
reconnect
scandone
no shhh... found, reconnect after 1s
reconnect
scandone
no shhh... found, reconnect after 1s
reconnect
scandone
no shhh... found, reconnect after 1s
reconnect
scandone
no shhh... found, reconnect after 1s
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
a
dd 0
aid 2
cnt
connected with shhh..., channel 6
dhcp client start...
ip:192.168.1.7,mask:255.255.255.0,gw:192.168.1.1
pm open,type:2 0
Which appears to be very close to the output of the example wifi event handler given in the SDK documentation (see pages 73-74 of the version 1.4 SDK API guide).