Skip to content

Commit

Permalink
rfb: allow to use <code>,<times> in rfbON# / rfbOFF#
Browse files Browse the repository at this point in the history
ref. #2423
  • Loading branch information
mcspr committed Jan 28, 2021
1 parent 52a244d commit 19947c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions code/espurna/rfbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,12 @@ void _rfbSendQueued() {

// Check if the payload looks like a HEX code (plus comma, specifying the 'repeats' arg for the queue)
void _rfbSendFromPayload(const char * payload) {
size_t len { strlen(payload) };
if (!len) {
return;
}

decltype(_rfb_repeats) repeats { _rfb_repeats };
size_t len { strlen(payload) };

const char* sep { strchr(payload, ',') };
if (sep) {
Expand All @@ -951,7 +954,6 @@ void _rfbSendFromPayload(const char * payload) {
// We postpone the actual sending until the loop, as we may've been called from MQTT or HTTP API
// RFB_PROVIDER implementation should select the appropriate de-serialization function
_rfbEnqueue(payload, len, repeats);

}

void rfbSend(const char* code) {
Expand Down Expand Up @@ -1166,10 +1168,7 @@ void rfbStatus(unsigned char id, bool status) {
// TODO: Consider having 'origin' of the relay change. Either supply relayStatus with an additional arg,
// or track these statuses directly.
if (!_rfb_relay_status_lock[id]) {
String value = rfbRetrieve(id, status);
if (value.length() && !(value.length() & 1)) {
_rfbSendFromPayload(value.c_str());
}
rfbSend(rfbRetrieve(id, status));
}

_rfb_relay_status_lock[id] = false;
Expand Down

0 comments on commit 19947c1

Please sign in to comment.