[WiFi] Make sure to clear pending WiFi events on reconnect

Apparently this wasn't enough: https://github.com/letscontrolit/ESPEasy/pull/3650

Fix intended for [this report on the forum](https://www.letscontrolit.com/forum/viewtopic.php?p=53062#p53062)
This commit is contained in:
TD-er
2021-06-06 12:05:02 +02:00
parent 71387cb62e
commit f9f86f5e4d
3 changed files with 15 additions and 12 deletions
+12 -12
View File
@@ -56,16 +56,22 @@ bool WiFiEventData_t::unprocessedWifiEvents() const {
}
void WiFiEventData_t::clearAll() {
lastDisconnectMoment.clear();
lastConnectMoment.clear();
lastGetIPmoment.clear();
markWiFiTurnOn();
lastGetScanMoment.clear();
last_wifi_connect_attempt_moment.clear();
timerAPstart.clear();
setWiFiDisconnected();
lastWiFiResetMoment.setNow();
wifi_considered_stable = false;
wifi_TX_pwr = 0;
usedChannel = 0;
}
void WiFiEventData_t::markWiFiTurnOn() {
setWiFiDisconnected();
lastDisconnectMoment.clear();
lastConnectMoment.clear();
lastGetIPmoment.clear();
wifi_considered_stable = false;
// Mark all flags to default to prevent handling old events.
processedConnect = true;
@@ -77,17 +83,11 @@ void WiFiEventData_t::clearAll() {
processedScanDone = true;
wifiConnectAttemptNeeded = true;
wifiConnectInProgress = false;
wifi_TX_pwr = 0;
usedChannel = 0;
}
void WiFiEventData_t::markWiFiBegin() {
setWiFiDisconnected();
lastDisconnectMoment.clear();
lastConnectMoment.clear();
lastGetIPmoment.clear();
markWiFiTurnOn();
last_wifi_connect_attempt_moment.setNow();
wifi_considered_stable = false;
wifiConnectInProgress = true;
usedChannel = 0;
++wifi_connect_attempt;
+1
View File
@@ -29,6 +29,7 @@ struct WiFiEventData_t {
bool unprocessedWifiEvents() const;
void clearAll();
void markWiFiTurnOn();
void markWiFiBegin();
bool WiFiDisconnected() const;
+2
View File
@@ -897,6 +897,8 @@ void setWifiMode(WiFiMode_t wifimode) {
}
if (cur_mode == WIFI_OFF) {
WiFiEventData.markWiFiTurnOn();
#if defined(ESP32)
esp_wifi_set_ps(WIFI_PS_NONE);
#endif