From 224541bac6f544d6268a23c1dfb57de5f05d3245 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Thu, 8 May 2025 07:12:02 +0800 Subject: Check cap before enrolling. --- main.c | 3 +-- r503.c | 10 ++++++++-- r503.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 66f419e..734f687 100644 --- a/main.c +++ b/main.c @@ -44,8 +44,7 @@ int main(void) fpm_get_cfg(&cfg); if (fpm_get_count() == 0) { - // todo: check against capacity in prod - if (fpm_enroll(1)) { + if (fpm_enroll()) { fpm_led_on(BLUE); _delay_ms(500); fpm_led_off(); diff --git a/r503.c b/r503.c index 3320a1c..6a10f10 100644 --- a/r503.c +++ b/r503.c @@ -263,11 +263,17 @@ uint16_t fpm_get_count(void) return count; } -uint8_t fpm_enroll(uint16_t id) +uint8_t fpm_enroll(void) { - uint16_t n; + struct fpm_cfg cfg; + uint16_t n, id; uint8_t buf[MAXPDLEN]; + fpm_get_cfg(&cfg); + id = fpm_get_count(); + if (n == cfg.cap) + return 0; + if (!scan()) return 0; diff --git a/r503.h b/r503.h index 936e4f6..c4f6010 100644 --- a/r503.h +++ b/r503.h @@ -31,7 +31,7 @@ void fpm_led_off(void); uint16_t fpm_get_count(void); -uint8_t fpm_enroll(uint16_t id); +uint8_t fpm_enroll(void); uint8_t fpm_match(void); -- cgit v1.2.3