From ade0ea39b6935ed5e2e495dc23424caacb8a9fd5 Mon Sep 17 00:00:00 2001 From: MartinMueller2003 Date: Thu, 7 Mar 2024 08:40:25 -0500 Subject: [PATCH] Added logic to not try to connect to an AP when the default credentials have not been changed by the user at compile time. --- ESPixelStick/src/network/WiFiDriver.cpp | 18 +++++++++++++----- ESPixelStick/src/network/WiFiDriver.hpp | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ESPixelStick/src/network/WiFiDriver.cpp b/ESPixelStick/src/network/WiFiDriver.cpp index 294460400..4dbd90cf9 100644 --- a/ESPixelStick/src/network/WiFiDriver.cpp +++ b/ESPixelStick/src/network/WiFiDriver.cpp @@ -44,7 +44,7 @@ #endif // __has_include("secrets.h") #if !defined(SECRETS_SSID) -# define SECRETS_SSID "DEFAULT_SSID_NOT_SET" +# define SECRETS_SSID DEFAULT_SSID_NOT_SET #endif // SECRETS_SSID #if !defined(SECRETS_PASS) # define SECRETS_PASS "DEFAULT_PASSPHRASE_NOT_SET" @@ -753,11 +753,19 @@ void fsm_WiFi_state_ConnectingUsingDefaults::Init () // DEBUG_START; // DEBUG_V (String ("this: ") + String (uint32_t (this), HEX)); - pWiFiDriver->SetFsmState (this); - pWiFiDriver->AnnounceState (); - pWiFiDriver->GetFsmTimer().StartTimer(1000 * pWiFiDriver->Get_sta_timeout ()); - pWiFiDriver->connectWifi (default_ssid, default_passphrase); + if(!default_ssid.equals(DEFAULT_SSID_NOT_SET)) + { + pWiFiDriver->SetFsmState (this); + pWiFiDriver->AnnounceState (); + pWiFiDriver->GetFsmTimer().StartTimer(1000 * pWiFiDriver->Get_sta_timeout ()); + pWiFiDriver->connectWifi (default_ssid, default_passphrase); + } + else + { + // no defauult ssid was set at compile time. Just move on to AP mode + fsm_WiFi_state_ConnectingAsAP_imp.Init (); + } // pWiFiDriver->displayFsmState (); // DEBUG_END; diff --git a/ESPixelStick/src/network/WiFiDriver.hpp b/ESPixelStick/src/network/WiFiDriver.hpp index 19984b2fd..a3772cd21 100644 --- a/ESPixelStick/src/network/WiFiDriver.hpp +++ b/ESPixelStick/src/network/WiFiDriver.hpp @@ -86,7 +86,7 @@ class c_WiFiDriver void Enable (); private: - +#define DEFAULT_SSID_NOT_SET "DEFAULT_SSID_NOT_SET" int ValidateConfig (); #ifdef ARDUINO_ARCH_ESP8266