diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-05-05 12:33:45 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-05-05 12:33:45 +0800 |
| commit | 909d4c02a49694af662c10477bb2f8cbfbe4290e (patch) | |
| tree | 6b790256608d8ab936534f8afee5cd4c8140c252 | |
| parent | 605423d76e1f73c5a8590163b841c2db523626f7 (diff) | |
| download | smart-home-909d4c02a49694af662c10477bb2f8cbfbe4290e.tar.gz | |
Full system working.
| -rw-r--r-- | lock/Fend.Makefile | 2 | ||||
| -rw-r--r-- | lock/fend.c | 12 | ||||
| -rw-r--r-- | lock/fpm.c | 2 | ||||
| -rw-r--r-- | lock/util.c | 6 |
4 files changed, 14 insertions, 8 deletions
diff --git a/lock/Fend.Makefile b/lock/Fend.Makefile index def0112..9da89c7 100644 --- a/lock/Fend.Makefile +++ b/lock/Fend.Makefile @@ -12,7 +12,7 @@ CFLAGS += -Wall CFLAGS += -mmcu=$(MCU) CFLAGS += -DBAUD=57600 CFLAGS += -DF_CPU=16000000UL -CFLAGS += -DDEBUG=1 +CFLAGS += -DDEBUG=0 CFLAGS += -DFPM_PWD=$(FPM_PWD) CFLAGS += -ffunction-sections -fdata-sections diff --git a/lock/fend.c b/lock/fend.c index 78e42a1..1d1fe12 100644 --- a/lock/fend.c +++ b/lock/fend.c @@ -8,9 +8,9 @@ #include <avr/interrupt.h> #include <util/delay.h> +#include "fpm.h" #include "nrfm.h" #include "util.h" -#include "uart.h" #define LOCK_PIN PD2 #define UNLOCK_PIN PD3 @@ -65,20 +65,26 @@ int main(void) char buf[WDLEN], key[WDLEN]; wdt_off(); - uart_init(); led_init(); + fpm_init(); init_rx(); init_btns(); radio_init(rxaddr); - radio_print_config(); sei(); radio_listen(); for (;;) { if (!sync && (islock || isunlock)) { + if (isunlock) { + if (!fpm_match()) { + isunlock = 0; + continue; + } + } + xor(KEY, SYN, buf, WDLEN); retries = 0; do { @@ -237,7 +237,7 @@ uint8_t fpm_match(void) send(0x01, buf, 1); recv(buf, &n); retries++; - } while (buf[0] != OK && retries < 10); + } while (buf[0] != OK && retries < 50); return buf[0] == OK; } diff --git a/lock/util.c b/lock/util.c index 5a22ef1..ec5369e 100644 --- a/lock/util.c +++ b/lock/util.c @@ -64,11 +64,11 @@ void led_init(void) void led_locked(void) { LED_PORT |= (1 << LOCK_LED); - _delay_ms(70); + _delay_ms(100); LED_PORT &= ~(1 << LOCK_LED); - _delay_ms(70); + _delay_ms(100); LED_PORT |= (1 << LOCK_LED); - _delay_ms(70); + _delay_ms(100); LED_PORT &= ~(1 << LOCK_LED); } |
