Voici le code que j'utilise pour me connecter à FreeWifi avec une version récente des bibliothèques ESP où ClientSecure est désormais déprécié. On ne peut pas utiliser le code déjà posté dans ce thread.
J'ai pas mal galéré pour trouver comment se connecter en https SANS fingerprint donc si ça peut aider quelqu'un, voici:
PS: Si vous avez du code pour se connecter aux AP libres d'autres fournisseurs ( Bouygues, SFR, Orange ...) , soyez sympa partagez ...
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define WIFI_TIMEOUT 20
#define HTTP_TIMEOUT 20
const char * ssid = "FreeWifi";
uint16_t port = 443;
String host = "wifi.free.fr";
const char * login = "LOGIN";
const char * pwd = "PASSWORD";
HTTPClient https;
void setup() {
Serial.begin(115200);
Serial.println("");
delay(100);
WiFi.mode(WIFI_STA);
WiFi.persistent(false);
signed int n = WiFi.scanNetworks();
while (n--) {
if (WiFi.encryptionType(n) == ENC_TYPE_NONE && strcmp(WiFi.SSID(n).c_str(), ssid) == 0) {
break;
}
}
if (n == -1) {
Serial.print("Could not find a free Access Point for ssid "); Serial.print(ssid);
return;
}
Serial.print("Connecting to "); Serial.print(WiFi.SSID(n)); Serial.print(" RSSI= "); Serial.println(WiFi.RSSI(n));
WiFi.begin(ssid, "", WiFi.channel(n), WiFi.BSSID(n));
unsigned long start = millis();
while (WiFi.status() != WL_CONNECTED) { //Wait for connection
if (millis() - start > WIFI_TIMEOUT * 1000)
{
Serial.println("WIFI TIMEOUT");
return;
}
Serial.print(".");
delay(500);
}
Serial.println(".Now connected to " + WiFi.SSID(n));
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
client->setInsecure();
String url = "/Auth?login=";
url += String(login);
url += "&password=";
url += String(pwd);
url += "&submit=Valider";
if (https.begin(*client, host, port, url, true)) { // HTTPS
https.addHeader("Content-Type", "text/html");
https.setTimeout(HTTP_TIMEOUT * 1000);
// start connection and send HTTP header
int httpCode = https.POST("");
bool auth_ok = false;
if (httpCode < 0) {
Serial.println( https.errorToString(httpCode).c_str() );
}
else {
if (httpCode == HTTP_CODE_OK) {
while (https.connected()) {
String line = client->readStringUntil('\n');
if (line.indexOf("CONNEXION AU SERVICE REUSSIE") != -1) {
auth_ok = true;
break;
}
}
Serial.println( auth_ok ? "Connexion réussie au service" : "Echec de l'authentification d'accès au service" );
}
else {
Serial.println( https.errorToString(httpCode).c_str() );
}
https.end();
}
}
}