From b37d3bc5fc0e401db257cb3fdb4ec94ffb63c987 Mon Sep 17 00:00:00 2001 From: technyon Date: Sun, 24 Nov 2024 03:43:27 +0100 Subject: [PATCH] remove redundant fetching of wifi credentials from preferences --- src/Config.h | 2 +- src/networkDevices/WifiDevice.cpp | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Config.h b/src/Config.h index bf29145..b09e28d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -4,7 +4,7 @@ #define NUKI_HUB_VERSION "9.02" #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2024-11-23" +#define NUKI_HUB_DATE "2024-11-24" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" diff --git a/src/networkDevices/WifiDevice.cpp b/src/networkDevices/WifiDevice.cpp index 4f2490c..7e5fa3d 100644 --- a/src/networkDevices/WifiDevice.cpp +++ b/src/networkDevices/WifiDevice.cpp @@ -68,11 +68,11 @@ void WifiDevice::scan(bool passive, bool async) if(async) { - Log->println(F("Wi-Fi async scan started")); + Log->println("Wi-Fi async scan started"); } else { - Log->println(F("Wi-Fi sync scan started")); + Log->println("Wi-Fi sync scan started"); } if(passive) { @@ -105,8 +105,6 @@ void WifiDevice::openAP() bool WifiDevice::connect() { bool ret = false; - ssid = _preferences->getString(preference_wifi_ssid, ""); - pass = _preferences->getString(preference_wifi_pass, ""); WiFi.mode(WIFI_STA); WiFi.setHostname(_hostname.c_str()); delay(500); @@ -119,11 +117,11 @@ bool WifiDevice::connect() { if (ssid == WiFi.SSID(i)) { - Log->println(String(F("Saved SSID ")) + ssid + String(F(" found with RSSI: ")) + + Log->println(String("Saved SSID ") + ssid + String(" found with RSSI: ") + String(WiFi.RSSI(i)) + String(F("(")) + String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) + - String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(i) + - String(F(" and channel: ")) + String(WiFi.channel(i))); + String(" %) and BSSID: ") + WiFi.BSSIDstr(i) + + String(" and channel: ") + String(WiFi.channel(i))); if (bestConnection == -1) { bestConnection = i; @@ -145,11 +143,11 @@ bool WifiDevice::connect() } else { - Log->println(String(F("Trying to connect to SSID ")) + ssid + String(F(" found with RSSI: ")) + + Log->println(String("Trying to connect to SSID ") + ssid + String(" found with RSSI: ") + String(WiFi.RSSI(bestConnection)) + String(F("(")) + String(constrain((100.0 + WiFi.RSSI(bestConnection)) * 2, 0, 100)) + - String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(bestConnection) + - String(F(" and channel: ")) + String(WiFi.channel(bestConnection))); + String(" %) and BSSID: ") + WiFi.BSSIDstr(bestConnection) + + String(" and channel: ") + String(WiFi.channel(bestConnection))); } } @@ -244,7 +242,7 @@ bool WifiDevice::isConnected() void WifiDevice::onConnected() { - Log->println(F("Wi-Fi connected")); + Log->println("Wi-Fi connected"); _connected = true; } @@ -260,8 +258,6 @@ void WifiDevice::onDisconnected() //QUICK RECONNECT _connecting = true; - ssid = _preferences->getString(preference_wifi_ssid, ""); - pass = _preferences->getString(preference_wifi_pass, ""); if(!_ipConfiguration->dhcpEnabled()) { @@ -355,16 +351,16 @@ void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &in } else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE) { - Log->println(F("Wi-Fi scan done")); + Log->println("Wi-Fi scan done"); _foundNetworks = WiFi.scanComplete(); for (int i = 0; i < _foundNetworks; i++) { - Log->println(String(F("SSID ")) + WiFi.SSID(i) + String(F(" found with RSSI: ")) + + Log->println(String("SSID ") + WiFi.SSID(i) + String(" found with RSSI: ") + String(WiFi.RSSI(i)) + String(F("(")) + String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) + - String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(i) + - String(F(" and channel: ")) + String(WiFi.channel(i))); + String(" %) and BSSID: ") + WiFi.BSSIDstr(i) + + String(" and channel: ") + String(WiFi.channel(i))); } if (_openAP)