Merge pull request #3521 from TD-er/bugfix/WiFi_bogus_RTC

[WiFi] Fix bogus RTC settings loaded to connect to WiFi
This commit is contained in:
TD-er
2021-02-21 13:29:20 +01:00
committed by GitHub
3 changed files with 18 additions and 11 deletions
+1 -1
View File
@@ -211,7 +211,7 @@ void checkUDP()
std::vector<char> packetBuffer;
packetBuffer.resize(packetSize + 1);
if (packetBuffer.size() >= packetSize) {
if (packetBuffer.size() >= static_cast<size_t>(packetSize)) {
memset(&packetBuffer[0], 0, packetSize + 1);
int len = portUDP.read(&packetBuffer[0], packetSize);
+16 -9
View File
@@ -6,13 +6,15 @@
#include "../Globals/Settings.h"
WiFi_AP_CandidatesList::WiFi_AP_CandidatesList() {
known.clear();
candidates.clear();
known_it = known.begin();
load_knownCredentials();
}
void WiFi_AP_CandidatesList::load_knownCredentials() {
if (!mustLoadCredentials) { return; }
mustLoadCredentials = false;
if (!_mustLoadCredentials) { return; }
_mustLoadCredentials = false;
known.clear();
candidates.clear();
addFromRTC();
@@ -32,7 +34,7 @@ void WiFi_AP_CandidatesList::load_knownCredentials() {
}
void WiFi_AP_CandidatesList::clearCache() {
mustLoadCredentials = true;
_mustLoadCredentials = true;
known.clear();
known_it = known.begin();
}
@@ -68,10 +70,10 @@ void WiFi_AP_CandidatesList::process_WiFiscan(uint8_t scancount) {
}
bool WiFi_AP_CandidatesList::getNext() {
if (candidates.empty()) { return false; }
load_knownCredentials();
if (candidates.empty()) { return false; }
bool mustPop = true;
currentCandidate = candidates.front();
@@ -109,7 +111,7 @@ bool WiFi_AP_CandidatesList::getNext() {
candidates.pop_front();
}
}
return true;
return currentCandidate.usable();
}
const WiFi_AP_Candidate& WiFi_AP_CandidatesList::getCurrent() const {
@@ -228,13 +230,18 @@ bool WiFi_AP_CandidatesList::get_SSID_key(byte index, String& ssid, String& key)
case 1:
ssid = SecuritySettings.WifiSSID;
key = SecuritySettings.WifiKey;
return true;
break;
case 2:
ssid = SecuritySettings.WifiSSID2;
key = SecuritySettings.WifiKey2;
return true;
break;
default:
return false;
}
// TODO TD-er: Read other credentials from extra file.
return false;
ssid.trim();
key.trim();
return true;
}
+1 -1
View File
@@ -55,7 +55,7 @@ private:
WiFi_AP_Candidate currentCandidate;
bool mustLoadCredentials = true;
bool _mustLoadCredentials = true;
};
#endif // ifndef HELPERS_WIFI_AP_CANDIDATESLIST_H