Problems with wifi_set_event_handler_cb
Posted: Sat Nov 07, 2015 2:17 am
I've been trying to get the SDK working, so far I've managed to get a program to compile and flash it to my board (I think it's an 02). The problem I'm having is that I always seem to get the output of the default wifi_set_event_handler_cb() that's mentioned in the SDK guide. I'm using the currently using the latest pre-release from the Espressif forums and I've tried the latest official from the forums, both give me the same thing. I've attached the code I'm trying to get working (it's just the "basic_example" from the examples.) Is there something I'm doing wrong?
Code: Select all
#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 );
}