diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-27 11:58:17 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-27 11:58:17 +0800 |
| commit | 5e4eb6bef2a611ef4f39dbf577c550317b965e7f (patch) | |
| tree | 2b9851c2c241f10215ec013f28bad456a6622cfc /lock/bend.c | |
| parent | f4cb00a6ea7d1a9b2e559de2981e700ce7b97688 (diff) | |
| download | smart-home-5e4eb6bef2a611ef4f39dbf577c550317b965e7f.tar.gz | |
Control servo remotely without encryption.
Diffstat (limited to 'lock/bend.c')
| -rw-r--r-- | lock/bend.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/lock/bend.c b/lock/bend.c index 896c0b3..8436770 100644 --- a/lock/bend.c +++ b/lock/bend.c @@ -130,36 +130,16 @@ int main(void) uart_write_line("reset..."); for (;;) { - if (!rxd) - _delay_ms(500); - if (rxd) { n = radio_recv(buf, WDLEN); buf[n] = '\0'; + rxd = 0; uart_write("recv: "); uart_write(buf); - itoa(n, s, 10); - uart_write(s); - uart_write_line(" bytes"); - if (!sync) { - xor(KEY, buf, msg, WDLEN); - if (strncmp(msg, SYN, WDLEN) == 0) { - keygen(key, WDLEN + 1); - xor(KEY, key, buf, WDLEN); - sync = radio_sendto(txaddr, buf, WDLEN); - } else { - uart_write_line("not syn"); - } - } else { - sync = 0; - xor(key, buf, msg, WDLEN); - if (strncmp(msg, LOCK, WDLEN) == 0) - lock(); - else if (strncmp(msg, UNLOCK, WDLEN) == 0) - unlock(); - keydel(buf, WDLEN); - } - rxd = 0; + if (strncmp(buf, LOCK, WDLEN) == 0) + lock(); + else if (strncmp(buf, UNLOCK, WDLEN) == 0) + unlock(); } } return 0; |
