26 lines
585 B
C++
26 lines
585 B
C++
#pragma once
|
|
#include "Service.h"
|
|
#include "TaskManager.h"
|
|
#include <ArduinoJson.h>
|
|
|
|
class RelayService : public Service {
|
|
public:
|
|
RelayService(TaskManager& taskMgr, int pin);
|
|
void registerEndpoints(ApiServer& api) override;
|
|
const char* getName() const override { return "Relay"; }
|
|
|
|
void turnOn();
|
|
void turnOff();
|
|
void toggle();
|
|
|
|
private:
|
|
void registerTasks();
|
|
|
|
TaskManager& taskManager;
|
|
int relayPin;
|
|
bool relayOn;
|
|
|
|
void handleStatusRequest(AsyncWebServerRequest* request);
|
|
void handleControlRequest(AsyncWebServerRequest* request);
|
|
};
|