mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
fix mqtt heartbeat, send when wifi is connected
This commit is contained in:
@@ -271,13 +271,14 @@ void System::loop() {
|
|||||||
|
|
||||||
// send periodic MQTT message with system information
|
// send periodic MQTT message with system information
|
||||||
void System::send_heartbeat() {
|
void System::send_heartbeat() {
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
// don't send heartbeat if WiFi is not connected
|
||||||
|
|
||||||
int rssid = wifi_quality();
|
int rssid = wifi_quality();
|
||||||
if (rssid != -1) {
|
if (rssid == -1) {
|
||||||
doc["rssid"] = rssid;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||||
|
doc["rssid"] = rssid;
|
||||||
doc["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
|
doc["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
|
||||||
doc["uptime_sec"] = uuid::get_uptime_sec();
|
doc["uptime_sec"] = uuid::get_uptime_sec();
|
||||||
doc["freemem"] = free_mem();
|
doc["freemem"] = free_mem();
|
||||||
|
|||||||
Reference in New Issue
Block a user