mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
reset mqtt fail count when settings change
This commit is contained in:
@@ -280,6 +280,9 @@ void Mqtt::on_connect() {
|
|||||||
publish("info", doc, false); // send with retain off
|
publish("info", doc, false); // send with retain off
|
||||||
|
|
||||||
publish("status", "online", true); // say we're alive to the Last Will topic, with retain on
|
publish("status", "online", true); // say we're alive to the Last Will topic, with retain on
|
||||||
|
|
||||||
|
reset_publish_fails(); // reset fail count to 0
|
||||||
|
|
||||||
LOG_INFO(F("MQTT connected"));
|
LOG_INFO(F("MQTT connected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Mqtt {
|
|||||||
|
|
||||||
enum Operation { PUBLISH, SUBSCRIBE };
|
enum Operation { PUBLISH, SUBSCRIBE };
|
||||||
|
|
||||||
static constexpr uint8_t MQTT_TOPIC_MAX_SIZE = 60; // include host and base etc
|
static constexpr uint8_t MQTT_TOPIC_MAX_SIZE = 60;
|
||||||
|
|
||||||
// are static to be accessed from EMS devices
|
// are static to be accessed from EMS devices
|
||||||
static void subscribe(const uint8_t device_id, const std::string & topic, mqtt_function_p cb);
|
static void subscribe(const uint8_t device_id, const std::string & topic, mqtt_function_p cb);
|
||||||
@@ -108,6 +108,10 @@ class Mqtt {
|
|||||||
return mqtt_publish_fails_;
|
return mqtt_publish_fails_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reset_publish_fails() {
|
||||||
|
mqtt_publish_fails_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uuid::log::Logger logger_;
|
static uuid::log::Logger logger_;
|
||||||
|
|
||||||
@@ -156,6 +160,7 @@ class Mqtt {
|
|||||||
std::string topic_;
|
std::string topic_;
|
||||||
mqtt_function_p mqtt_function_;
|
mqtt_function_p mqtt_function_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<MQTTFunction> mqtt_functions_; // list of mqtt callbacks for all devices
|
static std::vector<MQTTFunction> mqtt_functions_; // list of mqtt callbacks for all devices
|
||||||
|
|
||||||
uint32_t last_mqtt_poll_ = 0;
|
uint32_t last_mqtt_poll_ = 0;
|
||||||
@@ -165,7 +170,7 @@ class Mqtt {
|
|||||||
static std::string hostname_;
|
static std::string hostname_;
|
||||||
static uint8_t mqtt_qos_;
|
static uint8_t mqtt_qos_;
|
||||||
static uint16_t publish_time_;
|
static uint16_t publish_time_;
|
||||||
}; // namespace emsesp
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user