Browse Source

Allow to define just ON or OFF codes in rfbridge (#304)

fastled
Xose Pérez 7 years ago
parent
commit
20334d1c97
1 changed files with 23 additions and 19 deletions
  1. +23
    -19
      code/espurna/rfbridge.ino

+ 23
- 19
code/espurna/rfbridge.ino View File

@ -160,32 +160,36 @@ void _rfbDecode() {
unsigned char id;
unsigned char status = 0;
bool found = false;
for (id=0; id<relayCount(); id++) {
String code_on = rfbRetrieve(id, true);
if (code_on.length() && code_on.endsWith(&buffer[12])) {
DEBUG_MSG_P(PSTR("[RFBRIDGE] Match ON code for relay %d\n"), id);
status = 1;
found = true;
}
String code_off = rfbRetrieve(id, false);
if (code_on.length() && code_off.length()) {
if (code_on.endsWith(&buffer[12])) {
DEBUG_MSG_P(PSTR("[RFBRIDGE] Match ON code for relay %d\n"), id);
status = 1;
found = true;
}
if (code_off.endsWith(&buffer[12])) {
DEBUG_MSG_P(PSTR("[RFBRIDGE] Match OFF code for relay %d\n"), id);
if (found) status = 2;
found = true;
}
if (code_off.length() && code_off.endsWith(&buffer[12])) {
DEBUG_MSG_P(PSTR("[RFBRIDGE] Match OFF code for relay %d\n"), id);
if (found) status = 2;
found = true;
}
if (found) break;
}
if (found) {
_rfbin = true;
if (status == 2) {
relayToggle(id);
} else {
relayStatus(id, status == 1);
if (found) {
_rfbin = true;
if (status == 2) {
relayToggle(id);
} else {
relayStatus(id, status == 1);
}
break;
}
}
}
}


Loading…
Cancel
Save