summaryrefslogtreecommitdiffstats
path: root/lock/bend.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-04-27 11:58:17 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-04-27 11:58:17 +0800
commit5e4eb6bef2a611ef4f39dbf577c550317b965e7f (patch)
tree2b9851c2c241f10215ec013f28bad456a6622cfc /lock/bend.c
parentf4cb00a6ea7d1a9b2e559de2981e700ce7b97688 (diff)
downloadsmart-home-5e4eb6bef2a611ef4f39dbf577c550317b965e7f.tar.gz
Control servo remotely without encryption.
Diffstat (limited to 'lock/bend.c')
-rw-r--r--lock/bend.c30
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;