mqtt_dbg
This commit is contained in:
parent
14767df9ec
commit
9cd5b7132b
|
@ -454,7 +454,8 @@ MqttConfig *ESPMegaIoT::getMqttConfig()
|
|||
|
||||
bool ESPMegaIoT::mqttConnected()
|
||||
{
|
||||
return mqtt_connected;
|
||||
//return mqtt_connected;
|
||||
return mqtt.connected();
|
||||
}
|
||||
|
||||
bool ESPMegaIoT::networkConnected()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <ClimateCard.hpp>
|
||||
|
||||
// #define FRAM_DEBUG
|
||||
#define MQTT_DEBUG
|
||||
|
||||
// Demo PLC firmware using the ESPMegaPRO OOP library
|
||||
|
||||
|
@ -122,4 +123,21 @@ void loop()
|
|||
espmega.dumpFRAMtoSerialASCII(0, 500);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Every 5 seconds, publish "I'm alive" to MQTT
|
||||
#ifdef MQTT_DEBUG
|
||||
static uint32_t last_mqtt_publish = 0;
|
||||
if (millis() - last_mqtt_publish >= 5000)
|
||||
{
|
||||
last_mqtt_publish = millis();
|
||||
espmega.iot->publishToTopic("/espmegai/alive", "true");
|
||||
}
|
||||
static uint32_t last_mqtt_status = 0;
|
||||
if (millis() - last_mqtt_status >= 1000)
|
||||
{
|
||||
last_mqtt_status = millis();
|
||||
Serial.print("MQTT Status: ");
|
||||
Serial.println(espmega.iot->mqttConnected() ? "Connected" : "Disconnected");
|
||||
}
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue