remove redundant fetching of wifi credentials from preferences

This commit is contained in:
technyon
2024-11-24 03:43:27 +01:00
parent 27fa67f9b1
commit b37d3bc5fc
2 changed files with 14 additions and 18 deletions

View File

@@ -4,7 +4,7 @@
#define NUKI_HUB_VERSION "9.02" #define NUKI_HUB_VERSION "9.02"
#define NUKI_HUB_BUILD "unknownbuildnr" #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_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" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"

View File

@@ -68,11 +68,11 @@ void WifiDevice::scan(bool passive, bool async)
if(async) if(async)
{ {
Log->println(F("Wi-Fi async scan started")); Log->println("Wi-Fi async scan started");
} }
else else
{ {
Log->println(F("Wi-Fi sync scan started")); Log->println("Wi-Fi sync scan started");
} }
if(passive) if(passive)
{ {
@@ -105,8 +105,6 @@ void WifiDevice::openAP()
bool WifiDevice::connect() bool WifiDevice::connect()
{ {
bool ret = false; bool ret = false;
ssid = _preferences->getString(preference_wifi_ssid, "");
pass = _preferences->getString(preference_wifi_pass, "");
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.setHostname(_hostname.c_str()); WiFi.setHostname(_hostname.c_str());
delay(500); delay(500);
@@ -119,11 +117,11 @@ bool WifiDevice::connect()
{ {
if (ssid == WiFi.SSID(i)) 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(WiFi.RSSI(i)) + String(F("(")) +
String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) + String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) +
String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(i) + String(" %) and BSSID: ") + WiFi.BSSIDstr(i) +
String(F(" and channel: ")) + String(WiFi.channel(i))); String(" and channel: ") + String(WiFi.channel(i)));
if (bestConnection == -1) if (bestConnection == -1)
{ {
bestConnection = i; bestConnection = i;
@@ -145,11 +143,11 @@ bool WifiDevice::connect()
} }
else 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(WiFi.RSSI(bestConnection)) + String(F("(")) +
String(constrain((100.0 + WiFi.RSSI(bestConnection)) * 2, 0, 100)) + String(constrain((100.0 + WiFi.RSSI(bestConnection)) * 2, 0, 100)) +
String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(bestConnection) + String(" %) and BSSID: ") + WiFi.BSSIDstr(bestConnection) +
String(F(" and channel: ")) + String(WiFi.channel(bestConnection))); String(" and channel: ") + String(WiFi.channel(bestConnection)));
} }
} }
@@ -244,7 +242,7 @@ bool WifiDevice::isConnected()
void WifiDevice::onConnected() void WifiDevice::onConnected()
{ {
Log->println(F("Wi-Fi connected")); Log->println("Wi-Fi connected");
_connected = true; _connected = true;
} }
@@ -260,8 +258,6 @@ void WifiDevice::onDisconnected()
//QUICK RECONNECT //QUICK RECONNECT
_connecting = true; _connecting = true;
ssid = _preferences->getString(preference_wifi_ssid, "");
pass = _preferences->getString(preference_wifi_pass, "");
if(!_ipConfiguration->dhcpEnabled()) 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) else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE)
{ {
Log->println(F("Wi-Fi scan done")); Log->println("Wi-Fi scan done");
_foundNetworks = WiFi.scanComplete(); _foundNetworks = WiFi.scanComplete();
for (int i = 0; i < _foundNetworks; i++) 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(WiFi.RSSI(i)) + String(F("(")) +
String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) + String(constrain((100.0 + WiFi.RSSI(i)) * 2, 0, 100)) +
String(F(" %) and BSSID: ")) + WiFi.BSSIDstr(i) + String(" %) and BSSID: ") + WiFi.BSSIDstr(i) +
String(F(" and channel: ")) + String(WiFi.channel(i))); String(" and channel: ") + String(WiFi.channel(i)));
} }
if (_openAP) if (_openAP)