Skip to content

Commit

Permalink
🧼 Removes the need to pass reference to fs
Browse files Browse the repository at this point in the history
  • Loading branch information
runeharlyk committed Nov 12, 2024
1 parent 316b1a5 commit 426b4a1
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion esp32/lib/ESP32-sveltekit/CameraSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 2 additions & 3 deletions esp32/lib/ESP32-sveltekit/FSPersistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion esp32/lib/ESP32-sveltekit/LEDService.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define LEDService_h

#include <FastLED.h>
#include <task_manager.h>

#ifndef WS2812_PIN
#define WS2812_PIN 12
Expand Down
3 changes: 1 addition & 2 deletions esp32/lib/ESP32-sveltekit/Peripherals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
2 changes: 1 addition & 1 deletion esp32/lib/ESP32-sveltekit/ServoController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion esp32/lib/ESP32-sveltekit/ap_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion esp32/lib/ESP32-sveltekit/ntp_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion esp32/lib/ESP32-sveltekit/wifi_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 426b4a1

Please sign in to comment.