mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
formatting
This commit is contained in:
@@ -9,17 +9,17 @@ class FSPersistence {
|
|||||||
public:
|
public:
|
||||||
FSPersistence(JsonStateReader<T> stateReader,
|
FSPersistence(JsonStateReader<T> stateReader,
|
||||||
JsonStateUpdater<T> stateUpdater,
|
JsonStateUpdater<T> stateUpdater,
|
||||||
StatefulService<T> * statefulService,
|
StatefulService<T>* statefulService,
|
||||||
FS * fs,
|
FS* fs,
|
||||||
char const * filePath,
|
char const* filePath,
|
||||||
size_t bufferSize = DEFAULT_BUFFER_SIZE)
|
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||||
: _stateReader(stateReader)
|
_stateReader(stateReader),
|
||||||
, _stateUpdater(stateUpdater)
|
_stateUpdater(stateUpdater),
|
||||||
, _statefulService(statefulService)
|
_statefulService(statefulService),
|
||||||
, _fs(fs)
|
_fs(fs),
|
||||||
, _filePath(filePath)
|
_filePath(filePath),
|
||||||
, _bufferSize(bufferSize)
|
_bufferSize(bufferSize),
|
||||||
, _updateHandlerId(0) {
|
_updateHandlerId(0) {
|
||||||
enableUpdateHandler();
|
enableUpdateHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,9 +37,9 @@ class FSPersistence {
|
|||||||
}
|
}
|
||||||
settingsFile.close();
|
settingsFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reach here we have not been successful in loading the config,
|
// If we reach here we have not been successful in loading the config,
|
||||||
// hard-coded emergency defaults are now applied.
|
// hard-coded emergency defaults are now applied.
|
||||||
|
|
||||||
applyDefaults();
|
applyDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,16 +72,16 @@ class FSPersistence {
|
|||||||
|
|
||||||
void enableUpdateHandler() {
|
void enableUpdateHandler() {
|
||||||
if (!_updateHandlerId) {
|
if (!_updateHandlerId) {
|
||||||
_updateHandlerId = _statefulService->addUpdateHandler([&](const String & originId) { writeToFS(); });
|
_updateHandlerId = _statefulService->addUpdateHandler([&](const String& originId) { writeToFS(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonStateReader<T> _stateReader;
|
JsonStateReader<T> _stateReader;
|
||||||
JsonStateUpdater<T> _stateUpdater;
|
JsonStateUpdater<T> _stateUpdater;
|
||||||
StatefulService<T> * _statefulService;
|
StatefulService<T>* _statefulService;
|
||||||
FS * _fs;
|
FS* _fs;
|
||||||
char const * _filePath;
|
char const* _filePath;
|
||||||
size_t _bufferSize;
|
size_t _bufferSize;
|
||||||
update_handler_id_t _updateHandlerId;
|
update_handler_id_t _updateHandlerId;
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
FactoryResetService::FactoryResetService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
|
FactoryResetService::FactoryResetService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : fs(fs) {
|
||||||
: fs(fs) {
|
|
||||||
server->on(FACTORY_RESET_SERVICE_PATH,
|
server->on(FACTORY_RESET_SERVICE_PATH,
|
||||||
HTTP_POST,
|
HTTP_POST,
|
||||||
securityManager->wrapRequest(std::bind(&FactoryResetService::handleRequest, this, _1), AuthenticationPredicates::IS_ADMIN));
|
securityManager->wrapRequest(std::bind(&FactoryResetService::handleRequest, this, _1),
|
||||||
|
AuthenticationPredicates::IS_ADMIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FactoryResetService::handleRequest(AsyncWebServerRequest * request) {
|
void FactoryResetService::handleRequest(AsyncWebServerRequest* request) {
|
||||||
request->onDisconnect(std::bind(&FactoryResetService::factoryReset, this));
|
request->onDisconnect(std::bind(&FactoryResetService::factoryReset, this));
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user