Skip to content

Commit

Permalink
Fix rfbridge OFF button toggling relay (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoseperez committed Dec 1, 2017
1 parent 0ab5321 commit 1758efc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions code/espurna/rfbridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,22 @@ void _rfbDecode() {
DEBUG_MSG_P(PSTR("[RFBRIDGE] Forward message '%s'\n"), buffer);

// Look for the code
unsigned char id, status;
unsigned char id;
unsigned char status = 0;
bool found = false;
for (id=0; id<relayCount(); id++) {
String code_on = rfbRetrieve(id, true);
String code_off = rfbRetrieve(id, false);
if (code_on.length() && code_off.length()) {
if (code_on.endsWith(&buffer[12])) {
found = true;
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 (status == 1) status = 2;
}
}
if (found) break;
Expand Down

0 comments on commit 1758efc

Please sign in to comment.