reset mqtt fail count when settings change

This commit is contained in:
proddy
2020-07-18 20:58:03 +02:00
parent 938952db57
commit 6cd9113193
2 changed files with 10 additions and 2 deletions

View File

@@ -280,6 +280,9 @@ void Mqtt::on_connect() {
publish("info", doc, false); // send with retain off
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"));
}

View File

@@ -69,7 +69,7 @@ class Mqtt {
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
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_;
}
static void reset_publish_fails() {
mqtt_publish_fails_ = 0;
}
private:
static uuid::log::Logger logger_;
@@ -156,6 +160,7 @@ class Mqtt {
std::string topic_;
mqtt_function_p mqtt_function_;
};
static std::vector<MQTTFunction> mqtt_functions_; // list of mqtt callbacks for all devices
uint32_t last_mqtt_poll_ = 0;
@@ -165,7 +170,7 @@ class Mqtt {
static std::string hostname_;
static uint8_t mqtt_qos_;
static uint16_t publish_time_;
}; // namespace emsesp
};
} // namespace emsesp