From 1b7ae688a6d07b02f1a7eee418a51b2699405b8f Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Tue, 12 Nov 2024 11:28:01 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=BC=20Removes=20server=20dependencies?= =?UTF-8?q?=20from=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp | 13 ++----------- esp32/lib/ESP32-sveltekit/MotionService.h | 5 +---- esp32/lib/ESP32-sveltekit/ServoController.h | 6 ++---- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp b/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp index c9885e6..34d34e3 100644 --- a/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp +++ b/esp32/lib/ESP32-sveltekit/ESP32SvelteKit.cpp @@ -17,18 +17,12 @@ ESP32SvelteKit::ESP32SvelteKit(PsychicHttpServer *server) : -#if FT_ENABLED(USE_DOWNLOAD_FIRMWARE) - _downloadFirmwareService(server), -#endif -#if FT_ENABLED(USE_SLEEP) - _sleepService(server), -#endif #if FT_ENABLED(USE_BATTERY) _batteryService(&_peripherals), #endif - _servoController(server, &ESPFS, &_peripherals), + _servoController(&_peripherals), #if FT_ENABLED(USE_MOTION) - _motionService(_server, &_servoController), + _motionService(&_servoController), #endif _server(server) { } @@ -209,9 +203,6 @@ void ESP32SvelteKit::startServices() { #if FT_ENABLED(USE_NTP) _ntpService.begin(); #endif -#if FT_ENABLED(USE_SLEEP) - _sleepService.begin(); -#endif #if FT_ENABLED(USE_BATTERY) _batteryService.begin(); #endif diff --git a/esp32/lib/ESP32-sveltekit/MotionService.h b/esp32/lib/ESP32-sveltekit/MotionService.h index 673d0e9..024c203 100644 --- a/esp32/lib/ESP32-sveltekit/MotionService.h +++ b/esp32/lib/ESP32-sveltekit/MotionService.h @@ -10,7 +10,6 @@ #include #define DEFAULT_STATE false -#define LIGHT_SETTINGS_ENDPOINT_PATH "/api/input" #define ANGLES_EVENT "angles" #define INPUT_EVENT "input" #define POSITION_EVENT "position" @@ -20,8 +19,7 @@ enum class MOTION_STATE { DEACTIVATED, IDLE, CALIBRATION, REST, STAND, CRAWL, WA class MotionService { public: - MotionService(PsychicHttpServer *server, ServoController *servoController) - : _server(server), _servoController(servoController) {} + MotionService(ServoController *servoController) : _servoController(servoController) {} void begin() { socket.onEvent(INPUT_EVENT, [&](JsonObject &root, int originId) { handleInput(root, originId); }); @@ -144,7 +142,6 @@ class MotionService { static void _loopImpl(void *_this) { static_cast(_this)->_loop(); } private: - PsychicHttpServer *_server; ServoController *_servoController; Kinematics kinematics; ControllerCommand command = {0, 0, 0, 0, 0, 0, 0, 0}; diff --git a/esp32/lib/ESP32-sveltekit/ServoController.h b/esp32/lib/ESP32-sveltekit/ServoController.h index 9594df6..0791281 100644 --- a/esp32/lib/ESP32-sveltekit/ServoController.h +++ b/esp32/lib/ESP32-sveltekit/ServoController.h @@ -17,9 +17,8 @@ class ServoController : public StatefulService { public: - ServoController(PsychicHttpServer *server, FS *fs, Peripherals *peripherals) - : _server(server), - _peripherals(peripherals), + ServoController(Peripherals *peripherals) + : _peripherals(peripherals), endpoint(ServoSettings::read, ServoSettings::update, this), _persistence(ServoSettings::read, ServoSettings::update, this, &ESPFS, SERVO_SETTINGS_FILE) {} @@ -83,7 +82,6 @@ class ServoController : public StatefulService { StatefulHttpEndpoint endpoint; private: - PsychicHttpServer *_server; Peripherals *_peripherals; FSPersistence _persistence;