only send heartbeat after MQTT connect

This commit is contained in:
Paul
2020-01-12 12:37:28 +01:00
parent aa721abe77
commit 5b6df62f8f
2 changed files with 7 additions and 8 deletions

View File

@@ -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

View File

@@ -9,7 +9,7 @@
#ifndef MyESP_h
#define MyESP_h
#define MYESP_VERSION "1.2.23"
#define MYESP_VERSION "1.2.24"
#include <ArduinoJson.h>
#include <ArduinoOTA.h>