mqtt DISCONNECTED log fix
This commit is contained in:
parent
9f4f0dba79
commit
d8eb6c87d8
@ -32,14 +32,15 @@ void mqttSetup() {
|
||||
|
||||
void mqttDisconnect() {
|
||||
if (mqttConnected) {
|
||||
error("MQTT", "Disconnecting...");
|
||||
info("MQTT", "Disconnecting");
|
||||
mqtt.disconnect();
|
||||
mqttConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void mqttLoop() {
|
||||
const bool connected = mqtt.loop();
|
||||
if (mqttConnected != !connected) {
|
||||
if (mqttConnected != connected) {
|
||||
if (!connected) {
|
||||
error("MQTT", "DISCONNECTED");
|
||||
}
|
||||
@ -47,7 +48,7 @@ void mqttLoop() {
|
||||
}
|
||||
|
||||
if (isWiFiConnected() && isTimeSet() && !connected && (mqttLastConnectTry == 0 || millis() - mqttLastConnectTry > CONNECT_TIMEOUT_MILLISECONDS)) {
|
||||
error("MQTT", "Connecting: \"%s\"", MQTT_HOST);
|
||||
error("MQTT", "Connecting MQTT host: %s", MQTT_HOST);
|
||||
mqttLastConnectTry = millis();
|
||||
mqtt.setServer(MQTT_HOST, 1883);
|
||||
if (!mqtt.connect(HOSTNAME, logTopic, 0, false, "MQTT disconnected")) {
|
||||
|
||||
@ -148,7 +148,7 @@ void wifiLoop() {
|
||||
} else {
|
||||
if (hasIp) {
|
||||
wifiConnected = true;
|
||||
info("WIFI", "Connected: ip=%s", WiFi.localIP().toString().c_str());
|
||||
info("WIFI", "WiFi connected: ip=%s", WiFi.localIP().toString().c_str());
|
||||
ArduinoOTA.begin();
|
||||
configTime(TIMEZONE_OFFSET, DST_OFFSET, WiFi.gatewayIP().toString().c_str(), NTP_SERVER);
|
||||
} else if (millis() - wifiLastConnectTry > WIFI_TIMEOUT_MS) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user