transmit IR raw data to MQTT

#9
This commit is contained in:
1technophile committed 2017-06-02 23:18:00 +02:00
1 parent 9e9a2cd191
commit 9481bcd868
2 files changed
+9

No files matched your search

+1
View File
@@ -105,6 +105,7 @@ RF supported protocols
#define subjectMQTTtoIR "home/commands/MQTTtoIR" #define subjectMQTTtoIR "home/commands/MQTTtoIR"
#define subjectIRtoMQTTprotocol "home/IRtoMQTT/protocol" #define subjectIRtoMQTTprotocol "home/IRtoMQTT/protocol"
#define subjectIRtoMQTTbits "home/IRtoMQTT/bits" #define subjectIRtoMQTTbits "home/IRtoMQTT/bits"
#define subjectIRtoMQTTRaw "home/IRtoMQTT/raw"
// subject monitored to listen traffic processed by other gateways to store data and avoid ntuple // subject monitored to listen traffic processed by other gateways to store data and avoid ntuple
#define subjectMultiGTWIR "+/IRtoMQTT" #define subjectMultiGTWIR "+/IRtoMQTT"
#define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits #define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits
+8
View File
@@ -58,6 +58,13 @@ boolean IRtoMQTT(){
MQTTvalue = results.value; MQTTvalue = results.value;
MQTTprotocol = String(results.decode_type); MQTTprotocol = String(results.decode_type);
MQTTbits = String(results.bits); MQTTbits = String(results.bits);
String rawCode = "";
// Dump data
for (int i = 1; i < results.rawlen; i++) {
rawCode = rawCode + (results.rawbuf[i] * USECPERTICK);
if ( i < results.rawlen-1 ) rawCode = rawCode + ","; // ',' not needed on last one
}
trc(rawCode);
irrecv.resume(); // Receive the next value irrecv.resume(); // Receive the next value
if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol
trc(F("--------------don't publish the received code unknown protocol--------------")); trc(F("--------------don't publish the received code unknown protocol--------------"));
@@ -65,6 +72,7 @@ boolean IRtoMQTT(){
trc(F("Sending adv data to MQTT")); trc(F("Sending adv data to MQTT"));
client.publish(subjectIRtoMQTTprotocol,(char *)MQTTprotocol.c_str()); client.publish(subjectIRtoMQTTprotocol,(char *)MQTTprotocol.c_str());
client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str()); client.publish(subjectIRtoMQTTbits,(char *)MQTTbits.c_str());
client.publish(subjectIRtoMQTTRaw,(char *)rawCode.c_str());
trc(F("Sending IR to MQTT")); trc(F("Sending IR to MQTT"));
String value = String(MQTTvalue); String value = String(MQTTvalue);
trc(value); trc(value);