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