From 5c17df704b8e0228a0647b6110297bb38b40ef1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 25 Aug 2017 23:35:14 +0200 Subject: [PATCH] Allow to specify via MQTT the number of times to transmit an RF code in Sonoff RFBridge --- code/espurna/rfbridge.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/code/espurna/rfbridge.ino b/code/espurna/rfbridge.ino index f4f59f3c..eaaa15b1 100644 --- a/code/espurna/rfbridge.ino +++ b/code/espurna/rfbridge.ino @@ -240,10 +240,17 @@ void _rfbMqttCallback(unsigned int type, const char * topic, const char * payloa } if (t.equals(MQTT_TOPIC_RFOUT)) { + + // The payload may be a code in HEX format ([0-9A-Z]{18}) or + // the code comma the number of times to transmit it. byte message[RF_MESSAGE_SIZE]; - if (_rfbToArray(payload, message)) { - _rfbSend(message, 1); + char * tok = strtok((char *) payload, ","); + if (_rfbToArray(tok, message)) { + tok = strtok(NULL, ","); + byte times = (tok != NULL) ? atoi(tok) : 1; + _rfbSend(message, times); } + } }