if wifi is lost the ESP was blocked on a "MQTT connection loop"
To avoid that check the status of wifi connection before trying to connect to mqtt Add of traces
This commit is contained in:
1 parent
e0c8d93802
commit
87c85eabe0
1 file changed
+5
@@ -828,8 +828,10 @@ void loop()
|
||||
//MQTT client connexion management
|
||||
if (!client.connected()) { // not connected
|
||||
if (now - lastReconnectAttempt > 5000) {
|
||||
trc("client disconnected");
|
||||
lastReconnectAttempt = now;
|
||||
// Attempt to reconnect
|
||||
if (WiFi.status() == WL_CONNECTED){
|
||||
if (reconnect()) {
|
||||
lastReconnectAttempt = 0;
|
||||
} else {
|
||||
@@ -848,6 +850,9 @@ void loop()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
trc("wifi disconnected");
|
||||
}
|
||||
}
|
||||
} else { //connected
|
||||
// MQTT loop
|
||||
|
||||
Reference in new issue
Block a user