esp8266-react-framework/lib/framework/RestartService.cpp
Rick Watson 62f3d3fc7a fix broken imports under ESP32
use ESP32 rather than ESP_PLATFORM - it's ambigious
standardise to ifdef ESP32 elif defined(ESP8266)
use ifdef over if defined where possible
2019-12-24 11:19:19 +00:00

20 lines
573 B
C++

#include <RestartService.h>
RestartService::RestartService(AsyncWebServer* server, SecurityManager* securityManager) {
server->on(RESTART_SERVICE_PATH,
HTTP_POST,
securityManager->wrapRequest(std::bind(&RestartService::restart, this, std::placeholders::_1),
AuthenticationPredicates::IS_ADMIN));
}
void RestartService::restart(AsyncWebServerRequest* request) {
request->onDisconnect([]() {
#ifdef ESP32
ESP.restart();
#elif defined(ESP8266)
ESP.reset();
#endif
});
request->send(200);
}