mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix mqtt heartbeat #710
This commit is contained in:
@@ -444,7 +444,7 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) {
|
|||||||
// MQTT onConnect - when an MQTT connect is established
|
// MQTT onConnect - when an MQTT connect is established
|
||||||
// send out some inital MQTT messages
|
// send out some inital MQTT messages
|
||||||
void Mqtt::on_connect() {
|
void Mqtt::on_connect() {
|
||||||
if (connecting_) {
|
if (connecting_) { // prevent duplicating connections
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,10 +138,6 @@ class Mqtt {
|
|||||||
return mqtt_enabled_;
|
return mqtt_enabled_;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_connecting() {
|
|
||||||
return connecting_;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string base() {
|
static std::string base() {
|
||||||
return mqtt_base_;
|
return mqtt_base_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,14 +373,13 @@ void System::show_mem(const char * note) {
|
|||||||
|
|
||||||
// send periodic MQTT message with system information
|
// send periodic MQTT message with system information
|
||||||
void System::send_heartbeat() {
|
void System::send_heartbeat() {
|
||||||
// don't send heartbeat if WiFi is not connected
|
// don't send heartbeat if WiFi or MQTT is connected
|
||||||
int8_t rssi = wifi_quality();
|
if (!Mqtt::connected()) {
|
||||||
if (rssi == -1) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't send if we're connecting to MQTT
|
int8_t rssi = wifi_quality();
|
||||||
if (Mqtt::is_connecting()) {
|
if (rssi == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user