I'm writing a code to connect my ESP8266-07 to Eduroam (WPA2-Enterprise MSCHAPv2).
I followed the SDK2.0 WPA2 flow on documentation but I can't get IP.
This is my user_main.c:
#include "ets_sys.h"
#include "osapi.h"
#include "os_type.h"
#include "user_config.h"
#include "user_interface.h"
#include "wpa2_enterprise.h"
#include "inttypes.h"
#include "mem.h"
#define user_procTaskQueueLen 1
static u8 ent_username[] = "*******";
static u8 ent_password[] = "*******";
static void loop(os_event_t *events);
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static volatile os_timer_t some_timer;
bool checkConnection = true;
void ICACHE_FLASH_ATTR
user_init(){
uart_div_modify(0, UART_CLK_FREQ / 115200);
wifi_station_disconnect();
wifi_set_opmode(STATION_MODE);
char ssid[32] = "eduroam";
char password[64] = {0x00};
struct station_config stationConf;
stationConf.bssid_set = 0; //need not check MAC address of AP
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
if(!wifi_station_set_config(&stationConf)){
os_printf("\r\nset config fail\r\n");
}
// switch to WPA2 Enterprise
wifi_station_set_wpa2_enterprise_auth(1);
if(wifi_station_set_enterprise_username (ent_username, sizeof(ent_username))){
os_printf("\r\nusername set fail\r\n");
}
if(wifi_station_set_enterprise_password (ent_password, sizeof(ent_password))){
os_printf("\r\npassword set fail\r\n");
}
system_os_task(loop, USER_TASK_PRIO_0, user_procTaskQueue, user_procTaskQueueLen);
system_os_post(USER_TASK_PRIO_0, 0, 0 );
}
//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
struct ip_info ipconfig;
wifi_get_ip_info(STATION_IF, &ipconfig);
if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {
os_printf("IP found\n\r");
} else {
os_printf("No IP found\n\r");
}
if(checkConnection)
if(wifi_station_connect())
checkConnection = false;
os_delay_us(10000);
system_os_post(USER_TASK_PRIO_0, 0, 0 );
}
I'm using esp-open-sdk with the latest Espressif SDK (August 2016).
Thanks in advance!