Skip to content

Commit

Permalink
Allow reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
steadramon committed Jul 29, 2024
1 parent 280cc25 commit 0f3d23d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ESPGeiger/src/Mqtt/MQTT_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void MQTT_Client::onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
break;
}
Log::console(PSTR("MQTT: Disconnected (%s)"),text.c_str());
mqttClient->clearQueue();
//mqttClient->clearQueue();
status.mqtt_connected = false;
}

Expand All @@ -89,11 +89,15 @@ void MQTT_Client::loop(unsigned long now)
return;
}

if (!status.mqtt_connected) {
if (!mqttClient || !mqttClient->connected()) {
reconnect();
return;
}

if (!status.mqtt_connected) {
onMqttConnect(true);
}

if (now - lastStatus > statusInterval)
{
status.led.Blink(500, 500);
Expand Down

0 comments on commit 0f3d23d

Please sign in to comment.