diff --git a/User_config.h b/User_config.h index 8cf57fb..7821e1b 100644 --- a/User_config.h +++ b/User_config.h @@ -79,6 +79,7 @@ const byte subnet[] = { 255, 255, 255, 0 }; //ip adress #define subjectRFtoMQTTbits "home/433toMQTT/bits" #define subjectRFtoMQTTlength "home/433toMQTT/length" #define RFprotocolKey "433_" // protocol will be defined if a subject contains RFprotocolKey followed by a value of 1 digit +#define repeatRFwMQTT true // do we repeat a received signal by using mqtt /* RF supported protocols 433_1 @@ -103,6 +104,7 @@ RF supported protocols #define subjectMultiGTWIR "+/IRtoMQTT" #define IRbitsKey "BITS_" // 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 true // do we repeat a received signal by using mqtt #define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) diff --git a/ZgatewayIR.ino b/ZgatewayIR.ino index 8f6f2ab..e69b631 100644 --- a/ZgatewayIR.ino +++ b/ZgatewayIR.ino @@ -67,6 +67,10 @@ boolean IRtoMQTT(){ String value = String(MQTTvalue); trc(value); boolean result = client.publish(subjectIRtoMQTT,(char *)value.c_str()); + if (repeatIRwMQTT){ + trc(F("Publishing IR signal so as to make the gateway(s) repeat it")); + client.publish(subjectMQTTtoIR,(char *)value.c_str()); + } return result; } } @@ -224,7 +228,7 @@ void MQTTtoIR(char * topicOri, char * datacallback) { signalSent = true; } #endif - if (signalSent){ + if (signalSent){ // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also boolean result = client.publish(subjectGTWIRtoMQTT, datacallback); if (result){ trc(F("Signal below sent by IR and acknowledgment published")); diff --git a/ZgatewayRF.ino b/ZgatewayRF.ino index 47d9ff2..b2b46a4 100644 --- a/ZgatewayRF.ino +++ b/ZgatewayRF.ino @@ -27,8 +27,7 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT RCSwitch mySwitch = RCSwitch(); -void setupRF() -{ +void setupRF(){ //RF init parameters mySwitch.enableTransmit(RF_EMITTER_PIN); @@ -59,6 +58,10 @@ boolean RFtoMQTT(){ String value = String(MQTTvalue); trc(value); boolean result = client.publish(subjectRFtoMQTT,(char *)value.c_str()); + if (repeatRFwMQTT){ + trc(F("Publishing IR signal so as to make the gateway(s) repeat it")); + client.publish(subjectMQTTtoRF,(char *)value.c_str()); + } return result; } } @@ -106,8 +109,8 @@ void MQTTtoRF(char * topicOri, char * datacallback) { trc(String(valuePLSL)); mySwitch.setProtocol(valuePRT,valuePLSL); mySwitch.send(data, 24); - // Acknowledgement to the GTWRF topic - boolean result = client.publish(subjectGTWRFtoMQTT, datacallback); + // Acknowledgement to the GTWRF topic + boolean result = client.publish(subjectGTWRFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also if (result){ trc(F("Signal below sent by RF and acknowledgment published")); trc(String(data));