diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-16 17:21:15 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-16 17:21:15 +0800 |
| commit | d0f895105f41c40f9a6a000b3437ad55b1ef9bc6 (patch) | |
| tree | b26b9cae7fd82a293e99d33b4d04f95140fd0413 /lock/bend.c | |
| parent | 3049eede70c7209459ce2df811802c5d49d0d0c1 (diff) | |
| download | smart-home-d0f895105f41c40f9a6a000b3437ad55b1ef9bc6.tar.gz | |
Function to flush RX buffers.
Diffstat (limited to 'lock/bend.c')
| -rw-r--r-- | lock/bend.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lock/bend.c b/lock/bend.c index f70b6be..a9796d8 100644 --- a/lock/bend.c +++ b/lock/bend.c @@ -37,11 +37,12 @@ static char tab[] = { 'P', 'f', ':', 'B', ']', 'Y', '^', 'F', '%', 'C', 'x' }; -static uint8_t synced = 0; +static uint8_t sync = 0; +static uint16_t tablen = sizeof(tab) / sizeof(tab[0]); + static volatile uint8_t rxd = 0; static volatile uint8_t islock = 0; static volatile uint8_t isunlock = 0; -static uint16_t tablen = sizeof(tab) / sizeof(tab[0]); static inline void keygen(char *buf, uint8_t n) { @@ -133,15 +134,15 @@ int main(void) if (rxd) { n = radio_recv(buf, WDLEN); buf[n] = '\0'; - if (!synced) { + if (!sync) { xor(KEY, buf, msg, WDLEN); if (strncmp(msg, SYN, WDLEN) == 0) { keygen(key, WDLEN + 1); xor(KEY, key, buf, WDLEN); - synced = radio_sendto(txaddr, buf, WDLEN); + sync = radio_sendto(txaddr, buf, WDLEN); } } else { - synced = 0; + sync = 0; xor(key, buf, msg, WDLEN); if (strncmp(msg, LOCK, WDLEN) == 0) lock(); |
