mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
only send heartbeat after MQTT connect
This commit is contained in:
@@ -452,7 +452,7 @@ void MyESP::_mqttOnConnect() {
|
|||||||
mqttPublish(MQTT_TOPIC_START, MQTT_TOPIC_START_PAYLOAD, false);
|
mqttPublish(MQTT_TOPIC_START, MQTT_TOPIC_START_PAYLOAD, false);
|
||||||
|
|
||||||
// send heartbeat if enabled
|
// send heartbeat if enabled
|
||||||
_heartbeatCheck();
|
_heartbeatCheck(true);
|
||||||
|
|
||||||
// call custom function to handle mqtt receives
|
// call custom function to handle mqtt receives
|
||||||
(_mqtt_callback_f)(MQTT_CONNECT_EVENT, nullptr, nullptr);
|
(_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) {
|
if ((millis() - last_heartbeat > MYESP_HEARTBEAT_INTERVAL) || force) {
|
||||||
last_heartbeat = millis();
|
last_heartbeat = millis();
|
||||||
|
|
||||||
// print to log if force is set, so at bootup
|
|
||||||
if (force) {
|
|
||||||
_printHeap("[SYSTEM]");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MYESP_DEBUG
|
#ifdef MYESP_DEBUG
|
||||||
_printHeap("[HEARTBEAT] ");
|
_printHeap("[HEARTBEAT] ");
|
||||||
#endif
|
#endif
|
||||||
@@ -1467,6 +1462,11 @@ void MyESP::_heartbeatCheck(bool force) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print to log if force is set
|
||||||
|
if (force) {
|
||||||
|
_printHeap("[SYSTEM]");
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t total_memory = _getInitialFreeHeap();
|
uint32_t total_memory = _getInitialFreeHeap();
|
||||||
uint32_t free_memory = ESP.getFreeHeap();
|
uint32_t free_memory = ESP.getFreeHeap();
|
||||||
uint8_t mem_available = 100 * free_memory / total_memory; // as a %
|
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
|
_webserver_setup(); // init web server
|
||||||
|
|
||||||
_setSystemCheck(false); // reset system check
|
_setSystemCheck(false); // reset system check
|
||||||
_heartbeatCheck(true); // force heartbeat, will send out message to log too
|
|
||||||
|
|
||||||
_setSystemDropoutCounter(0); // reset # TCP dropouts
|
_setSystemDropoutCounter(0); // reset # TCP dropouts
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef MyESP_h
|
#ifndef MyESP_h
|
||||||
#define MyESP_h
|
#define MyESP_h
|
||||||
|
|
||||||
#define MYESP_VERSION "1.2.23"
|
#define MYESP_VERSION "1.2.24"
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user