Correct endless loop when first wifi connection missed with wifi manual setup (#636)
and add parenthesis for better understanding of the comparisons correct also a non pertinent ;
This commit is contained in:
1 parent
afa3010033
commit
713727cf98
1 file changed
+6
-6
+6
-6
@@ -653,14 +653,15 @@ void reinit_wifi() {
|
|||||||
|
|
||||||
void disconnection_handling(int failure_number) {
|
void disconnection_handling(int failure_number) {
|
||||||
Log.warning(F("disconnection_handling, failed %d times" CR), failure_number);
|
Log.warning(F("disconnection_handling, failed %d times" CR), failure_number);
|
||||||
if (failure_number > maxConnectionRetry && !connectedOnce) {
|
if ((failure_number > maxConnectionRetry) && !connectedOnce) {
|
||||||
# ifndef ESPWifiManualSetup
|
# ifndef ESPWifiManualSetup
|
||||||
Log.error(F("Failed connecting 1st time to mqtt, you should put TRIGGER_GPIO to LOW or erase the flash" CR));
|
Log.error(F("Failed connecting 1st time to mqtt, you should put TRIGGER_GPIO to LOW or erase the flash" CR));
|
||||||
# endif
|
# endif
|
||||||
} else if (failure_number <= maxConnectionRetry + ATTEMPTS_BEFORE_BG && connectedOnce) {
|
}
|
||||||
|
if (failure_number <= (maxConnectionRetry + ATTEMPTS_BEFORE_BG)) {
|
||||||
Log.warning(F("Attempt to reinit wifi: %d" CR), wifiProtocol);
|
Log.warning(F("Attempt to reinit wifi: %d" CR), wifiProtocol);
|
||||||
reinit_wifi();
|
reinit_wifi();
|
||||||
} else if (failure_number > maxConnectionRetry + ATTEMPTS_BEFORE_BG && failure_number <= maxConnectionRetry + ATTEMPTS_BEFORE_B) // After maxConnectionRetry + ATTEMPTS_BEFORE_BG try to connect with BG protocol
|
} else if ((failure_number > (maxConnectionRetry + ATTEMPTS_BEFORE_BG)) && (failure_number <= (maxConnectionRetry + ATTEMPTS_BEFORE_B))) // After maxConnectionRetry + ATTEMPTS_BEFORE_BG try to connect with BG protocol
|
||||||
{
|
{
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
wifiProtocol = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G;
|
wifiProtocol = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G;
|
||||||
@@ -669,7 +670,7 @@ void disconnection_handling(int failure_number) {
|
|||||||
# endif
|
# endif
|
||||||
Log.warning(F("Wifi Protocol changed to WIFI_11G: %d" CR), wifiProtocol);
|
Log.warning(F("Wifi Protocol changed to WIFI_11G: %d" CR), wifiProtocol);
|
||||||
reinit_wifi();
|
reinit_wifi();
|
||||||
} else if (failure_number > maxConnectionRetry + ATTEMPTS_BEFORE_B && failure_number <= maxConnectionRetry + ATTEMPTS_BEFORE_B + ATTEMPTS_BEFORE_BG) // After maxConnectionRetry + ATTEMPTS_BEFORE_B try to connect with B protocol
|
} else if ((failure_number > (maxConnectionRetry + ATTEMPTS_BEFORE_B)) && (failure_number <= (maxConnectionRetry + ATTEMPTS_BEFORE_B + ATTEMPTS_BEFORE_BG))) // After maxConnectionRetry + ATTEMPTS_BEFORE_B try to connect with B protocol
|
||||||
{
|
{
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
wifiProtocol = WIFI_PROTOCOL_11B;
|
wifiProtocol = WIFI_PROTOCOL_11B;
|
||||||
@@ -678,7 +679,7 @@ void disconnection_handling(int failure_number) {
|
|||||||
# endif
|
# endif
|
||||||
Log.warning(F("Wifi Protocol changed to WIFI_11B: %d" CR), wifiProtocol);
|
Log.warning(F("Wifi Protocol changed to WIFI_11B: %d" CR), wifiProtocol);
|
||||||
reinit_wifi();
|
reinit_wifi();
|
||||||
} else if (failure_number > maxConnectionRetry + ATTEMPTS_BEFORE_B + ATTEMPTS_BEFORE_BG) // After maxConnectionRetry + ATTEMPTS_BEFORE_B try to connect with B protocol
|
} else if (failure_number > (maxConnectionRetry + ATTEMPTS_BEFORE_B + ATTEMPTS_BEFORE_BG)) // After maxConnectionRetry + ATTEMPTS_BEFORE_B try to connect with B protocol
|
||||||
{
|
{
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
wifiProtocol = 0;
|
wifiProtocol = 0;
|
||||||
@@ -748,7 +749,6 @@ void setup_wifi() {
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (wifi_reconnect_bypass())
|
if (wifi_reconnect_bypass())
|
||||||
;
|
|
||||||
Log.notice(F("Connected with saved credentials" CR));
|
Log.notice(F("Connected with saved credentials" CR));
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
|||||||
Reference in new issue
Block a user