Skip to content

Instantly share code, notes, and snippets.

@thomasvt1
Created September 1, 2017 13:26
Show Gist options
  • Save thomasvt1/e43ed7b2a27a25253d784b82bc4b530f to your computer and use it in GitHub Desktop.
Save thomasvt1/e43ed7b2a27a25253d784b82bc4b530f to your computer and use it in GitHub Desktop.
#include <ESP8266WiFi.h>
extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
}
// SSID to connect to
static const char* ssid = "eduroam";
// Username for authentification
static const char* username = "myusername@myinstitution";
// Password for authentication
static const char* password = "mypassword";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// Setting ESP into STATION mode only (no AP mode or dual mode)
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_clear_cert_key();
wifi_station_clear_enterprise_ca_cert();
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_connect();
// Wait for connection AND IP address from DHCP
Serial.println();
Serial.println("Waiting for connection and IP Address from DHCP");
while (WiFi.status() != WL_CONNECTED) {
delay(2000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// put your main code here, to run repeatedly:
}
@thomasvt1
Copy link
Author

thomasvt1 commented Sep 1, 2017

https://github.com/esp8266/Arduino/issues/1032#issuecomment-314477339

So close and yet so far

This is what I did to get a working development environment:

I took a fresh Debian 9 x64 VM
I installed Arduino 1.8.3
In Arduino's package manager I added this repository
https://github.com/esp8266/Arduino/releases/download/2.4.0-rc1/package_esp8266com_index.json
I installed the 2.4.0-rc1 version of the esp8266 library
The 2.4.0-rc1 version of wpa2_enterprise.h does not yet contain the function wifi_station_set_enterprise_identity so I replaced ~/.arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc1/tools/sdk/include/wpa2_enterprise.h with this newer file
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/include/wpa2_enterprise.h
Now I think that the binary library ~/.arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc1/tools/sdk/lib/libwpa2.a also has to be replaced with a newer version that contains the wifi_station_set_enterprise_identity function. So I replaced that file with the version from the expressif SDK https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/lib/libwpa2.a.

I then tried to compile the following code:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment