2019-11-30 12:54:57 +00:00
|
|
|
#include <ResetService.h>
|
|
|
|
|
|
|
|
ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) {
|
2019-11-30 13:15:59 +00:00
|
|
|
server->on(RESET_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest(
|
|
|
|
std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN
|
|
|
|
));
|
2019-11-30 12:54:57 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 13:15:59 +00:00
|
|
|
void ResetService::reset(AsyncWebServerRequest* request) {
|
|
|
|
request->onDisconnect([]() {
|
|
|
|
#if defined(ESP8266)
|
2019-11-30 12:54:57 +00:00
|
|
|
ESP.reset();
|
2019-11-30 13:15:59 +00:00
|
|
|
#elif defined(ESP_PLATFORM)
|
|
|
|
ESP.restart();
|
|
|
|
#endif
|
2019-11-30 12:54:57 +00:00
|
|
|
});
|
|
|
|
request->send(200);
|
|
|
|
}
|