mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[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:
@@ -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;
|
||||
|
||||
@@ -29,6 +29,7 @@ struct WiFiEventData_t {
|
||||
bool unprocessedWifiEvents() const;
|
||||
|
||||
void clearAll();
|
||||
void markWiFiTurnOn();
|
||||
void markWiFiBegin();
|
||||
|
||||
bool WiFiDisconnected() const;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user