[SYS] Clean queue before restart (#1986)
This commit is contained in:
1 parent
cd04c5b92a
commit
3c0140f57b
1 file changed
+4
-1
+4
-1
@@ -1616,13 +1616,16 @@ void setupTLS(int index) {
|
|||||||
9 - SELFTEST end
|
9 - SELFTEST end
|
||||||
*/
|
*/
|
||||||
void ESPRestart(byte reason) {
|
void ESPRestart(byte reason) {
|
||||||
delay(1000);
|
|
||||||
StaticJsonDocument<128> jsonBuffer;
|
StaticJsonDocument<128> jsonBuffer;
|
||||||
JsonObject jsondata = jsonBuffer.to<JsonObject>();
|
JsonObject jsondata = jsonBuffer.to<JsonObject>();
|
||||||
jsondata["reason"] = reason;
|
jsondata["reason"] = reason;
|
||||||
jsondata["retain"] = true;
|
jsondata["retain"] = true;
|
||||||
jsondata["uptime"] = uptime();
|
jsondata["uptime"] = uptime();
|
||||||
pub(subjectLOGtoMQTT, jsondata);
|
pub(subjectLOGtoMQTT, jsondata);
|
||||||
|
// Clean queue
|
||||||
|
while (!jsonQueue.empty()) {
|
||||||
|
jsonQueue.pop();
|
||||||
|
}
|
||||||
Log.warning(F("Rebooting for reason code %d" CR), reason);
|
Log.warning(F("Rebooting for reason code %d" CR), reason);
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
|||||||
Reference in new issue
Block a user