|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|