I know this is an old issue (and I hope that in the meantime it has been fixed properly), but I got it working with the following approach:
I use the following code to connect to a (P)EAP-enabled WPA2-Enterprise network:
Code: Select all
wifi_set_opmode(STATION_MODE);
struct station_config wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config));
strcpy((char*)wifi_config.ssid, ssid);
wifi_station_set_config(&wifi_config);
wifi_station_dhcpc_start();
wifi_station_clear_cert_key();
wifi_station_set_wpa2_enterprise_auth(1);
wifi_station_set_enterprise_identity((uint8*)username, strlen(username));
wifi_station_set_enterprise_username((uint8*)username, strlen(username));
wifi_station_set_enterprise_password((uint8*)password, strlen(password));
wifi_station_set_enterprise_ca_cert((byte*)ca_cert, strlen(ca_cert));
wifi_station_connect();
1. I got rid of the 'No poison...' error by modifying the malloc implementation (umm_malloc) used to ignore this kind of error. Of course, this is
not the correct way, because you might run into other kinds of issues, but if all you need is a working WPA2-Enterprise connection, then do this at your own risk. (insert `return 1;` at line 43 in
https://raw.githubusercontent.com/esp82 ... m_poison.c`)
2. To use DHCP, I had to implement some kind of timeout as sometimes the dhcp discovery just did not fire - I checked with Wireshark running on the gateway (which also supplies the DHCP leases), and in fact every ~2nd time the ESP did not send the correct DHCP packet. My solution is the following:
Code: Select all
Ticker timer;
bool connected = true;
timer.attach(5, [&](){connected = false;});
while (WiFi.status() != WL_CONNECTED) {
delay(10);
}
timer.detach();
If I do not get a WL_CONNECTED status after 5s, I set the connected flag to false.
My entire code this way:
bool connect() {
wifi_set_opmode(STATION_MODE);
struct station_config wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config));
strcpy((char*)wifi_config.ssid, ssid);
wifi_station_set_config(&wifi_config);
wifi_station_dhcpc_start();
wifi_station_clear_cert_key();
wifi_station_set_wpa2_enterprise_auth(1);
wifi_station_set_enterprise_identity((uint8*)username, strlen(username));
wifi_station_set_enterprise_username((uint8*)username, strlen(username));
wifi_station_set_enterprise_password((uint8*)password, strlen(password));
wifi_station_set_enterprise_ca_cert((byte*)ca_cert, strlen(ca_cert));
wifi_station_connect();
Ticker timer;
bool connected = true;
timer.attach(5, [&](){connected = false;});
while (WiFi.status() != WL_CONNECTED) {
delay(10);
}
timer.detach();
return connected;
}
void connectBlock(){
while(!connect()){
delay(100);
}
}
If you call connectBlock(), you
will get a connection after a while - fine-tune the timeout parameter if you need to, but I found that 5s works for me; and if it seems like a long time, then maybe WiFi is not the best approach for your use-case after all.
Note: After establishing the connection, it is pretty stable, I did not experience an influx of dropouts in contrast with a regular WPA2-PSK network.
I hope I could help, please do share your experiences should you try this approach out!