From 612c263931b69e5acf5301c5f8429501d76dcf0b Mon Sep 17 00:00:00 2001 From: "Eldon R. Brown - WA0UWH" Date: Mon, 11 Dec 2017 12:24:31 -0800 Subject: [PATCH] Added 'datetime' to Mqtt Heartbeat Report This change adds Date and Time ('datetime') to the Mqtt Heartbeat Report, which can help diagnose the Mqtt connection and/or client device problems. Uptime is already reported, but without a datetime context it is unknown if the retained Mqtt informantion is current. Note: Date and Time will not be reported if NTP_SUPPORT is NOT enabled. - --- code/espurna/config/general.h | 2 ++ code/espurna/utils.ino | 3 +++ 2 files changed, 5 insertions(+) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 744c58d4..c738a528 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -120,6 +120,7 @@ #define HEARTBEAT_REPORT_MAC 1 #define HEARTBEAT_REPORT_RSSI 1 #define HEARTBEAT_REPORT_UPTIME 1 +#define HEARTBEAT_REPORT_DATETIME 1 #define HEARTBEAT_REPORT_FREEHEAP 1 #define HEARTBEAT_REPORT_VCC 1 #define HEARTBEAT_REPORT_RELAY 1 @@ -431,6 +432,7 @@ PROGMEM const char* const custom_reset_string[] = { #define MQTT_TOPIC_IP "ip" #define MQTT_TOPIC_VERSION "version" #define MQTT_TOPIC_UPTIME "uptime" +#define MQTT_TOPIC_DATETIME "datetime" #define MQTT_TOPIC_FREEHEAP "freeheap" #define MQTT_TOPIC_VCC "vcc" #define MQTT_TOPIC_STATUS "status" diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 0f557bc4..156856c1 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -118,6 +118,9 @@ void heartbeat() { #if (HEARTBEAT_REPORT_UPTIME) mqttSend(MQTT_TOPIC_UPTIME, String(uptime_seconds).c_str()); #endif + #if (HEARTBEAT_REPORT_DATETIME) & (NTP_SUPPORT) + mqttSend(MQTT_TOPIC_DATETIME, String(ntpDateTime()).c_str()); + #endif #if (HEARTBEAT_REPORT_FREEHEAP) mqttSend(MQTT_TOPIC_FREEHEAP, String(free_heap).c_str()); #endif