Browse Source

Allow to specify via MQTT the number of times to transmit an RF code in Sonoff RFBridge

fastled
Xose Pérez 7 years ago
parent
commit
5c17df704b
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      code/espurna/rfbridge.ino

+ 9
- 2
code/espurna/rfbridge.ino View File

@ -240,10 +240,17 @@ void _rfbMqttCallback(unsigned int type, const char * topic, const char * payloa
} }
if (t.equals(MQTT_TOPIC_RFOUT)) { 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]; 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);
} }
} }
} }


Loading…
Cancel
Save