[SYS] Clean queue before restart (#1986)

This commit is contained in:
Florian authored and GitHub committed 2024-07-03 15:02:32 -05:00
1 parent cd04c5b92a
commit 3c0140f57b
1 file changed
+4 -1
+4 -1
View File
@@ -1616,13 +1616,16 @@ void setupTLS(int index) {
9 - SELFTEST end
*/
void ESPRestart(byte reason) {
delay(1000);
StaticJsonDocument<128> jsonBuffer;
JsonObject jsondata = jsonBuffer.to<JsonObject>();
jsondata["reason"] = reason;
jsondata["retain"] = true;
jsondata["uptime"] = uptime();
pub(subjectLOGtoMQTT, jsondata);
// Clean queue
while (!jsonQueue.empty()) {
jsonQueue.pop();
}
Log.warning(F("Rebooting for reason code %d" CR), reason);
#if defined(ESP32)
ESP.restart();