🧼 Removes the need to pass reference to fs

This commit is contained in:
Rune Harlyk
2024-11-12 11:54:10 +01:00
parent 316b1a52cb
commit 426b4a1332
8 changed files with 8 additions and 11 deletions
@@ -24,7 +24,7 @@ class CameraSettingsService : public StatefulService<CameraSettings> {
CameraSettingsService()
: endpoint(CameraSettings::read, CameraSettings::update, this),
_eventEndpoint(CameraSettings::read, CameraSettings::update, this, EVENT_CAMERA_SETTINGS),
_persistence(CameraSettings::read, CameraSettings::update, this, &ESPFS, CAMERA_SETTINGS_FILE) {
_persistence(CameraSettings::read, CameraSettings::update, this, CAMERA_SETTINGS_FILE) {
addUpdateHandler([&](const String &originId) { updateCamera(); }, false);
}
+2 -3
View File
@@ -24,11 +24,10 @@ template <class T>
class FSPersistence {
public:
FSPersistence(JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> *statefulService,
FS *fs, const char *filePath)
const char *filePath)
: _stateReader(stateReader),
_stateUpdater(stateUpdater),
_statefulService(statefulService),
_fs(fs),
_filePath(filePath),
_updateHandlerId(0) {
enableUpdateHandler();
@@ -98,7 +97,7 @@ class FSPersistence {
JsonStateReader<T> _stateReader;
JsonStateUpdater<T> _stateUpdater;
StatefulService<T> *_statefulService;
FS *_fs;
FS *_fs {&ESPFS};
const char *_filePath;
size_t _bufferSize;
update_handler_id_t _updateHandlerId;
-1
View File
@@ -2,7 +2,6 @@
#define LEDService_h
#include <FastLED.h>
#include <task_manager.h>
#ifndef WS2812_PIN
#define WS2812_PIN 12
+1 -2
View File
@@ -68,8 +68,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
#if FT_ENABLED(USE_BMP)
_bmp(10085),
#endif
_persistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, &ESPFS,
DEVICE_CONFIG_FILE) {
_persistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, DEVICE_CONFIG_FILE) {
_accessMutex = xSemaphoreCreateMutex();
addUpdateHandler([&](const String &originId) { updatePins(); }, false);
};
+1 -1
View File
@@ -20,7 +20,7 @@ class ServoController : public StatefulService<ServoSettings> {
ServoController(Peripherals *peripherals)
: _peripherals(peripherals),
endpoint(ServoSettings::read, ServoSettings::update, this),
_persistence(ServoSettings::read, ServoSettings::update, this, &ESPFS, SERVO_SETTINGS_FILE) {}
_persistence(ServoSettings::read, ServoSettings::update, this, SERVO_SETTINGS_FILE) {}
void begin() {
socket.onEvent(EVENT_SERVO_CONFIGURATION_SETTINGS,
+1 -1
View File
@@ -4,7 +4,7 @@ static const char *TAG = "APService";
APService::APService()
: endpoint(APSettings::read, APSettings::update, this),
_persistence(APSettings::read, APSettings::update, this, &ESPFS, NTP_SETTINGS_FILE) {
_persistence(APSettings::read, APSettings::update, this, NTP_SETTINGS_FILE) {
addUpdateHandler([&](const String &originId) { reconfigureAP(); }, false);
}
+1 -1
View File
@@ -4,7 +4,7 @@ static const char *TAG = "NPT Service";
NTPService::NTPService()
: endpoint(NTPSettings::read, NTPSettings::update, this),
_persistence(NTPSettings::read, NTPSettings::update, this, &ESPFS, NTP_SETTINGS_FILE) {
_persistence(NTPSettings::read, NTPSettings::update, this, NTP_SETTINGS_FILE) {
addUpdateHandler([&](const String &originId) { configureNTP(); }, false);
}
+1 -1
View File
@@ -2,7 +2,7 @@
WiFiService::WiFiService()
: endpoint(WiFiSettings::read, WiFiSettings::update, this),
_persistence(WiFiSettings::read, WiFiSettings::update, this, &ESPFS, WIFI_SETTINGS_FILE) {
_persistence(WiFiSettings::read, WiFiSettings::update, this, WIFI_SETTINGS_FILE) {
addUpdateHandler([&](const String &originId) { reconfigureWiFiConnection(); }, false);
}