Prvni ulozeni z chegewara githubu
This commit is contained in:
43
libraries/WiFi/examples/WiFiClientEnterprise/README.md
Normal file
43
libraries/WiFi/examples/WiFiClientEnterprise/README.md
Normal file
@ -0,0 +1,43 @@
|
||||
# ESP32-Eduroam
|
||||
* Eduroam wifi connection with university login identity
|
||||
* Working under Eduroam networks worldwide
|
||||
* Methods: PEAP + MsCHAPv2
|
||||
|
||||
# Format
|
||||
* IDENTITY = youridentity --> if connecting from different university, use youridentity@youruniversity.domain format
|
||||
* PASSWORD = yourpassword
|
||||
|
||||
# Usage
|
||||
* Change IDENTITY
|
||||
* Change password
|
||||
* Upload sketch and enjoy!
|
||||
* After sucessful assign of IP address, board will connect to HTTP page on internet to verify your authentification
|
||||
* Board will auto reconnect to Eduroam if it lost connection
|
||||
|
||||
# Tested locations
|
||||
|University|Board|Method|Result|
|
||||
|-------------|-------------| -----|------|
|
||||
|Technical University in Košice (Slovakia)|ESP32 Devkit v1|PEAP + MsCHAPv2|Working|
|
||||
|Technical University in Košice (Slovakia)|ESP32 Devmodule v4|PEAP + MsCHAPv2|Working on 6th attempt in loop|
|
||||
|Slovak Technical University in Bratislava (Slovakia)|ESP32 Devkit v1|PEAP + MsCHAPv2|Working|
|
||||
|University of Antwerp (Belgium)|Lolin32|PEAP + MsCHAPv2|Working|
|
||||
|UPV Universitat Politècnica de València (Spain)|ESP32 Devmodule v4|PEAP + MsCHAPv2|Working|
|
||||
|Local Zeroshell powered network|ESP32 Devkit v1|PEAP + MsCHAPv2|*Not working*|
|
||||
|Hasselt University (Belgium)|xxx|PEAP + MsCHAPv2|Working with fix sketch|
|
||||
|Universidad de Granada (Spain)|Lolin D32 Pro|PEAP + MsCHAPv2|Working|
|
||||
|Universidad de Granada (Spain)|Lolin D32|PEAP + MsCHAPv2|Working|
|
||||
|Universidade Federal de Santa Catarina (Brazil)|xxx|EAP-TTLS + MsCHAPv2|Working|
|
||||
|University of Central Florida (Orlando, Florida)|ESP32 Built-in OLED – Heltec WiFi Kit 32|PEAP + MsCHAPv2|Working|
|
||||
|Université de Montpellier (France)|NodeMCU-32S|PEAP + MsCHAPv2|Working|
|
||||
|
||||
# Common errors - Switch to Debug mode for Serial monitor prints
|
||||
|Error|Appearance|Solution|
|
||||
|-------------|-------------|-------------|
|
||||
|wifi: Set status to INIT|Frequent|Hold EN button for few seconds|
|
||||
|HANDSHAKE_TIMEOUT|Rare|Bug was found under Zeroshell RADIUS authentization - Unsucessful connection|
|
||||
|AUTH_EXPIRE|Common|In the case of weak wifi network signal, this error is quite common, bring your device closer to AP|
|
||||
|ASSOC_EXPIRE|Rare|-|
|
||||
# Sucessful connection example
|
||||

|
||||
# Unsucessful connection example
|
||||

|
@ -0,0 +1,86 @@
|
||||
#include <WiFi.h> //Wifi library
|
||||
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks
|
||||
#define EAP_IDENTITY "login" //if connecting from another corporation, use identity@organisation.domain in Eduroam
|
||||
#define EAP_USERNAME "login" //oftentimes just a repeat of the identity
|
||||
#define EAP_PASSWORD "password" //your Eduroam password
|
||||
const char* ssid = "eduroam"; // Eduroam SSID
|
||||
const char* host = "arduino.php5.sk"; //external server domain for HTTP connection after authentification
|
||||
int counter = 0;
|
||||
|
||||
// NOTE: For some systems, various certification keys are required to connect to the wifi system.
|
||||
// Usually you are provided these by the IT department of your organization when certs are required
|
||||
// and you can't connect with just an identity and password.
|
||||
// Most eduroam setups we have seen do not require this level of authentication, but you should contact
|
||||
// your IT department to verify.
|
||||
// You should uncomment these and populate with the contents of the files if this is required for your scenario (See Example 2 and Example 3 below).
|
||||
//const char *ca_pem = "insert your CA cert from your .pem file here";
|
||||
//const char *client_cert = "insert your client cert from your .crt file here";
|
||||
//const char *client_key = "insert your client key from your .key file here";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
Serial.println();
|
||||
Serial.print("Connecting to network: ");
|
||||
Serial.println(ssid);
|
||||
WiFi.disconnect(true); //disconnect form wifi to set new wifi connection
|
||||
WiFi.mode(WIFI_STA); //init wifi mode
|
||||
|
||||
// Example1 (most common): a cert-file-free eduroam with PEAP (or TTLS)
|
||||
WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_USERNAME, EAP_PASSWORD);
|
||||
|
||||
// Example 2: a cert-file WPA2 Enterprise with PEAP
|
||||
//WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_USERNAME, EAP_PASSWORD, ca_pem, client_cert, client_key);
|
||||
|
||||
// Example 3: TLS with cert-files and no password
|
||||
//WiFi.begin(ssid, WPA2_AUTH_TLS, EAP_IDENTITY, NULL, NULL, ca_pem, client_cert, client_key);
|
||||
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
counter++;
|
||||
if(counter>=60){ //after 30 seconds timeout - reset board
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected");
|
||||
Serial.println("IP address set: ");
|
||||
Serial.println(WiFi.localIP()); //print LAN IP
|
||||
}
|
||||
void loop() {
|
||||
if (WiFi.status() == WL_CONNECTED) { //if we are connected to Eduroam network
|
||||
counter = 0; //reset counter
|
||||
Serial.println("Wifi is still connected with IP: ");
|
||||
Serial.println(WiFi.localIP()); //inform user about his IP address
|
||||
}else if (WiFi.status() != WL_CONNECTED) { //if we lost connection, retry
|
||||
WiFi.begin(ssid);
|
||||
}
|
||||
while (WiFi.status() != WL_CONNECTED) { //during lost connection, print dots
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
counter++;
|
||||
if(counter>=60){ //30 seconds timeout - reset board
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
Serial.print("Connecting to website: ");
|
||||
Serial.println(host);
|
||||
WiFiClient client;
|
||||
if (client.connect(host, 80)) {
|
||||
String url = "/rele/rele1.txt";
|
||||
client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "User-Agent: ESP32\r\n" + "Connection: close\r\n\r\n");
|
||||
|
||||
while (client.connected()) {
|
||||
String line = client.readStringUntil('\n');
|
||||
if (line == "\r") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
String line = client.readStringUntil('\n');
|
||||
Serial.println(line);
|
||||
}else{
|
||||
Serial.println("Connection unsucessful");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user