diff --git a/lib/framework/RestartService.h b/lib/framework/RestartService.h index a3b7b893..01948579 100644 --- a/lib/framework/RestartService.h +++ b/lib/framework/RestartService.h @@ -17,6 +17,7 @@ #include +#include #include #include @@ -31,9 +32,16 @@ class RestartService static void restartNow() { - WiFi.disconnect(true); - delay(500); - ESP.restart(); + xTaskCreate( + [](void *pvParams) { + delay(250); + MDNS.end(); + delay(100); + WiFi.disconnect(true); + delay(500); + ESP.restart(); + }, + "Restart task", 4096, nullptr, 10, nullptr); } private: diff --git a/lib/framework/SleepService.cpp b/lib/framework/SleepService.cpp index 15e12b3d..03416505 100644 --- a/lib/framework/SleepService.cpp +++ b/lib/framework/SleepService.cpp @@ -86,9 +86,10 @@ void SleepService::sleepNow() Serial.println("Good by!"); #endif - // Just to be sure - delay(100); - - // Hibernate - esp_deep_sleep_start(); + xTaskCreate( + [](void *pvParams) { + delay(200); + esp_deep_sleep_start(); + }, + "Sleep task", 4096, nullptr, 10, nullptr); }