From db75db33d8a99a49fcba2abef47143bf32a4ab41 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 11 Sep 2023 21:27:23 -0400 Subject: [PATCH 1/2] fixing issue when wifi connects but no connection was requested --- Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp | 4 ++++ Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp index 66884ed..9aee168 100644 --- a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp +++ b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp @@ -109,6 +109,8 @@ void wifiHandler::update_status() void wifiHandler::update_credentials() { + // No connection was attempted so don't try to to save the creds + if(!this->connect_attempt) return; #if 0 if (strcmp(temporary_password, wifiHandler::password) != 0 || strcmp(temporary_ssid, wifiHandler::SSID) != 0) { @@ -138,6 +140,7 @@ void wifiHandler::update_credentials() preferences.end(); } #endif +this->connect_attempt = false; } void wifiHandler::scan() @@ -200,6 +203,7 @@ void wifiHandler::onStatusUpdate(std::function void wifiHandler::connect(std::shared_ptr ssid, std::shared_ptr password) { + this->connect_attempt = true; this->temporary_password = password; this->temporary_ssid = ssid; WiFi.begin(ssid->c_str(), password->c_str()); diff --git a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.hpp b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.hpp index d44735b..b9a855f 100644 --- a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.hpp +++ b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.hpp @@ -66,6 +66,7 @@ class wifiHandler: public wifiHandlerInterface { std::string getIP(); wifiStatus wifi_status; static std::shared_ptr mInstance; + bool connect_attempt = false; std::shared_ptr temporary_password; std::shared_ptr temporary_ssid; From 94de4d165ecf574b1232c0c434fd5267ca5bb0f7 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 12 Sep 2023 00:03:52 -0400 Subject: [PATCH 2/2] enabling connecting to wifi --- Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp index 9aee168..7b55a67 100644 --- a/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp +++ b/Platformio/HAL/Targets/ESP32/wifiHandler/wifihandler.cpp @@ -179,7 +179,7 @@ void wifiHandler::begin() //strcpy(this->password, password.c_str()); this->SSID = ssid.c_str(); this->password = password.c_str(); - //this->connect(std::make_shared(std::string(this->SSID)), std::make_shared(std::string(this->password))); + this->connect(std::make_shared(std::string(this->SSID)), std::make_shared(std::string(this->password))); } else {