ESP8266 Wi-Fi WPA2 Enterprise example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
extern "C" { | |
#include "user_interface.h" | |
#include "wpa2_enterprise.h" | |
#include "c_types.h" | |
} | |
// SSID to connect to | |
char ssid[] = "TEST_KRA"; | |
char username[] = "matheus_garbelini"; | |
char identity[] = "matheus_garbelini"; | |
char password[] = "testtest"; | |
uint8_t target_esp_mac[6] = {0x24, 0x0a, 0xc4, 0x9a, 0x58, 0x28}; | |
void setup() { | |
WiFi.mode(WIFI_STA); | |
Serial.begin(115200); | |
delay(1000); | |
Serial.setDebugOutput(true); | |
Serial.printf("SDK version: %s\n", system_get_sdk_version()); | |
Serial.printf("Free Heap: %4d\n",ESP.getFreeHeap()); | |
// 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); | |
strcpy((char*)wifi_config.password, password); | |
wifi_station_set_config(&wifi_config); | |
wifi_set_macaddr(STATION_IF,target_esp_mac); | |
wifi_station_set_wpa2_enterprise_auth(1); | |
// Clean up to be sure no old data is still inside | |
wifi_station_clear_cert_key(); | |
wifi_station_clear_enterprise_ca_cert(); | |
wifi_station_clear_enterprise_identity(); | |
wifi_station_clear_enterprise_username(); | |
wifi_station_clear_enterprise_password(); | |
wifi_station_clear_enterprise_new_password(); | |
wifi_station_set_enterprise_identity((uint8*)identity, strlen(identity)); | |
wifi_station_set_enterprise_username((uint8*)username, strlen(username)); | |
wifi_station_set_enterprise_password((uint8*)password, strlen((char*)password)); | |
wifi_station_connect(); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(1000); | |
Serial.print("."); | |
} | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
} | |
void loop() { | |
} |
ziogianni
commented
Dec 4, 2022
via email
•
Identity must be equal to the username: ***@***.***
As far as I remember, since there’s a bug in the sdk you can only use
***@***.*** as username and identity. Otherwise everything’s
going to be overwritten by this specific hard-coded credential.
Moreover on the Openssl configuration (server side) you need to force the
server to accept TLS 1.0 connections.
If you’re using Arduino IDE, simply select the ESP-12E board and all the
libraries will be loaded accordingly.
Il giorno sab 25 feb 2023 alle 01:04 bhamicus42 ***@***.***>
ha scritto:
… ***@***.**** commented on this gist.
------------------------------
Where can I find the library(ies?) that define WiFi.h, esp_wpa2.h, and
esp_wifi.h?
Thanks a lot! I had so much troubles working with esp8266 in the University. Now the problem is solved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment