mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
gracefully close mqtt on restart
This commit is contained in:
@@ -114,6 +114,12 @@ class Mqtt {
|
|||||||
return mqttClient_ ? mqttClient_->connected() : false;
|
return mqttClient_ ? mqttClient_->connected() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void disconnect() {
|
||||||
|
if (mqttClient_) {
|
||||||
|
mqttClient_->disconnect();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static MqttClient * client() {
|
static MqttClient * client() {
|
||||||
return mqttClient_;
|
return mqttClient_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ void System::system_restart(const char * partitionname) {
|
|||||||
|
|
||||||
store_nvs_values(); // save any NVS values
|
store_nvs_values(); // save any NVS values
|
||||||
Shell::loop_all(); // flush log to output
|
Shell::loop_all(); // flush log to output
|
||||||
|
Mqtt::disconnect(); // gracefully disconnect MQTT, needed for QOS1
|
||||||
delay(1000); // wait 1 second
|
delay(1000); // wait 1 second
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user