diff --git a/src/NetworkSettings.cpp b/src/NetworkSettings.cpp index dac3ecb0a..8ae1c909d 100644 --- a/src/NetworkSettings.cpp +++ b/src/NetworkSettings.cpp @@ -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(); @@ -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); }