From d0f895105f41c40f9a6a000b3437ad55b1ef9bc6 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Wed, 16 Apr 2025 17:21:15 +0800 Subject: Function to flush RX buffers. --- lock/bend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lock/bend.c') 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(); -- cgit v1.2.3