fix mqtt reconnect delay

This commit is contained in:
technyon
2022-03-27 00:16:49 +01:00
parent ab0fc991ad
commit 38b5af5421

View File

@@ -50,7 +50,7 @@ bool Network::reconnect()
while (!_mqttClient.connected()) { while (!_mqttClient.connected()) {
Serial.println("Attempting MQTT connection"); Serial.println("Attempting MQTT connection");
// Attempt to connect // Attempt to connect
if (_mqttClient.connect("arduinoClient")) { if (_mqttClient.connect("nukiHub")) {
Serial.println("MQTT connected"); Serial.println("MQTT connected");
// ... and resubscribe // ... and resubscribe
@@ -58,6 +58,7 @@ bool Network::reconnect()
} else { } else {
Serial.print("MQTT connect failed, rc="); Serial.print("MQTT connect failed, rc=");
Serial.println(_mqttClient.state()); Serial.println(_mqttClient.state());
vTaskDelay( 5000 / portTICK_PERIOD_MS);
} }
} }
} }
@@ -76,7 +77,6 @@ void Network::update()
bool success = reconnect(); bool success = reconnect();
if(!success) if(!success)
{ {
vTaskDelay( 5000 / portTICK_PERIOD_MS);
return; return;
} }
} }