diff --git a/src/mqtt.cpp b/src/mqtt.cpp index b19dd057e..1126a307e 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -444,7 +444,7 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) { // MQTT onConnect - when an MQTT connect is established // send out some inital MQTT messages void Mqtt::on_connect() { - if (connecting_) { + if (connecting_) { // prevent duplicating connections return; } diff --git a/src/mqtt.h b/src/mqtt.h index 6abf6ff40..c760a767d 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -138,10 +138,6 @@ class Mqtt { return mqtt_enabled_; } - static bool is_connecting() { - return connecting_; - } - static std::string base() { return mqtt_base_; } diff --git a/src/system.cpp b/src/system.cpp index 4db979770..c14498f4e 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -373,14 +373,13 @@ void System::show_mem(const char * note) { // send periodic MQTT message with system information void System::send_heartbeat() { - // don't send heartbeat if WiFi is not connected - int8_t rssi = wifi_quality(); - if (rssi == -1) { + // don't send heartbeat if WiFi or MQTT is connected + if (!Mqtt::connected()) { return; } - // don't send if we're connecting to MQTT - if (Mqtt::is_connecting()) { + int8_t rssi = wifi_quality(); + if (rssi == -1) { return; }