mirror of
https://github.com/wled/WLED.git
synced 2025-07-16 23:36:35 +00:00
Remove regression
Init wifi for scan Always save WiFi name
This commit is contained in:
parent
1bebf3d3d6
commit
3e2aebcd10
@ -31,8 +31,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
char oldSSID[33]; strcpy(oldSSID, multiWiFi[n].clientSSID);
|
char oldSSID[33]; strcpy(oldSSID, multiWiFi[n].clientSSID);
|
||||||
char oldPass[65]; strcpy(oldPass, multiWiFi[n].clientPass);
|
char oldPass[65]; strcpy(oldPass, multiWiFi[n].clientPass);
|
||||||
|
|
||||||
if (strlen(oldSSID) == 0 || !strncmp(request->arg(cs).c_str(), oldSSID, 32)) {
|
|
||||||
strlcpy(multiWiFi[n].clientSSID, request->arg(cs).c_str(), 33);
|
strlcpy(multiWiFi[n].clientSSID, request->arg(cs).c_str(), 33);
|
||||||
|
if (strlen(oldSSID) == 0 || !strncmp(multiWiFi[n].clientSSID, oldSSID, 32)) {
|
||||||
forceReconnect = true;
|
forceReconnect = true;
|
||||||
}
|
}
|
||||||
if (!isAsterisksOnly(request->arg(pw).c_str(), 65)) {
|
if (!isAsterisksOnly(request->arg(pw).c_str(), 65)) {
|
||||||
|
@ -453,6 +453,7 @@ void WLED::setup()
|
|||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WiFi.mode(WIFI_STA); // enable scanning
|
||||||
findWiFi(true); // start scanning for available WiFi-s
|
findWiFi(true); // start scanning for available WiFi-s
|
||||||
|
|
||||||
#ifdef WLED_ENABLE_ADALIGHT
|
#ifdef WLED_ENABLE_ADALIGHT
|
||||||
@ -720,7 +721,7 @@ bool WLED::findWiFi(bool doScan) {
|
|||||||
WiFi.scanNetworks(true); // start scanning in asynchronous mode
|
WiFi.scanNetworks(true); // start scanning in asynchronous mode
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (status > 0) { // status contains number of found networks
|
if (status >= 0) { // status contains number of found networks
|
||||||
DEBUG_PRINT(F("WiFi scan completed: ")); DEBUG_PRINTLN(status);
|
DEBUG_PRINT(F("WiFi scan completed: ")); DEBUG_PRINTLN(status);
|
||||||
int rssi = -9999;
|
int rssi = -9999;
|
||||||
for (int o = 0; o < status; o++) {
|
for (int o = 0; o < status; o++) {
|
||||||
@ -758,7 +759,7 @@ void WLED::initConnection()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (findWiFi()) WiFi.disconnect(true); // close old connections (only if scan completed and found networks)
|
if (findWiFi()) WiFi.disconnect(); // close old connections (only if scan completed and found networks)
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
WiFi.setPhyMode(force802_3g ? WIFI_PHY_MODE_11G : WIFI_PHY_MODE_11N);
|
WiFi.setPhyMode(force802_3g ? WIFI_PHY_MODE_11G : WIFI_PHY_MODE_11N);
|
||||||
#endif
|
#endif
|
||||||
@ -796,6 +797,7 @@ void WLED::initConnection()
|
|||||||
char hostname[25];
|
char hostname[25];
|
||||||
prepareHostname(hostname);
|
prepareHostname(hostname);
|
||||||
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass); // no harm if called multiple times
|
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass); // no harm if called multiple times
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32S3))
|
#if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32S3))
|
||||||
WiFi.setTxPower(WIFI_POWER_8_5dBm);
|
WiFi.setTxPower(WIFI_POWER_8_5dBm);
|
||||||
@ -892,13 +894,16 @@ void WLED::handleConnection()
|
|||||||
static unsigned long heapTime = 0;
|
static unsigned long heapTime = 0;
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
if (now < 2000 && (!WLED_WIFI_CONFIGURED || apBehavior == AP_BEHAVIOR_ALWAYS))
|
if ((now < 500 && WLED_WIFI_CONFIGURED) || (now < 2000 && (!WLED_WIFI_CONFIGURED || apBehavior == AP_BEHAVIOR_ALWAYS)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (lastReconnectAttempt == 0 || forceReconnect) {
|
if (lastReconnectAttempt == 0 || forceReconnect) {
|
||||||
DEBUG_PRINTLN(F("Initial connect or forced reconnect."));
|
DEBUG_PRINTLN(F("Initial connect or forced reconnect."));
|
||||||
if (forceReconnect) selectedWiFi = 0;
|
findWiFi();
|
||||||
initConnection();
|
initConnection();
|
||||||
|
interfacesInited = false;
|
||||||
|
forceReconnect = false;
|
||||||
|
wasConnected = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,14 +943,7 @@ void WLED::handleConnection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (forceReconnect) {
|
|
||||||
DEBUG_PRINTLN(F("Forcing reconnect."));
|
|
||||||
initConnection();
|
|
||||||
interfacesInited = false;
|
|
||||||
forceReconnect = false;
|
|
||||||
wasConnected = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Network.isConnected()) {
|
if (!Network.isConnected()) {
|
||||||
if (interfacesInited) {
|
if (interfacesInited) {
|
||||||
DEBUG_PRINTLN(F("Disconnected!"));
|
DEBUG_PRINTLN(F("Disconnected!"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user