perfer restart on ESP32 platform
This commit is contained in:
parent
a840aba878
commit
1ded736b9a
@ -1,14 +1,18 @@
|
|||||||
#include <ResetService.h>
|
#include <ResetService.h>
|
||||||
|
|
||||||
ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) {
|
ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) {
|
||||||
server->on(RESET_SERVICE_PATH, HTTP_POST,
|
server->on(RESET_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest(
|
||||||
securityManager->wrapRequest(std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN)
|
std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetService::reset(AsyncWebServerRequest *request) {
|
void ResetService::reset(AsyncWebServerRequest* request) {
|
||||||
request->onDisconnect([](){
|
request->onDisconnect([]() {
|
||||||
|
#if defined(ESP8266)
|
||||||
ESP.reset();
|
ESP.reset();
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
ESP.restart();
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user