auto formatting

This commit is contained in:
proddy
2020-11-23 13:12:20 +01:00
parent 3f0c40d86c
commit d9df0bb996
39 changed files with 1521 additions and 1600 deletions

View File

@@ -1,11 +1,11 @@
#include <APSettingsService.h> #include <APSettingsService.h>
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : APSettingsService::APSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
_httpEndpoint(APSettings::read, APSettings::update, this, server, AP_SETTINGS_SERVICE_PATH, securityManager), : _httpEndpoint(APSettings::read, APSettings::update, this, server, AP_SETTINGS_SERVICE_PATH, securityManager)
_fsPersistence(APSettings::read, APSettings::update, this, fs, AP_SETTINGS_FILE), , _fsPersistence(APSettings::read, APSettings::update, this, fs, AP_SETTINGS_FILE)
_dnsServer(nullptr), , _dnsServer(nullptr)
_lastManaged(0), , _lastManaged(0)
_reconfigureAp(false) { , _reconfigureAp(false) {
addUpdateHandler([&](const String & originId) { reconfigureAP(); }, false); addUpdateHandler([&](const String & originId) { reconfigureAP(); }, false);
} }
@@ -31,13 +31,11 @@ void APSettingsService::loop() {
void APSettingsService::manageAP() { void APSettingsService::manageAP() {
WiFiMode_t currentWiFiMode = WiFi.getMode(); WiFiMode_t currentWiFiMode = WiFi.getMode();
if (_state.provisionMode == AP_MODE_ALWAYS || if (_state.provisionMode == AP_MODE_ALWAYS || (_state.provisionMode == AP_MODE_DISCONNECTED && WiFi.status() != WL_CONNECTED)) {
(_state.provisionMode == AP_MODE_DISCONNECTED && WiFi.status() != WL_CONNECTED)) {
if (_reconfigureAp || currentWiFiMode == WIFI_OFF || currentWiFiMode == WIFI_STA) { if (_reconfigureAp || currentWiFiMode == WIFI_OFF || currentWiFiMode == WIFI_STA) {
startAP(); startAP();
} }
} else if ((currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA) && } else if ((currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA) && (_reconfigureAp || !WiFi.softAPgetStationNum())) {
(_reconfigureAp || !WiFi.softAPgetStationNum())) {
stopAP(); stopAP();
} }
_reconfigureAp = false; _reconfigureAp = false;

View File

@@ -57,8 +57,8 @@ class APSettings {
IPAddress subnetMask; IPAddress subnetMask;
bool operator==(const APSettings & settings) const { bool operator==(const APSettings & settings) const {
return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password && return provisionMode == settings.provisionMode && ssid == settings.ssid && password == settings.password && localIP == settings.localIP
localIP == settings.localIP && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask; && gatewayIP == settings.gatewayIP && subnetMask == settings.subnetMask;
} }
static void read(APSettings & settings, JsonObject & root) { static void read(APSettings & settings, JsonObject & root) {

View File

@@ -1,11 +1,10 @@
#include <APStatus.h> #include <APStatus.h>
APStatus::APStatus(AsyncWebServer* server, SecurityManager* securityManager, APSettingsService* apSettingsService) : APStatus::APStatus(AsyncWebServer * server, SecurityManager * securityManager, APSettingsService * apSettingsService)
_apSettingsService(apSettingsService) { : _apSettingsService(apSettingsService) {
server->on(AP_STATUS_SERVICE_PATH, server->on(AP_STATUS_SERVICE_PATH,
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED));
AuthenticationPredicates::IS_AUTHENTICATED));
} }
void APStatus::apStatus(AsyncWebServerRequest * request) { void APStatus::apStatus(AsyncWebServerRequest * request) {

View File

@@ -1,6 +1,7 @@
#include "ArduinoJsonJWT.h" #include "ArduinoJsonJWT.h"
ArduinoJsonJWT::ArduinoJsonJWT(String secret) : _secret(secret) { ArduinoJsonJWT::ArduinoJsonJWT(String secret)
: _secret(secret) {
} }
void ArduinoJsonJWT::setSecret(String secret) { void ArduinoJsonJWT::setSecret(String secret) {

View File

@@ -2,13 +2,10 @@
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(FT_SECURITY)
AuthenticationService::AuthenticationService(AsyncWebServer* server, SecurityManager* securityManager) : AuthenticationService::AuthenticationService(AsyncWebServer * server, SecurityManager * securityManager)
_securityManager(securityManager), : _securityManager(securityManager)
_signInHandler(SIGN_IN_PATH, , _signInHandler(SIGN_IN_PATH, std::bind(&AuthenticationService::signIn, this, std::placeholders::_1, std::placeholders::_2)) {
std::bind(&AuthenticationService::signIn, this, std::placeholders::_1, std::placeholders::_2)) { server->on(VERIFY_AUTHORIZATION_PATH, HTTP_GET, std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
server->on(VERIFY_AUTHORIZATION_PATH,
HTTP_GET,
std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
_signInHandler.setMethod(HTTP_POST); _signInHandler.setMethod(HTTP_POST);
_signInHandler.setMaxContentLength(MAX_AUTHENTICATION_SIZE); _signInHandler.setMaxContentLength(MAX_AUTHENTICATION_SIZE);
server->addHandler(&_signInHandler); server->addHandler(&_signInHandler);

View File

@@ -11,7 +11,7 @@ class FSPersistence {
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
FS * fs, FS * fs,
char const * filePath, const char * filePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) size_t bufferSize = DEFAULT_BUFFER_SIZE)
: _stateReader(stateReader) : _stateReader(stateReader)
, _stateUpdater(stateUpdater) , _stateUpdater(stateUpdater)
@@ -97,7 +97,7 @@ class FSPersistence {
JsonStateUpdater<T> _stateUpdater; JsonStateUpdater<T> _stateUpdater;
StatefulService<T> * _statefulService; StatefulService<T> * _statefulService;
FS * _fs; FS * _fs;
char const * _filePath; const char * _filePath;
size_t _bufferSize; size_t _bufferSize;
update_handler_id_t _updateHandlerId; update_handler_id_t _updateHandlerId;

View File

@@ -20,20 +20,23 @@ class HttpGetEndpoint {
const String & servicePath, const String & servicePath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { : _stateReader(stateReader)
, _statefulService(statefulService)
, _bufferSize(bufferSize) {
server->on(servicePath.c_str(), server->on(servicePath.c_str(),
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&HttpGetEndpoint::fetchSettings, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&HttpGetEndpoint::fetchSettings, this, std::placeholders::_1), authenticationPredicate));
authenticationPredicate));
} }
HttpGetEndpoint(JsonStateReader<T> stateReader, HttpGetEndpoint(JsonStateReader<T> stateReader,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
const String & servicePath, const String & servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), _statefulService(statefulService), _bufferSize(bufferSize) { : _stateReader(stateReader)
, _statefulService(statefulService)
, _bufferSize(bufferSize) {
server->on(servicePath.c_str(), HTTP_GET, std::bind(&HttpGetEndpoint::fetchSettings, this, std::placeholders::_1)); server->on(servicePath.c_str(), HTTP_GET, std::bind(&HttpGetEndpoint::fetchSettings, this, std::placeholders::_1));
} }
@@ -62,17 +65,15 @@ class HttpPostEndpoint {
const String & servicePath, const String & servicePath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), : _stateReader(stateReader)
_stateUpdater(stateUpdater), , _stateUpdater(stateUpdater)
_statefulService(statefulService), , _statefulService(statefulService)
_updateHandler( , _updateHandler(servicePath,
servicePath, securityManager->wrapCallback(std::bind(&HttpPostEndpoint::updateSettings, this, std::placeholders::_1, std::placeholders::_2),
securityManager->wrapCallback(
std::bind(&HttpPostEndpoint::updateSettings, this, std::placeholders::_1, std::placeholders::_2),
authenticationPredicate), authenticationPredicate),
bufferSize), bufferSize)
_bufferSize(bufferSize) { , _bufferSize(bufferSize) {
_updateHandler.setMethod(HTTP_POST); _updateHandler.setMethod(HTTP_POST);
server->addHandler(&_updateHandler); server->addHandler(&_updateHandler);
} }
@@ -82,14 +83,12 @@ class HttpPostEndpoint {
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
const String & servicePath, const String & servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
_stateReader(stateReader), : _stateReader(stateReader)
_stateUpdater(stateUpdater), , _stateUpdater(stateUpdater)
_statefulService(statefulService), , _statefulService(statefulService)
_updateHandler(servicePath, , _updateHandler(servicePath, std::bind(&HttpPostEndpoint::updateSettings, this, std::placeholders::_1, std::placeholders::_2), bufferSize)
std::bind(&HttpPostEndpoint::updateSettings, this, std::placeholders::_1, std::placeholders::_2), , _bufferSize(bufferSize) {
bufferSize),
_bufferSize(bufferSize) {
_updateHandler.setMethod(HTTP_POST); _updateHandler.setMethod(HTTP_POST);
server->addHandler(&_updateHandler); server->addHandler(&_updateHandler);
} }
@@ -133,22 +132,9 @@ class HttpEndpoint : public HttpGetEndpoint<T>, public HttpPostEndpoint<T> {
const String & servicePath, const String & servicePath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
HttpGetEndpoint<T>(stateReader, : HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize)
statefulService, , HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) {
server,
servicePath,
securityManager,
authenticationPredicate,
bufferSize),
HttpPostEndpoint<T>(stateReader,
stateUpdater,
statefulService,
server,
servicePath,
securityManager,
authenticationPredicate,
bufferSize) {
} }
HttpEndpoint(JsonStateReader<T> stateReader, HttpEndpoint(JsonStateReader<T> stateReader,
@@ -156,9 +142,9 @@ class HttpEndpoint : public HttpGetEndpoint<T>, public HttpPostEndpoint<T> {
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
const String & servicePath, const String & servicePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, bufferSize), : HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, bufferSize)
HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) { , HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) {
} }
}; };

View File

@@ -13,8 +13,10 @@ class MqttConnector {
AsyncMqttClient * _mqttClient; AsyncMqttClient * _mqttClient;
size_t _bufferSize; size_t _bufferSize;
MqttConnector(StatefulService<T>* statefulService, AsyncMqttClient* mqttClient, size_t bufferSize) : MqttConnector(StatefulService<T> * statefulService, AsyncMqttClient * mqttClient, size_t bufferSize)
_statefulService(statefulService), _mqttClient(mqttClient), _bufferSize(bufferSize) { : _statefulService(statefulService)
, _mqttClient(mqttClient)
, _bufferSize(bufferSize) {
_mqttClient->onConnect(std::bind(&MqttConnector::onConnect, this)); _mqttClient->onConnect(std::bind(&MqttConnector::onConnect, this));
} }
@@ -33,8 +35,10 @@ class MqttPub : virtual public MqttConnector<T> {
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncMqttClient * mqttClient, AsyncMqttClient * mqttClient,
const String & pubTopic = "", const String & pubTopic = "",
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
MqttConnector<T>(statefulService, mqttClient, bufferSize), _stateReader(stateReader), _pubTopic(pubTopic) { : MqttConnector<T>(statefulService, mqttClient, bufferSize)
, _stateReader(stateReader)
, _pubTopic(pubTopic) {
MqttConnector<T>::_statefulService->addUpdateHandler([&](const String & originId) { publish(); }, false); MqttConnector<T>::_statefulService->addUpdateHandler([&](const String & originId) { publish(); }, false);
} }
@@ -76,8 +80,10 @@ class MqttSub : virtual public MqttConnector<T> {
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncMqttClient * mqttClient, AsyncMqttClient * mqttClient,
const String & subTopic = "", const String & subTopic = "",
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
MqttConnector<T>(statefulService, mqttClient, bufferSize), _stateUpdater(stateUpdater), _subTopic(subTopic) { : MqttConnector<T>(statefulService, mqttClient, bufferSize)
, _stateUpdater(stateUpdater)
, _subTopic(subTopic) {
MqttConnector<T>::_mqttClient->onMessage(std::bind(&MqttSub::onMqttMessage, MqttConnector<T>::_mqttClient->onMessage(std::bind(&MqttSub::onMqttMessage,
this, this,
std::placeholders::_1, std::placeholders::_1,
@@ -115,12 +121,7 @@ class MqttSub : virtual public MqttConnector<T> {
} }
} }
void onMqttMessage(char* topic, void onMqttMessage(char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
char* payload,
AsyncMqttClientMessageProperties properties,
size_t len,
size_t index,
size_t total) {
// we only care about the topic we are watching in this class // we only care about the topic we are watching in this class
if (strcmp(_subTopic.c_str(), topic)) { if (strcmp(_subTopic.c_str(), topic)) {
return; return;
@@ -145,10 +146,10 @@ class MqttPubSub : public MqttPub<T>, public MqttSub<T> {
AsyncMqttClient * mqttClient, AsyncMqttClient * mqttClient,
const String & pubTopic = "", const String & pubTopic = "",
const String & subTopic = "", const String & subTopic = "",
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
MqttConnector<T>(statefulService, mqttClient, bufferSize), : MqttConnector<T>(statefulService, mqttClient, bufferSize)
MqttPub<T>(stateReader, statefulService, mqttClient, pubTopic, bufferSize), , MqttPub<T>(stateReader, statefulService, mqttClient, pubTopic, bufferSize)
MqttSub<T>(stateUpdater, statefulService, mqttClient, subTopic, bufferSize) { , MqttSub<T>(stateUpdater, statefulService, mqttClient, subTopic, bufferSize) {
} }
public: public:

View File

@@ -1,26 +1,21 @@
#include <NTPSettingsService.h> #include <NTPSettingsService.h>
NTPSettingsService::NTPSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : NTPSettingsService::NTPSettingsService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
_httpEndpoint(NTPSettings::read, NTPSettings::update, this, server, NTP_SETTINGS_SERVICE_PATH, securityManager), : _httpEndpoint(NTPSettings::read, NTPSettings::update, this, server, NTP_SETTINGS_SERVICE_PATH, securityManager)
_fsPersistence(NTPSettings::read, NTPSettings::update, this, fs, NTP_SETTINGS_FILE), , _fsPersistence(NTPSettings::read, NTPSettings::update, this, fs, NTP_SETTINGS_FILE)
_timeHandler(TIME_PATH, , _timeHandler(TIME_PATH,
securityManager->wrapCallback( securityManager->wrapCallback(std::bind(&NTPSettingsService::configureTime, this, std::placeholders::_1, std::placeholders::_2),
std::bind(&NTPSettingsService::configureTime, this, std::placeholders::_1, std::placeholders::_2),
AuthenticationPredicates::IS_ADMIN)) { AuthenticationPredicates::IS_ADMIN)) {
_timeHandler.setMethod(HTTP_POST); _timeHandler.setMethod(HTTP_POST);
_timeHandler.setMaxContentLength(MAX_TIME_SIZE); _timeHandler.setMaxContentLength(MAX_TIME_SIZE);
server->addHandler(&_timeHandler); server->addHandler(&_timeHandler);
#ifdef ESP32 #ifdef ESP32
WiFi.onEvent( WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED); WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2), WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2), WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
#elif defined(ESP8266) #elif defined(ESP8266)
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected( _onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1)); _onStationModeGotIPHandler = WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1));
_onStationModeGotIPHandler =
WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1));
#endif #endif
addUpdateHandler([&](const String & originId) { configureNTP(); }, false); addUpdateHandler([&](const String & originId) { configureNTP(); }, false);
} }

View File

@@ -3,8 +3,7 @@
NTPStatus::NTPStatus(AsyncWebServer * server, SecurityManager * securityManager) { NTPStatus::NTPStatus(AsyncWebServer * server, SecurityManager * securityManager) {
server->on(NTP_STATUS_SERVICE_PATH, server->on(NTP_STATUS_SERVICE_PATH,
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&NTPStatus::ntpStatus, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&NTPStatus::ntpStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED));
AuthenticationPredicates::IS_AUTHENTICATED));
} }
String toISOString(tm * time, bool incOffset) { String toISOString(tm * time, bool incOffset) {

View File

@@ -3,8 +3,7 @@
RestartService::RestartService(AsyncWebServer * server, SecurityManager * securityManager) { RestartService::RestartService(AsyncWebServer * server, SecurityManager * securityManager) {
server->on(RESTART_SERVICE_PATH, server->on(RESTART_SERVICE_PATH,
HTTP_POST, HTTP_POST,
securityManager->wrapRequest(std::bind(&RestartService::restart, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&RestartService::restart, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN));
AuthenticationPredicates::IS_ADMIN));
} }
void RestartService::restart(AsyncWebServerRequest * request) { void RestartService::restart(AsyncWebServerRequest * request) {

View File

@@ -27,7 +27,10 @@ class User {
bool admin; bool admin;
public: public:
User(String username, String password, bool admin) : username(username), password(password), admin(admin) { User(String username, String password, bool admin)
: username(username)
, password(password)
, admin(admin) {
} }
}; };
@@ -37,9 +40,13 @@ class Authentication {
boolean authenticated; boolean authenticated;
public: public:
Authentication(User& user) : user(new User(user)), authenticated(true) { Authentication(User & user)
: user(new User(user))
, authenticated(true) {
} }
Authentication() : user(nullptr), authenticated(false) { Authentication()
: user(nullptr)
, authenticated(false) {
} }
~Authentication() { ~Authentication() {
delete (user); delete (user);
@@ -89,14 +96,12 @@ class SecurityManager {
/** /**
* Wrap the provided request to provide validation against an AuthenticationPredicate. * Wrap the provided request to provide validation against an AuthenticationPredicate.
*/ */
virtual ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, virtual ArRequestHandlerFunction wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) = 0;
AuthenticationPredicate predicate) = 0;
/** /**
* Wrap the provided json request callback to provide validation against an AuthenticationPredicate. * Wrap the provided json request callback to provide validation against an AuthenticationPredicate.
*/ */
virtual ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction onRequest, virtual ArJsonRequestHandlerFunction wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) = 0;
AuthenticationPredicate predicate) = 0;
}; };
#endif // end SecurityManager_h #endif // end SecurityManager_h

View File

@@ -2,10 +2,10 @@
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(FT_SECURITY)
SecuritySettingsService::SecuritySettingsService(AsyncWebServer* server, FS* fs) : SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs)
_httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this), : _httpEndpoint(SecuritySettings::read, SecuritySettings::update, this, server, SECURITY_SETTINGS_PATH, this)
_fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE), , _fsPersistence(SecuritySettings::read, SecuritySettings::update, this, fs, SECURITY_SETTINGS_FILE)
_jwtHandler(FACTORY_JWT_SECRET) { , _jwtHandler(FACTORY_JWT_SECRET) {
addUpdateHandler([&](const String & originId) { configureJWTHandler(); }, false); addUpdateHandler([&](const String & originId) { configureJWTHandler(); }, false);
} }
@@ -85,8 +85,7 @@ ArRequestFilterFunction SecuritySettingsService::filterRequest(AuthenticationPre
}; };
} }
ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) {
return [this, onRequest, predicate](AsyncWebServerRequest * request) { return [this, onRequest, predicate](AsyncWebServerRequest * request) {
Authentication authentication = authenticateRequest(request); Authentication authentication = authenticateRequest(request);
if (!predicate(authentication)) { if (!predicate(authentication)) {
@@ -97,8 +96,7 @@ ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFu
}; };
} }
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) {
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) { return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) {
Authentication authentication = authenticateRequest(request); Authentication authentication = authenticateRequest(request);
if (!predicate(authentication)) { if (!predicate(authentication)) {
@@ -113,7 +111,8 @@ ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequest
User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true); User ADMIN_USER = User(FACTORY_ADMIN_USERNAME, FACTORY_ADMIN_PASSWORD, true);
SecuritySettingsService::SecuritySettingsService(AsyncWebServer* server, FS* fs) : SecurityManager() { SecuritySettingsService::SecuritySettingsService(AsyncWebServer * server, FS * fs)
: SecurityManager() {
} }
SecuritySettingsService::~SecuritySettingsService() { SecuritySettingsService::~SecuritySettingsService() {
} }
@@ -128,13 +127,11 @@ Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerReques
} }
// Return the function unwrapped // Return the function unwrapped
ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) {
return onRequest; return onRequest;
} }
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
AuthenticationPredicate predicate) {
return onRequest; return onRequest;
} }

View File

@@ -35,8 +35,10 @@ typedef struct StateUpdateHandlerInfo {
update_handler_id_t _id; update_handler_id_t _id;
StateUpdateCallback _cb; StateUpdateCallback _cb;
bool _allowRemove; bool _allowRemove;
StateUpdateHandlerInfo(StateUpdateCallback cb, bool allowRemove) : StateUpdateHandlerInfo(StateUpdateCallback cb, bool allowRemove)
_id(++currentUpdatedHandlerId), _cb(cb), _allowRemove(allowRemove){}; : _id(++currentUpdatedHandlerId)
, _cb(cb)
, _allowRemove(allowRemove){};
} StateUpdateHandlerInfo_t; } StateUpdateHandlerInfo_t;
template <class T> template <class T>
@@ -44,11 +46,13 @@ class StatefulService {
public: public:
template <typename... Args> template <typename... Args>
#ifdef ESP32 #ifdef ESP32
StatefulService(Args&&... args) : StatefulService(Args &&... args)
_state(std::forward<Args>(args)...), _accessMutex(xSemaphoreCreateRecursiveMutex()) { : _state(std::forward<Args>(args)...)
, _accessMutex(xSemaphoreCreateRecursiveMutex()) {
} }
#else #else
StatefulService(Args&&... args) : _state(std::forward<Args>(args)...) { StatefulService(Args &&... args)
: _state(std::forward<Args>(args)...) {
} }
#endif #endif

View File

@@ -1,7 +1,7 @@
#include <UploadFirmwareService.h> #include <UploadFirmwareService.h>
UploadFirmwareService::UploadFirmwareService(AsyncWebServer* server, SecurityManager* securityManager) : UploadFirmwareService::UploadFirmwareService(AsyncWebServer * server, SecurityManager * securityManager)
_securityManager(securityManager) { : _securityManager(securityManager) {
server->on(UPLOAD_FIRMWARE_PATH, server->on(UPLOAD_FIRMWARE_PATH,
HTTP_POST, HTTP_POST,
std::bind(&UploadFirmwareService::uploadComplete, this, std::placeholders::_1), std::bind(&UploadFirmwareService::uploadComplete, this, std::placeholders::_1),
@@ -18,12 +18,7 @@ UploadFirmwareService::UploadFirmwareService(AsyncWebServer* server, SecurityMan
#endif #endif
} }
void UploadFirmwareService::handleUpload(AsyncWebServerRequest* request, void UploadFirmwareService::handleUpload(AsyncWebServerRequest * request, const String & filename, size_t index, uint8_t * data, size_t len, bool final) {
const String& filename,
size_t index,
uint8_t* data,
size_t len,
bool final) {
if (!index) { if (!index) {
Authentication authentication = _securityManager->authenticateRequest(request); Authentication authentication = _securityManager->authenticateRequest(request);
if (AuthenticationPredicates::IS_ADMIN(authentication)) { if (AuthenticationPredicates::IS_ADMIN(authentication)) {

View File

@@ -24,12 +24,7 @@ class UploadFirmwareService {
private: private:
SecurityManager * _securityManager; SecurityManager * _securityManager;
void handleUpload(AsyncWebServerRequest* request, void handleUpload(AsyncWebServerRequest * request, const String & filename, size_t index, uint8_t * data, size_t len, bool final);
const String& filename,
size_t index,
uint8_t* data,
size_t len,
bool final);
void uploadComplete(AsyncWebServerRequest * request); void uploadComplete(AsyncWebServerRequest * request);
void handleError(AsyncWebServerRequest * request, int code); void handleError(AsyncWebServerRequest * request, int code);
static void handleEarlyDisconnect(); static void handleEarlyDisconnect();

View File

@@ -20,11 +20,14 @@ class WebSocketConnector {
WebSocketConnector(StatefulService<T> * statefulService, WebSocketConnector(StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate, AuthenticationPredicate authenticationPredicate,
size_t bufferSize) : size_t bufferSize)
_statefulService(statefulService), _server(server), _webSocket(webSocketPath), _bufferSize(bufferSize) { : _statefulService(statefulService)
, _server(server)
, _webSocket(webSocketPath)
, _bufferSize(bufferSize) {
_webSocket.setFilter(securityManager->filterRequest(authenticationPredicate)); _webSocket.setFilter(securityManager->filterRequest(authenticationPredicate));
_webSocket.onEvent(std::bind(&WebSocketConnector::onWSEvent, _webSocket.onEvent(std::bind(&WebSocketConnector::onWSEvent,
this, this,
@@ -38,11 +41,11 @@ class WebSocketConnector {
_server->on(webSocketPath, HTTP_GET, std::bind(&WebSocketConnector::forbidden, this, std::placeholders::_1)); _server->on(webSocketPath, HTTP_GET, std::bind(&WebSocketConnector::forbidden, this, std::placeholders::_1));
} }
WebSocketConnector(StatefulService<T>* statefulService, WebSocketConnector(StatefulService<T> * statefulService, AsyncWebServer * server, const char * webSocketPath, size_t bufferSize)
AsyncWebServer* server, : _statefulService(statefulService)
char const* webSocketPath, , _server(server)
size_t bufferSize) : , _webSocket(webSocketPath)
_statefulService(statefulService), _server(server), _webSocket(webSocketPath), _bufferSize(bufferSize) { , _bufferSize(bufferSize) {
_webSocket.onEvent(std::bind(&WebSocketConnector::onWSEvent, _webSocket.onEvent(std::bind(&WebSocketConnector::onWSEvent,
this, this,
std::placeholders::_1, std::placeholders::_1,
@@ -54,12 +57,7 @@ class WebSocketConnector {
_server->addHandler(&_webSocket); _server->addHandler(&_webSocket);
} }
virtual void onWSEvent(AsyncWebSocket* server, virtual void onWSEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t * data, size_t len) = 0;
AsyncWebSocketClient* client,
AwsEventType type,
void* arg,
uint8_t* data,
size_t len) = 0;
String clientId(AsyncWebSocketClient * client) { String clientId(AsyncWebSocketClient * client) {
return WEB_SOCKET_ORIGIN_CLIENT_ID_PREFIX + String(client->id()); return WEB_SOCKET_ORIGIN_CLIENT_ID_PREFIX + String(client->id());
@@ -77,38 +75,27 @@ class WebSocketTx : virtual public WebSocketConnector<T> {
WebSocketTx(JsonStateReader<T> stateReader, WebSocketTx(JsonStateReader<T> stateReader,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, : WebSocketConnector<T>(statefulService, server, webSocketPath, securityManager, authenticationPredicate, bufferSize)
server, , _stateReader(stateReader) {
webSocketPath, WebSocketConnector<T>::_statefulService->addUpdateHandler([&](const String & originId) { transmitData(nullptr, originId); }, false);
securityManager,
authenticationPredicate,
bufferSize),
_stateReader(stateReader) {
WebSocketConnector<T>::_statefulService->addUpdateHandler(
[&](const String& originId) { transmitData(nullptr, originId); }, false);
} }
WebSocketTx(JsonStateReader<T> stateReader, WebSocketTx(JsonStateReader<T> stateReader,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize), _stateReader(stateReader) { : WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize)
WebSocketConnector<T>::_statefulService->addUpdateHandler( , _stateReader(stateReader) {
[&](const String& originId) { transmitData(nullptr, originId); }, false); WebSocketConnector<T>::_statefulService->addUpdateHandler([&](const String & originId) { transmitData(nullptr, originId); }, false);
} }
protected: protected:
virtual void onWSEvent(AsyncWebSocket* server, virtual void onWSEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t * data, size_t len) {
AsyncWebSocketClient* client,
AwsEventType type,
void* arg,
uint8_t* data,
size_t len) {
if (type == WS_EVT_CONNECT) { if (type == WS_EVT_CONNECT) {
// when a client connects, we transmit it's id and the current payload // when a client connects, we transmit it's id and the current payload
transmitId(client); transmitId(client);
@@ -166,34 +153,25 @@ class WebSocketRx : virtual public WebSocketConnector<T> {
WebSocketRx(JsonStateUpdater<T> stateUpdater, WebSocketRx(JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, : WebSocketConnector<T>(statefulService, server, webSocketPath, securityManager, authenticationPredicate, bufferSize)
server, , _stateUpdater(stateUpdater) {
webSocketPath,
securityManager,
authenticationPredicate,
bufferSize),
_stateUpdater(stateUpdater) {
} }
WebSocketRx(JsonStateUpdater<T> stateUpdater, WebSocketRx(JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize), _stateUpdater(stateUpdater) { : WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize)
, _stateUpdater(stateUpdater) {
} }
protected: protected:
virtual void onWSEvent(AsyncWebSocket* server, virtual void onWSEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t * data, size_t len) {
AsyncWebSocketClient* client,
AwsEventType type,
void* arg,
uint8_t* data,
size_t len) {
if (type == WS_EVT_DATA) { if (type == WS_EVT_DATA) {
AwsFrameInfo * info = (AwsFrameInfo *)arg; AwsFrameInfo * info = (AwsFrameInfo *)arg;
if (info->final && info->index == 0 && info->len == len) { if (info->final && info->index == 0 && info->len == len) {
@@ -202,8 +180,7 @@ class WebSocketRx : virtual public WebSocketConnector<T> {
DeserializationError error = deserializeJson(jsonDocument, (char *)data); DeserializationError error = deserializeJson(jsonDocument, (char *)data);
if (!error && jsonDocument.is<JsonObject>()) { if (!error && jsonDocument.is<JsonObject>()) {
JsonObject jsonObject = jsonDocument.as<JsonObject>(); JsonObject jsonObject = jsonDocument.as<JsonObject>();
WebSocketConnector<T>::_statefulService->update( WebSocketConnector<T>::_statefulService->update(jsonObject, _stateUpdater, WebSocketConnector<T>::clientId(client));
jsonObject, _stateUpdater, WebSocketConnector<T>::clientId(client));
} }
} }
} }
@@ -221,50 +198,28 @@ class WebSocketTxRx : public WebSocketTx<T>, public WebSocketRx<T> {
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
SecurityManager * securityManager, SecurityManager * securityManager,
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN, AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, : WebSocketConnector<T>(statefulService, server, webSocketPath, securityManager, authenticationPredicate, bufferSize)
server, , WebSocketTx<T>(stateReader, statefulService, server, webSocketPath, securityManager, authenticationPredicate, bufferSize)
webSocketPath, , WebSocketRx<T>(stateUpdater, statefulService, server, webSocketPath, securityManager, authenticationPredicate, bufferSize) {
securityManager,
authenticationPredicate,
bufferSize),
WebSocketTx<T>(stateReader,
statefulService,
server,
webSocketPath,
securityManager,
authenticationPredicate,
bufferSize),
WebSocketRx<T>(stateUpdater,
statefulService,
server,
webSocketPath,
securityManager,
authenticationPredicate,
bufferSize) {
} }
WebSocketTxRx(JsonStateReader<T> stateReader, WebSocketTxRx(JsonStateReader<T> stateReader,
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
AsyncWebServer * server, AsyncWebServer * server,
char const* webSocketPath, const char * webSocketPath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) : size_t bufferSize = DEFAULT_BUFFER_SIZE)
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize), : WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize)
WebSocketTx<T>(stateReader, statefulService, server, webSocketPath, bufferSize), , WebSocketTx<T>(stateReader, statefulService, server, webSocketPath, bufferSize)
WebSocketRx<T>(stateUpdater, statefulService, server, webSocketPath, bufferSize) { , WebSocketRx<T>(stateUpdater, statefulService, server, webSocketPath, bufferSize) {
} }
protected: protected:
void onWSEvent(AsyncWebSocket* server, void onWSEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t * data, size_t len) {
AsyncWebSocketClient* client,
AwsEventType type,
void* arg,
uint8_t* data,
size_t len) {
WebSocketRx<T>::onWSEvent(server, client, type, arg, data, len); WebSocketRx<T>::onWSEvent(server, client, type, arg, data, len);
WebSocketTx<T>::onWSEvent(server, client, type, arg, data, len); WebSocketTx<T>::onWSEvent(server, client, type, arg, data, len);
} }

View File

@@ -3,12 +3,10 @@
WiFiScanner::WiFiScanner(AsyncWebServer * server, SecurityManager * securityManager) { WiFiScanner::WiFiScanner(AsyncWebServer * server, SecurityManager * securityManager) {
server->on(SCAN_NETWORKS_SERVICE_PATH, server->on(SCAN_NETWORKS_SERVICE_PATH,
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&WiFiScanner::scanNetworks, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&WiFiScanner::scanNetworks, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN));
AuthenticationPredicates::IS_ADMIN));
server->on(LIST_NETWORKS_SERVICE_PATH, server->on(LIST_NETWORKS_SERVICE_PATH,
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&WiFiScanner::listNetworks, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&WiFiScanner::listNetworks, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN));
AuthenticationPredicates::IS_ADMIN));
}; };
void WiFiScanner::scanNetworks(AsyncWebServerRequest * request) { void WiFiScanner::scanNetworks(AsyncWebServerRequest * request) {

View File

@@ -53,7 +53,6 @@ class WiFiSettings {
} }
static StateUpdateResult update(JsonObject & root, WiFiSettings & settings) { static StateUpdateResult update(JsonObject & root, WiFiSettings & settings) {
settings.ssid = root["ssid"] | FACTORY_WIFI_SSID; settings.ssid = root["ssid"] | FACTORY_WIFI_SSID;
settings.password = root["password"] | FACTORY_WIFI_PASSWORD; settings.password = root["password"] | FACTORY_WIFI_PASSWORD;
settings.hostname = root["hostname"] | FACTORY_WIFI_HOSTNAME; settings.hostname = root["hostname"] | FACTORY_WIFI_HOSTNAME;
@@ -75,8 +74,7 @@ class WiFiSettings {
// Turning off static ip config if we don't meet the minimum requirements // Turning off static ip config if we don't meet the minimum requirements
// of ipAddress, gateway and subnet. This may change to static ip only // of ipAddress, gateway and subnet. This may change to static ip only
// as sensible defaults can be assumed for gateway and subnet // as sensible defaults can be assumed for gateway and subnet
if (settings.staticIPConfig && if (settings.staticIPConfig && (settings.localIP == INADDR_NONE || settings.gatewayIP == INADDR_NONE || settings.subnetMask == INADDR_NONE)) {
(settings.localIP == INADDR_NONE || settings.gatewayIP == INADDR_NONE || settings.subnetMask == INADDR_NONE)) {
settings.staticIPConfig = false; settings.staticIPConfig = false;
} }
return StateUpdateResult::CHANGED; return StateUpdateResult::CHANGED;

View File

@@ -3,8 +3,7 @@
WiFiStatus::WiFiStatus(AsyncWebServer * server, SecurityManager * securityManager) { WiFiStatus::WiFiStatus(AsyncWebServer * server, SecurityManager * securityManager) {
server->on(WIFI_STATUS_SERVICE_PATH, server->on(WIFI_STATUS_SERVICE_PATH,
HTTP_GET, HTTP_GET,
securityManager->wrapRequest(std::bind(&WiFiStatus::wifiStatus, this, std::placeholders::_1), securityManager->wrapRequest(std::bind(&WiFiStatus::wifiStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED));
AuthenticationPredicates::IS_AUTHENTICATED));
#ifdef ESP32 #ifdef ESP32
WiFi.onEvent(onStationModeConnected, WiFiEvent_t::SYSTEM_EVENT_STA_CONNECTED); WiFi.onEvent(onStationModeConnected, WiFiEvent_t::SYSTEM_EVENT_STA_CONNECTED);
WiFi.onEvent(onStationModeDisconnected, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED); WiFi.onEvent(onStationModeDisconnected, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);

View File

@@ -11,7 +11,7 @@ class FSPersistence {
JsonStateUpdater<T> stateUpdater, JsonStateUpdater<T> stateUpdater,
StatefulService<T> * statefulService, StatefulService<T> * statefulService,
FS * fs, FS * fs,
char const * filePath, const char * filePath,
size_t bufferSize = DEFAULT_BUFFER_SIZE) size_t bufferSize = DEFAULT_BUFFER_SIZE)
: _stateReader(stateReader) : _stateReader(stateReader)
, _stateUpdater(stateUpdater) , _stateUpdater(stateUpdater)
@@ -52,7 +52,7 @@ class FSPersistence {
JsonStateUpdater<T> _stateUpdater; JsonStateUpdater<T> _stateUpdater;
StatefulService<T> * _statefulService; StatefulService<T> * _statefulService;
FS * _fs; FS * _fs;
char const * _filePath; const char * _filePath;
size_t _bufferSize; size_t _bufferSize;
update_handler_id_t _updateHandlerId; update_handler_id_t _updateHandlerId;