🔥 Removes stateful socket
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#ifndef CameraService_h
|
||||
#define CameraService_h
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <PsychicHttp.h>
|
||||
@@ -7,7 +6,6 @@
|
||||
#include <async_worker.h>
|
||||
|
||||
#include <features.h>
|
||||
#include <template/stateful_socket.h>
|
||||
#include <template/stateful_persistence.h>
|
||||
#include <template/stateful_endpoint.h>
|
||||
|
||||
@@ -23,8 +21,6 @@ namespace Camera {
|
||||
|
||||
#define PART_BOUNDARY "frame"
|
||||
|
||||
#define EVENT_CAMERA_SETTINGS "CameraSettings"
|
||||
|
||||
camera_fb_t *safe_camera_fb_get();
|
||||
sensor_t *safe_sensor_get();
|
||||
void safe_sensor_return();
|
||||
@@ -41,10 +37,7 @@ class CameraService : public StatefulService<CameraSettings> {
|
||||
StatefulHttpEndpoint<CameraSettings> endpoint;
|
||||
|
||||
private:
|
||||
EventEndpoint<CameraSettings> _eventEndpoint;
|
||||
FSPersistence<CameraSettings> _persistence;
|
||||
void updateCamera();
|
||||
};
|
||||
} // namespace Camera
|
||||
|
||||
#endif // end CameraService_h
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#ifndef Peripherals_h
|
||||
#define Peripherals_h
|
||||
#pragma once
|
||||
|
||||
#include <template/stateful_socket.h>
|
||||
#include <template/stateful_persistence.h>
|
||||
#include <template/stateful_service.h>
|
||||
#include <utils/math_utils.h>
|
||||
@@ -22,14 +20,6 @@
|
||||
#include <peripherals/barometer.h>
|
||||
#include <peripherals/gesture.h>
|
||||
|
||||
#define EVENT_CONFIGURATION_SETTINGS "peripheralSettings"
|
||||
|
||||
#define EVENT_I2C_SCAN "i2cScan"
|
||||
|
||||
#define I2C_INTERVAL 250
|
||||
#define MAX_ESP_IMU_SIZE 500
|
||||
#define EVENT_IMU "imu"
|
||||
|
||||
/*
|
||||
* Ultrasonic Sensor Settings
|
||||
*/
|
||||
@@ -78,7 +68,6 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
||||
StatefulHttpEndpoint<PeripheralsConfiguration> endpoint;
|
||||
|
||||
private:
|
||||
EventEndpoint<PeripheralsConfiguration> _eventEndpoint;
|
||||
FSPersistence<PeripheralsConfiguration> _persistence;
|
||||
|
||||
SemaphoreHandle_t _accessMutex;
|
||||
@@ -107,7 +96,4 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
||||
|
||||
std::list<uint8_t> addressList;
|
||||
bool i2c_active = false;
|
||||
unsigned long _updateInterval {I2C_INTERVAL};
|
||||
};
|
||||
|
||||
#endif
|
||||
};
|
||||
@@ -3,15 +3,11 @@
|
||||
#include <ESPmDNS.h>
|
||||
#include <PsychicHttp.h>
|
||||
#include <WiFi.h>
|
||||
#include <communication/websocket_adapter.h>
|
||||
#include <filesystem.h>
|
||||
#include <global.h>
|
||||
#include "esp_timer.h"
|
||||
#include <string>
|
||||
|
||||
#define MAX_ESP_ANALYTICS_SIZE 2024
|
||||
#define EVENT_ANALYTICS "analytics"
|
||||
|
||||
namespace system_service {
|
||||
esp_err_t handleReset(PsychicRequest *request);
|
||||
esp_err_t handleRestart(PsychicRequest *request);
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <PsychicHttp.h>
|
||||
#include <string>
|
||||
|
||||
// #include <communication/websocket_adapter.h>
|
||||
#include <template/stateful_service.h>
|
||||
|
||||
template <class T>
|
||||
class EventEndpoint {
|
||||
public:
|
||||
EventEndpoint(JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> *statefulService,
|
||||
const char *event)
|
||||
: _stateReader(stateReader), _stateUpdater(stateUpdater), _statefulService(statefulService), _event(event) {
|
||||
_statefulService->addUpdateHandler([&](const std::string &originId) { syncState(originId); }, false);
|
||||
}
|
||||
|
||||
void begin() {
|
||||
// socket.onEvent(_event,
|
||||
// std::bind(&EventEndpoint::updateState, this, std::placeholders::_1, std::placeholders::_2));
|
||||
// socket.onSubscribe(_event,
|
||||
// std::bind(&EventEndpoint::syncState, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
private:
|
||||
JsonStateReader<T> _stateReader;
|
||||
JsonStateUpdater<T> _stateUpdater;
|
||||
StatefulService<T> *_statefulService;
|
||||
const char *_event;
|
||||
|
||||
void updateState(JsonVariant &root, int originId) {
|
||||
_statefulService->update(root, _stateUpdater, std::to_string(originId));
|
||||
}
|
||||
|
||||
void syncState(const std::string &originId, bool sync = false) {
|
||||
JsonDocument jsonDocument;
|
||||
JsonVariant root = jsonDocument.to<JsonVariant>();
|
||||
_statefulService->read(root, _stateReader);
|
||||
// socket.emit(_event, root, originId.c_str(), sync);
|
||||
}
|
||||
};
|
||||
@@ -31,13 +31,11 @@ void safe_sensor_return() { xSemaphoreGiveRecursive(cameraMutex); }
|
||||
|
||||
CameraService::CameraService()
|
||||
: endpoint(CameraSettings::read, CameraSettings::update, this),
|
||||
_eventEndpoint(CameraSettings::read, CameraSettings::update, this, EVENT_CAMERA_SETTINGS),
|
||||
_persistence(CameraSettings::read, CameraSettings::update, this, CAMERA_SETTINGS_FILE) {
|
||||
addUpdateHandler([&](const std::string &originId) { updateCamera(); }, false);
|
||||
}
|
||||
|
||||
esp_err_t CameraService::begin() {
|
||||
_eventEndpoint.begin();
|
||||
_persistence.readFromFS();
|
||||
camera_config_t camera_config;
|
||||
camera_config.ledc_channel = LEDC_CHANNEL_0;
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
Peripherals::Peripherals()
|
||||
: endpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this),
|
||||
_eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this,
|
||||
EVENT_CONFIGURATION_SETTINGS),
|
||||
_persistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, DEVICE_CONFIG_FILE) {
|
||||
_accessMutex = xSemaphoreCreateMutex();
|
||||
addUpdateHandler([&](const std::string &originId) { updatePins(); }, false);
|
||||
}
|
||||
|
||||
void Peripherals::begin() {
|
||||
_eventEndpoint.begin();
|
||||
_persistence.readFromFS();
|
||||
|
||||
updatePins();
|
||||
|
||||
Reference in New Issue
Block a user