From 5b6df62f8f2fc91a9e5c92921310344952bcfcb0 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 12 Jan 2020 12:37:28 +0100 Subject: [PATCH] only send heartbeat after MQTT connect --- src/MyESP.cpp | 13 ++++++------- src/MyESP.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/MyESP.cpp b/src/MyESP.cpp index 8ce0e816d..98ae302c7 100644 --- a/src/MyESP.cpp +++ b/src/MyESP.cpp @@ -452,7 +452,7 @@ void MyESP::_mqttOnConnect() { mqttPublish(MQTT_TOPIC_START, MQTT_TOPIC_START_PAYLOAD, false); // send heartbeat if enabled - _heartbeatCheck(); + _heartbeatCheck(true); // call custom function to handle mqtt receives (_mqtt_callback_f)(MQTT_CONNECT_EVENT, nullptr, nullptr); @@ -1455,11 +1455,6 @@ void MyESP::_heartbeatCheck(bool force) { if ((millis() - last_heartbeat > MYESP_HEARTBEAT_INTERVAL) || force) { last_heartbeat = millis(); - // print to log if force is set, so at bootup - if (force) { - _printHeap("[SYSTEM]"); - } - #ifdef MYESP_DEBUG _printHeap("[HEARTBEAT] "); #endif @@ -1467,6 +1462,11 @@ void MyESP::_heartbeatCheck(bool force) { return; } + // print to log if force is set + if (force) { + _printHeap("[SYSTEM]"); + } + uint32_t total_memory = _getInitialFreeHeap(); uint32_t free_memory = ESP.getFreeHeap(); uint8_t mem_available = 100 * free_memory / total_memory; // as a % @@ -2870,7 +2870,6 @@ void MyESP::begin(const char * app_hostname, const char * app_name, const char * _webserver_setup(); // init web server _setSystemCheck(false); // reset system check - _heartbeatCheck(true); // force heartbeat, will send out message to log too _setSystemDropoutCounter(0); // reset # TCP dropouts diff --git a/src/MyESP.h b/src/MyESP.h index fb6a98570..d6df5ccc1 100644 --- a/src/MyESP.h +++ b/src/MyESP.h @@ -9,7 +9,7 @@ #ifndef MyESP_h #define MyESP_h -#define MYESP_VERSION "1.2.23" +#define MYESP_VERSION "1.2.24" #include #include