Files
Arduino/ESP32/ESP32-HomeSpan/DEV_RELAY.h
2024-10-03 10:05:46 +02:00

20 lines
395 B
C

struct DEV_RELAY : Service::Switch { // deriving from the HomeSpan Switch service
int relayPin;
SpanCharacteristic *power;
DEV_RELAY(int relayPin) : Service::Switch() {
power = new Characteristic::On();
this->relayPin = relayPin;
pinMode(relayPin, OUTPUT);
}
boolean update() {
digitalWrite(relayPin, power->getNewVal());
return(true);
}
};