feat: configurable PixelStream
This commit is contained in:
33
examples/pixelstream/PixelStreamService.h
Normal file
33
examples/pixelstream/PixelStreamService.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "spore/Service.h"
|
||||
#include "spore/core/NodeContext.h"
|
||||
#include "PixelStreamController.h"
|
||||
#include <ArduinoJson.h>
|
||||
#include <LittleFS.h>
|
||||
#include "spore/util/Logging.h"
|
||||
|
||||
// PixelStreamConfig is defined in PixelStreamController.h
|
||||
|
||||
class PixelStreamService : public Service {
|
||||
public:
|
||||
PixelStreamService(NodeContext& ctx, ApiServer& apiServer, PixelStreamController* controller);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
void registerTasks(TaskManager& taskManager) override;
|
||||
const char* getName() const override { return "PixelStream"; }
|
||||
|
||||
// Config management
|
||||
PixelStreamConfig loadConfig();
|
||||
bool saveConfig(const PixelStreamConfig& config);
|
||||
void setController(PixelStreamController* ctrl) { controller = ctrl; }
|
||||
|
||||
private:
|
||||
NodeContext& ctx;
|
||||
ApiServer& apiServer;
|
||||
PixelStreamController* controller;
|
||||
|
||||
void handleConfigRequest(AsyncWebServerRequest* request);
|
||||
void handleGetConfigRequest(AsyncWebServerRequest* request);
|
||||
|
||||
static const char* CONFIG_FILE() { return "/pixelstream.json"; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user