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
  • Loading branch information
jstammi committed Aug 10, 2023
1 parent faa0303 commit b6c320d
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 @@ -24,6 +24,8 @@ void NetworkSettingsClass::init()
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 @@ -71,6 +73,7 @@ void NetworkSettingsClass::NetworkEvent(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 b6c320d

Please sign in to comment.