mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-11 10:47:10 +01:00
Fixed crash when calling idbSend from an MQTT callback (#410)
This commit is contained in:
@@ -345,10 +345,8 @@ void _mqttCallback(unsigned int type, const char * topic, const char * payload)
|
||||
// Subscribe to internal action topics
|
||||
mqttSubscribe(MQTT_TOPIC_ACTION);
|
||||
|
||||
// Send heartbeat messages
|
||||
#if HEARTBEAT_ENABLED
|
||||
heartbeat();
|
||||
#endif
|
||||
// Flag system to send heartbeat
|
||||
systemSendHeartbeat();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
unsigned long _loopDelay = 0;
|
||||
bool _system_send_heartbeat = false;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -58,6 +59,10 @@ void systemCheckLoop() {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void systemSendHeartbeat() {
|
||||
_system_send_heartbeat = true;
|
||||
}
|
||||
|
||||
void systemLoop() {
|
||||
|
||||
// Check system stability
|
||||
@@ -68,7 +73,8 @@ void systemLoop() {
|
||||
#if HEARTBEAT_ENABLED
|
||||
// Heartbeat
|
||||
static unsigned long last = 0;
|
||||
if ((last == 0) || (millis() - last > HEARTBEAT_INTERVAL)) {
|
||||
if (_system_send_heartbeat || (last == 0) || (millis() - last > HEARTBEAT_INTERVAL)) {
|
||||
_system_send_heartbeat = false;
|
||||
last = millis();
|
||||
heartbeat();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user