Browse Source
Use ESP.reset() rather than ESP.restart() - due to exceptions encountered on esp8266
master
Use ESP.reset() rather than ESP.restart() - due to exceptions encountered on esp8266
master
Rick Watson
5 years ago
8 changed files with 70 additions and 70 deletions
-
2interface/src/constants/Endpoints.js
-
46interface/src/containers/SystemStatus.js
-
2lib/framework/ESP8266React.cpp
-
4lib/framework/ESP8266React.h
-
14lib/framework/ResetService.cpp
-
29lib/framework/ResetService.h
-
14lib/framework/RestartService.cpp
-
29lib/framework/RestartService.h
@ -0,0 +1,14 @@ |
|||
#include <ResetService.h>
|
|||
|
|||
ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) { |
|||
server->on(RESET_SERVICE_PATH, HTTP_POST, |
|||
securityManager->wrapRequest(std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN) |
|||
); |
|||
} |
|||
|
|||
void ResetService::reset(AsyncWebServerRequest *request) { |
|||
request->onDisconnect([](){ |
|||
ESP.reset(); |
|||
}); |
|||
request->send(200); |
|||
} |
@ -0,0 +1,29 @@ |
|||
#ifndef ResetService_h |
|||
#define ResetService_h |
|||
|
|||
#if defined(ESP8266) |
|||
#include <ESP8266WiFi.h> |
|||
#include <ESPAsyncTCP.h> |
|||
#elif defined(ESP_PLATFORM) |
|||
#include <WiFi.h> |
|||
#include <AsyncTCP.h> |
|||
#endif |
|||
|
|||
#include <ESPAsyncWebServer.h> |
|||
#include <SecurityManager.h> |
|||
|
|||
#define RESET_SERVICE_PATH "/rest/reset" |
|||
|
|||
class ResetService { |
|||
|
|||
public: |
|||
|
|||
ResetService(AsyncWebServer* server, SecurityManager* securityManager); |
|||
|
|||
private: |
|||
|
|||
void reset(AsyncWebServerRequest *request); |
|||
|
|||
}; |
|||
|
|||
#endif // end ResetService_h |
@ -1,14 +0,0 @@ |
|||
#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([](){ |
|||
ESP.restart(); |
|||
}); |
|||
request->send(200); |
|||
} |
@ -1,29 +0,0 @@ |
|||
#ifndef RestartService_h |
|||
#define RestartService_h |
|||
|
|||
#if defined(ESP8266) |
|||
#include <ESP8266WiFi.h> |
|||
#include <ESPAsyncTCP.h> |
|||
#elif defined(ESP_PLATFORM) |
|||
#include <WiFi.h> |
|||
#include <AsyncTCP.h> |
|||
#endif |
|||
|
|||
#include <ESPAsyncWebServer.h> |
|||
#include <SecurityManager.h> |
|||
|
|||
#define RESTART_SERVICE_PATH "/rest/restart" |
|||
|
|||
class RestartService { |
|||
|
|||
public: |
|||
|
|||
RestartService(AsyncWebServer* server, SecurityManager* securityManager); |
|||
|
|||
private: |
|||
|
|||
void restart(AsyncWebServerRequest *request); |
|||
|
|||
}; |
|||
|
|||
#endif // end RestartService_h |
Write
Preview
Loading…
Cancel
Save
Reference in new issue