@ -58,6 +58,14 @@ String getCoreRevision() {
# endif
# endif
}
}
unsigned char getHeartbeatMode ( ) {
return getSetting ( " hbMode " , HEARTBEAT_MODE ) . toInt ( ) ;
}
unsigned char getHeartbeatInterval ( ) {
return getSetting ( " hbInterval " , HEARTBEAT_INTERVAL ) . toInt ( ) ;
}
// WTF
// WTF
// Calling ESP.getFreeHeap() is making the system crash on a specific
// Calling ESP.getFreeHeap() is making the system crash on a specific
// AiLight bulb, but anywhere else...
// AiLight bulb, but anywhere else...
@ -135,8 +143,6 @@ unsigned long getUptime() {
}
}
# if HEARTBEAT_MODE != HEARTBEAT_NONE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Heartbeat helper
// Heartbeat helper
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
@ -196,6 +202,7 @@ void heartbeat() {
unsigned int free_heap = getFreeHeap ( ) ;
unsigned int free_heap = getFreeHeap ( ) ;
# if MQTT_SUPPORT
# if MQTT_SUPPORT
unsigned char _heartbeat_mode = getHeartbeatMode ( ) ;
bool serial = ! mqttConnected ( ) ;
bool serial = ! mqttConnected ( ) ;
# else
# else
bool serial = true ;
bool serial = true ;
@ -224,9 +231,9 @@ void heartbeat() {
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
# if MQTT_SUPPORT
# if MQTT_SUPPORT
if ( ! serial ) {
if ( ! serial & & ( _heartbeat_mode = = HEARTBEAT_REPEAT | | systemGetHeartbeat ( ) ) ) {
if ( hb_cfg & Heartbeat : : Interval )
if ( hb_cfg & Heartbeat : : Interval )
mqttSend ( MQTT_TOPIC_INTERVAL , String ( HEARTBEAT_INTERVAL / 1000 ) . c_str ( ) ) ;
mqttSend ( MQTT_TOPIC_INTERVAL , String ( getHeartbeatInterval ( ) / 1000 ) . c_str ( ) ) ;
if ( hb_cfg & Heartbeat : : App )
if ( hb_cfg & Heartbeat : : App )
mqttSend ( MQTT_TOPIC_APP , APP_NAME ) ;
mqttSend ( MQTT_TOPIC_APP , APP_NAME ) ;
@ -280,7 +287,10 @@ void heartbeat() {
if ( hb_cfg & Heartbeat : : Loadavg )
if ( hb_cfg & Heartbeat : : Loadavg )
mqttSend ( MQTT_TOPIC_LOADAVG , String ( systemLoadAverage ( ) ) . c_str ( ) ) ;
mqttSend ( MQTT_TOPIC_LOADAVG , String ( systemLoadAverage ( ) ) . c_str ( ) ) ;
} else if ( ! serial & & _heartbeat_mode = = HEARTBEAT_REPEAT_STATUS ) {
mqttSend ( MQTT_TOPIC_STATUS , MQTT_STATUS_ONLINE , true ) ;
}
}
# endif
# endif
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
@ -300,8 +310,6 @@ void heartbeat() {
}
}
# endif /// HEARTBEAT_MODE != HEARTBEAT_NONE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// INFO
// INFO
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------