Bypass for ESP not reconnecting by WIFI automaticaly the second time (#580)
https://github.com/espressif/arduino-esp32/issues/2501
This commit is contained in:
1 parent
d5724bbf1f
commit
1385ddfa8d
1 file changed
+19
@@ -661,6 +661,21 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
|
// Bypass for ESP not reconnecting automaticaly the second time https://github.com/espressif/arduino-esp32/issues/2501
|
||||||
|
void wifi_reconnect_bypass(){
|
||||||
|
uint8_t wifi_autoreconnect_cnt = 0;
|
||||||
|
#ifdef ESP32
|
||||||
|
while (WiFi.status() != WL_CONNECTED && wifi_autoreconnect_cnt < 3) {
|
||||||
|
#else
|
||||||
|
while (WiFi.waitForConnectResult() != WL_CONNECTED && wifi_autoreconnect_cnt < 3) {
|
||||||
|
#endif
|
||||||
|
Log.notice(F("Attempting Wifi connection with saved AP: %d" CR), wifi_autoreconnect_cnt);
|
||||||
|
WiFi.begin();
|
||||||
|
delay(500);
|
||||||
|
wifi_autoreconnect_cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the 2 methods below are used to recover wifi connection by changing the protocols
|
// the 2 methods below are used to recover wifi connection by changing the protocols
|
||||||
void forceWifiProtocol(){
|
void forceWifiProtocol(){
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -800,6 +815,8 @@ void setup_wifi()
|
|||||||
WiFi.begin(wifi_ssid, wifi_password);
|
WiFi.begin(wifi_ssid, wifi_password);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wifi_reconnect_bypass();
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED)
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
delay(500);
|
delay(500);
|
||||||
@@ -970,6 +987,8 @@ void setup_wifimanager(bool reset_settings)
|
|||||||
//set minimum quality of signal so it ignores AP's under that quality
|
//set minimum quality of signal so it ignores AP's under that quality
|
||||||
wifiManager.setMinimumSignalQuality(MinimumWifiSignalQuality);
|
wifiManager.setMinimumSignalQuality(MinimumWifiSignalQuality);
|
||||||
|
|
||||||
|
wifi_reconnect_bypass();
|
||||||
|
|
||||||
//fetches ssid and pass and tries to connect
|
//fetches ssid and pass and tries to connect
|
||||||
//if it does not connect it starts an access point with the specified name
|
//if it does not connect it starts an access point with the specified name
|
||||||
//and goes into a blocking loop awaiting configuration
|
//and goes into a blocking loop awaiting configuration
|
||||||
|
|||||||
Reference in new issue
Block a user