diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-05-07 17:21:54 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-05-07 17:21:54 +0800 |
| commit | 5d885ede63e013ac6e7298ba9f2d8c701cf83bd3 (patch) | |
| tree | 654d964ddec9d0fa4aabfc3667490d8b1bac092e /r503.c | |
| parent | f066214e0f93f94aa084de0cb4e285cb2b021ba4 (diff) | |
| download | avr-fpm-drivers-5d885ede63e013ac6e7298ba9f2d8c701cf83bd3.tar.gz | |
Enroll fingerprint.
Diffstat (limited to 'r503.c')
| -rw-r--r-- | r503.c | 49 |
1 files changed, 42 insertions, 7 deletions
@@ -163,6 +163,18 @@ static inline uint8_t scan(void) return buf[0] == OK; } +static inline uint8_t img2tz(uint8_t bufid) +{ + uint16_t n; + uint8_t buf[MAXPDLEN]; + + buf[0] = 0x02; + buf[1] = bufid; + send(0x01, buf, 2); + recv(buf, &n); + return buf[0] == OK; +} + void fpm_led_on(COLOR color) { led_ctrl(0x03, color); @@ -245,14 +257,37 @@ uint16_t fpm_get_count(void) return count; } -uint8_t fpm_enroll(void) +uint8_t fpm_enroll(uint16_t id) { - uint16_t n, retries; - uint8_t buf[MAXPDLEN], led; + uint16_t n; + uint8_t buf[MAXPDLEN]; + + if (!scan()) + return 0; + + if (!img2tz(1)) + return 0; - if (scan()) { - - } + _delay_ms(2000); - return 0; + if (!scan()) + return 0; + + if (!img2tz(2)) + return 0; + + buf[0] = 0x05; + send(0x01, buf, 1); + recv(buf, &n); + if (buf[0] != OK) + return 0; + + buf[0] = 0x06; + buf[1] = 1; + buf[2] = (uint8_t)(id >> 8); + buf[3] = (uint8_t)(id & 0xFF); + send(0x01, buf, 4); + recv(buf, &n); + + return buf[0] == OK; } |
