From 670f51141556eb65014e6003d95e5a338bd08244 Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:49:57 +0100 Subject: [PATCH] Workaround to determine whether the Wi-Fi data has been changed via BLE --- CO2_Gadget_WIFI.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CO2_Gadget_WIFI.h b/CO2_Gadget_WIFI.h index 7da479ba..85ea0ff3 100644 --- a/CO2_Gadget_WIFI.h +++ b/CO2_Gadget_WIFI.h @@ -717,6 +717,17 @@ void wifiClientLoop() { if (activeWIFI && troubledWIFI && (millis() - timeTroubledWIFI >= timeToRetryTroubledWIFI * 1000)) { initWifi(); } + + // This is a workaround until I can directly determine whether the Wi-Fi data has been changed via BLE + // Only checks for SSID changed (not password) + if (WiFi.SSID() != wifiSSID) { + Serial.println("-->[WiFi] Wi-Fi SSID changed. Old SSID: " + wifiSSID + ", new SSID: " + WiFi.SSID()); + wifiSSID = WiFi.SSID(); + putPreferences(); + // initWifi(); + wifiChanged = true; + } + if (wifiChanged) { wifiChanged = false; initWifi();