🧼 Removes the need to pass reference to fs
This commit is contained in:
@@ -24,7 +24,7 @@ class CameraSettingsService : public StatefulService<CameraSettings> {
|
|||||||
CameraSettingsService()
|
CameraSettingsService()
|
||||||
: endpoint(CameraSettings::read, CameraSettings::update, this),
|
: endpoint(CameraSettings::read, CameraSettings::update, this),
|
||||||
_eventEndpoint(CameraSettings::read, CameraSettings::update, this, EVENT_CAMERA_SETTINGS),
|
_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);
|
addUpdateHandler([&](const String &originId) { updateCamera(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,10 @@ template <class T>
|
|||||||
class FSPersistence {
|
class FSPersistence {
|
||||||
public:
|
public:
|
||||||
FSPersistence(JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> *statefulService,
|
FSPersistence(JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> *statefulService,
|
||||||
FS *fs, const char *filePath)
|
const char *filePath)
|
||||||
: _stateReader(stateReader),
|
: _stateReader(stateReader),
|
||||||
_stateUpdater(stateUpdater),
|
_stateUpdater(stateUpdater),
|
||||||
_statefulService(statefulService),
|
_statefulService(statefulService),
|
||||||
_fs(fs),
|
|
||||||
_filePath(filePath),
|
_filePath(filePath),
|
||||||
_updateHandlerId(0) {
|
_updateHandlerId(0) {
|
||||||
enableUpdateHandler();
|
enableUpdateHandler();
|
||||||
@@ -98,7 +97,7 @@ class FSPersistence {
|
|||||||
JsonStateReader<T> _stateReader;
|
JsonStateReader<T> _stateReader;
|
||||||
JsonStateUpdater<T> _stateUpdater;
|
JsonStateUpdater<T> _stateUpdater;
|
||||||
StatefulService<T> *_statefulService;
|
StatefulService<T> *_statefulService;
|
||||||
FS *_fs;
|
FS *_fs {&ESPFS};
|
||||||
const char *_filePath;
|
const char *_filePath;
|
||||||
size_t _bufferSize;
|
size_t _bufferSize;
|
||||||
update_handler_id_t _updateHandlerId;
|
update_handler_id_t _updateHandlerId;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#define LEDService_h
|
#define LEDService_h
|
||||||
|
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
#include <task_manager.h>
|
|
||||||
|
|
||||||
#ifndef WS2812_PIN
|
#ifndef WS2812_PIN
|
||||||
#define WS2812_PIN 12
|
#define WS2812_PIN 12
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
|||||||
#if FT_ENABLED(USE_BMP)
|
#if FT_ENABLED(USE_BMP)
|
||||||
_bmp(10085),
|
_bmp(10085),
|
||||||
#endif
|
#endif
|
||||||
_persistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, &ESPFS,
|
_persistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, DEVICE_CONFIG_FILE) {
|
||||||
DEVICE_CONFIG_FILE) {
|
|
||||||
_accessMutex = xSemaphoreCreateMutex();
|
_accessMutex = xSemaphoreCreateMutex();
|
||||||
addUpdateHandler([&](const String &originId) { updatePins(); }, false);
|
addUpdateHandler([&](const String &originId) { updatePins(); }, false);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ServoController : public StatefulService<ServoSettings> {
|
|||||||
ServoController(Peripherals *peripherals)
|
ServoController(Peripherals *peripherals)
|
||||||
: _peripherals(peripherals),
|
: _peripherals(peripherals),
|
||||||
endpoint(ServoSettings::read, ServoSettings::update, this),
|
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() {
|
void begin() {
|
||||||
socket.onEvent(EVENT_SERVO_CONFIGURATION_SETTINGS,
|
socket.onEvent(EVENT_SERVO_CONFIGURATION_SETTINGS,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ static const char *TAG = "APService";
|
|||||||
|
|
||||||
APService::APService()
|
APService::APService()
|
||||||
: endpoint(APSettings::read, APSettings::update, this),
|
: 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);
|
addUpdateHandler([&](const String &originId) { reconfigureAP(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ static const char *TAG = "NPT Service";
|
|||||||
|
|
||||||
NTPService::NTPService()
|
NTPService::NTPService()
|
||||||
: endpoint(NTPSettings::read, NTPSettings::update, this),
|
: 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);
|
addUpdateHandler([&](const String &originId) { configureNTP(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
WiFiService::WiFiService()
|
WiFiService::WiFiService()
|
||||||
: endpoint(WiFiSettings::read, WiFiSettings::update, this),
|
: 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);
|
addUpdateHandler([&](const String &originId) { reconfigureWiFiConnection(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user