Fix: Set WiFi setScanMethod and setSortMethod also on first connect

This commit is contained in:
Thomas Basler 2023-07-20 23:44:09 +02:00
parent 3b02ffe7a8
commit 9dbeec3a31

View File

@ -21,6 +21,9 @@ void NetworkSettingsClass::init()
{ {
using std::placeholders::_1; using std::placeholders::_1;
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.onEvent(std::bind(&NetworkSettingsClass::NetworkEvent, this, _1)); WiFi.onEvent(std::bind(&NetworkSettingsClass::NetworkEvent, this, _1));
setupMode(); setupMode();
} }
@ -121,8 +124,6 @@ void NetworkSettingsClass::setupMode()
dnsServer->stop(); dnsServer->stop();
dnsServerStatus = false; dnsServerStatus = false;
if (_networkMode == network_mode::WiFi) { if (_networkMode == network_mode::WiFi) {
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
} else { } else {
WiFi.mode(WIFI_MODE_NULL); WiFi.mode(WIFI_MODE_NULL);