Browse Source

mqtt: cancel heartbeat when disconnected

mcspr-patch-1
Maxim Prokhorov 3 years ago
parent
commit
f9cbd507de
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      code/espurna/mqtt.cpp

+ 6
- 5
code/espurna/mqtt.cpp View File

@ -574,19 +574,20 @@ void _mqttCallback(unsigned int type, const char * topic, const char * payload)
} }
bool _mqttHeartbeat(heartbeat::Mask mask) { bool _mqttHeartbeat(heartbeat::Mask mask) {
// No point retrying, since we will be re-scheduled on connection
if (!mqttConnected()) {
return true;
}
#if NTP_SUPPORT
// Backported from the older utils implementation. // Backported from the older utils implementation.
// Wait until the time is synced to avoid sending partial report *and* // Wait until the time is synced to avoid sending partial report *and*
// as a result, wait until the next interval to actually send the datetime string. // as a result, wait until the next interval to actually send the datetime string.
#if NTP_SUPPORT
if ((mask & heartbeat::Report::Datetime) && !ntpSynced()) { if ((mask & heartbeat::Report::Datetime) && !ntpSynced()) {
return false; return false;
} }
#endif #endif
if (!mqttConnected()) {
return false;
}
// TODO: rework old HEARTBEAT_REPEAT_STATUS? // TODO: rework old HEARTBEAT_REPEAT_STATUS?
// for example: send full report once, send only the dynamic data after that // for example: send full report once, send only the dynamic data after that
// (interval, hostname, description, ssid, bssid, ip, mac, rssi, uptime, datetime, heap, loadavg, vcc) // (interval, hostname, description, ssid, bssid, ip, mac, rssi, uptime, datetime, heap, loadavg, vcc)


Loading…
Cancel
Save