create and subscribe transmission handler

This commit is contained in:
Ronald Schaten 2016-04-20 22:45:47 +02:00
parent e01e13cd9f
commit f595ac746f

View File

@ -16,7 +16,7 @@ class DeviceIrTx : public Device {
private:
byte pin_irtx;
IRsend irsend;
decode_results results;
bool irTxHandler(String message);
HomieNode irTxNode = HomieNode("irtx", "irtx");
};
@ -24,13 +24,18 @@ void DeviceIrTx::deviceSetup() {
pinMode(pin_irtx, OUTPUT);
}
bool DeviceIrTx::irTxHandler(String message) {
irsend.sendSony(0xa90, 12);
return true;
}
void DeviceIrTx::deviceRegister() {
irTxNode.subscribe("irtx", [this](String value) { return irTxHandler(value); });
Homie.registerNode(irTxNode);
}
void DeviceIrTx::deviceLoop() {
irsend.sendSony(0xa90, 12);
delay(500);
return;
}
#endif