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
|
//MQTT client connexion management
|
||||||
if (!client.connected()) { // not connected
|
if (!client.connected()) { // not connected
|
||||||
if (now - lastReconnectAttempt > 5000) {
|
if (now - lastReconnectAttempt > 5000) {
|
||||||
|
trc("client disconnected");
|
||||||
lastReconnectAttempt = now;
|
lastReconnectAttempt = now;
|
||||||
// Attempt to reconnect
|
// Attempt to reconnect
|
||||||
|
if (WiFi.status() == WL_CONNECTED){
|
||||||
if (reconnect()) {
|
if (reconnect()) {
|
||||||
lastReconnectAttempt = 0;
|
lastReconnectAttempt = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -848,6 +850,9 @@ void loop()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
trc("wifi disconnected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { //connected
|
} else { //connected
|
||||||
// MQTT loop
|
// MQTT loop
|
||||||
|
|||||||
Reference in new issue
Block a user