diff --git a/ZgatewayIR.ino b/ZgatewayIR.ino index 936b54b..cda48e6 100644 --- a/ZgatewayIR.ino +++ b/ZgatewayIR.ino @@ -72,7 +72,20 @@ boolean IRtoMQTT(){ if ( i < results.rawlen-1 ) rawCode = rawCode + ","; // ',' not needed on last one } trc(rawCode); + // if needed we directly resend the raw code + if (RawDirectForward){ + uint16_t rawsend[results.rawlen]; + for (uint16_t i = 1; i < results.rawlen; i++) { + #ifdef ESP8266 + if (i % 100 == 0) yield(); // Preemptive yield every 100th entry to feed the WDT. + #endif + rawsend[i] = results.rawbuf[i]; + } + irsend.sendRaw(rawsend, results.rawlen, RawFrequency); + trc(F("raw signal redirected")); + } irrecv.resume(); // Receive the next value + if (pubIRunknownPrtcl == false && MQTTprotocol == "-1"){ // don't publish unknown IR protocol trc(F("--no pub. unknown protocol--")); } else if (!isAduplicate(MQTTvalue) && MQTTvalue!=0) {// conditions to avoid duplications of RF -->MQTT @@ -156,7 +169,7 @@ void MQTTtoIR(char * topicOri, char * datacallback) { j++; } } - irsend.sendRaw(Raw, j, 38); // frequency hardcoded as a first approach for test purposes + irsend.sendRaw(Raw, j, RawFrequency); signalSent = true; } #endif diff --git a/config_IR.h b/config_IR.h index 772daad..bdd378d 100644 --- a/config_IR.h +++ b/config_IR.h @@ -37,6 +37,8 @@ #define IRbitsKey "IRBITS_" // bits will be defined if a subject contains IRbitsKey followed by a value of 2 digits #define IRRptKey "RPT_" // repeats will be defined if a subject contains IRRptKey followed by a value of 1 digit #define repeatIRwMQTT false // do we repeat a received signal by using mqtt +#define RawDirectForward false // direct repeat of IR signal with raw data +#define RawFrequency 38 // raw frequency sending #define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) #define PanasonicAddress 0x4004 // Panasonic address (Pre data)