From 0412461d66888e2a0658bd781379eac30aab3894 Mon Sep 17 00:00:00 2001 From: Florian <1technophile@users.noreply.github.com> Date: Sat, 14 Apr 2018 21:21:01 +0200 Subject: [PATCH] Add acknowledgement to ONOFF gateway #192 Publish to another topic the payload received --- ZactuatorONOFF.ino | 5 +++++ config_ONOFF.h | 1 + 2 files changed, 6 insertions(+) diff --git a/ZactuatorONOFF.ino b/ZactuatorONOFF.ino index bedbf05..b4324c5 100644 --- a/ZactuatorONOFF.ino +++ b/ZactuatorONOFF.ino @@ -48,6 +48,11 @@ void MQTTtoONOFF(char * topicOri, char * datacallback){ trc(F("MQTTtoONOFF")); trc(String(boolSWITCHTYPE)); digitalWrite(ACTUATOR_ONOFF_PIN, boolSWITCHTYPE); + boolean result = client.publish(subjectGTWONOFFtoMQTT, datacallback);// we acknowledge the sending by publishing the value to an acknowledgement topic + if (result){ + trc(F("MQTTtoONOFF ack pub.")); + trc(String(datacallback)); + } } } #endif diff --git a/config_ONOFF.h b/config_ONOFF.h index 3db2cc0..111f1cb 100644 --- a/config_ONOFF.h +++ b/config_ONOFF.h @@ -27,6 +27,7 @@ /*----------------------------USER PARAMETERS-----------------------------*/ /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/ #define subjectMQTTtoONOFF Base_Topic Gateway_Name "/commands/MQTTtoONOFF" +#define subjectGTWONOFFtoMQTT Base_Topic Gateway_Name "/ONOFFtoMQTT" /*-------------------PIN DEFINITIONS----------------------*/ #define ACTUATOR_ONOFF_PIN 4