Last active
March 18, 2019 11:29
-
-
Save jtuttas/df7f8c6aa812ba52504298d9fa285322 to your computer and use it in GitHub Desktop.
WPA2 Connection ESP32
This file contains hidden or 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 "esp_wpa2.h" | |
#include "WiFi.h" | |
// SSID to connect to | |
static const char *ssid = "MMBBS-Intern"; | |
// Username for authentification | |
#define EAP_ID "tuttas" | |
#define EAP_USERNAME "tuttas" | |
#define EAP_PASSWORD "geheim" | |
void setup() | |
{ | |
Serial.begin(115200); | |
delay(500); | |
WiFi.disconnect(true); | |
WiFi.mode(WIFI_STA); | |
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ID, strlen(EAP_ID)); | |
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_USERNAME, strlen(EAP_USERNAME)); | |
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD)); | |
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); | |
esp_wifi_sta_wpa2_ent_enable(&config); | |
WiFi.begin(ssid); | |
// 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() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LGTM 👍