feat: services (#2)
This commit is contained in:
16
include/services/ClusterService.h
Normal file
16
include/services/ClusterService.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "services/Service.h"
|
||||
#include "NodeContext.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class ClusterService : public Service {
|
||||
public:
|
||||
ClusterService(NodeContext& ctx);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
const char* getName() const override { return "Cluster"; }
|
||||
|
||||
private:
|
||||
NodeContext& ctx;
|
||||
|
||||
void handleMembersRequest(AsyncWebServerRequest* request);
|
||||
};
|
||||
22
include/services/NetworkService.h
Normal file
22
include/services/NetworkService.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "services/Service.h"
|
||||
#include "NetworkManager.h"
|
||||
#include "NodeContext.h"
|
||||
|
||||
class NetworkService : public Service {
|
||||
public:
|
||||
NetworkService(NetworkManager& networkManager);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
const char* getName() const override { return "Network"; }
|
||||
|
||||
private:
|
||||
NetworkManager& networkManager;
|
||||
|
||||
// WiFi scanning endpoints
|
||||
void handleWifiScanRequest(AsyncWebServerRequest* request);
|
||||
void handleGetWifiNetworks(AsyncWebServerRequest* request);
|
||||
|
||||
// Network status endpoints
|
||||
void handleNetworkStatus(AsyncWebServerRequest* request);
|
||||
void handleSetWifiConfig(AsyncWebServerRequest* request);
|
||||
};
|
||||
21
include/services/NodeService.h
Normal file
21
include/services/NodeService.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "services/Service.h"
|
||||
#include "NodeContext.h"
|
||||
#include <ArduinoJson.h>
|
||||
#include <Updater.h>
|
||||
|
||||
class NodeService : public Service {
|
||||
public:
|
||||
NodeService(NodeContext& ctx);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
const char* getName() const override { return "Node"; }
|
||||
|
||||
private:
|
||||
NodeContext& ctx;
|
||||
|
||||
void handleStatusRequest(AsyncWebServerRequest* request);
|
||||
void handleUpdateRequest(AsyncWebServerRequest* request);
|
||||
void handleUpdateUpload(AsyncWebServerRequest* request, const String& filename, size_t index, uint8_t* data, size_t len, bool final);
|
||||
void handleRestartRequest(AsyncWebServerRequest* request);
|
||||
void handleCapabilitiesRequest(AsyncWebServerRequest* request);
|
||||
};
|
||||
9
include/services/Service.h
Normal file
9
include/services/Service.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "ApiServer.h"
|
||||
|
||||
class Service {
|
||||
public:
|
||||
virtual ~Service() = default;
|
||||
virtual void registerEndpoints(ApiServer& api) = 0;
|
||||
virtual const char* getName() const = 0;
|
||||
};
|
||||
17
include/services/TaskService.h
Normal file
17
include/services/TaskService.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "services/Service.h"
|
||||
#include "TaskManager.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class TaskService : public Service {
|
||||
public:
|
||||
TaskService(TaskManager& taskManager);
|
||||
void registerEndpoints(ApiServer& api) override;
|
||||
const char* getName() const override { return "Task"; }
|
||||
|
||||
private:
|
||||
TaskManager& taskManager;
|
||||
|
||||
void handleStatusRequest(AsyncWebServerRequest* request);
|
||||
void handleControlRequest(AsyncWebServerRequest* request);
|
||||
};
|
||||
Reference in New Issue
Block a user