Skip to content

Commit

Permalink
Fix: explicitly disconnect prior connecting to wifi
Browse files Browse the repository at this point in the history
to prevent from invalid association packets exchange
#618

(cherry picked from commit b6c320d)
  • Loading branch information
jstammi committed Jun 30, 2024
1 parent e541a88 commit 1eab3ae
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/NetworkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void NetworkSettingsClass::init(Scheduler& scheduler)
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);

WiFi.disconnect(true, true);

WiFi.onEvent(std::bind(&NetworkSettingsClass::NetworkEvent, this, _1));
setupMode();

Expand Down Expand Up @@ -77,6 +79,7 @@ void NetworkSettingsClass::NetworkEvent(const WiFiEvent_t event)
MessageOutput.println("WiFi disconnected");
if (_networkMode == network_mode::WiFi) {
MessageOutput.println("Try reconnecting");
WiFi.disconnect(true, true);
WiFi.reconnect();
raiseEvent(network_event::NETWORK_DISCONNECTED);
}
Expand Down

0 comments on commit 1eab3ae

Please sign in to comment.