Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
510 B

  1. #include <ResetService.h>
  2. ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) {
  3. server->on(RESET_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest(
  4. std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN
  5. ));
  6. }
  7. void ResetService::reset(AsyncWebServerRequest* request) {
  8. request->onDisconnect([]() {
  9. #if defined(ESP8266)
  10. ESP.reset();
  11. #elif defined(ESP_PLATFORM)
  12. ESP.restart();
  13. #endif
  14. });
  15. request->send(200);
  16. }