diff --git a/TODO.md b/TODO.md index c130a22..faf8c72 100644 --- a/TODO.md +++ b/TODO.md @@ -16,19 +16,19 @@ - [ ] card + PIN read - [x] timeout on keycode - [x] rework ACL as struct (with cards, timer, etc) - - [ ] Update all variants - - [ ] controller + - [x] Update all variants + - [x] controller - [x] picow/base - [x] picow/wifi - [x] picow/wifi+usb - - [ ] pico/base - - [ ] pico/usb - - [ ] universal + - [x] pico/base + - [x] pico/usb + - [x] universal - [x] picow/base - [x] picow/wifi - [x] picow/wifi+usb - - [ ] pico/base - - [ ] pico/usb + - [x] pico/base + - [x] pico/usb - [ ] Remove debug stuff - [ ] Check mode == CONTROLLER/READER in unlock, etc - [ ] README diff --git a/pico/core/src/acl.c b/pico/core/src/acl.c index 14199c4..547e5ef 100644 --- a/pico/core/src/acl.c +++ b/pico/core/src/acl.c @@ -82,7 +82,7 @@ int acl_load() { ACL.cards[i].start = cards[i].start; ACL.cards[i].end = cards[i].end; ACL.cards[i].allowed = cards[i].allowed; - snprintf(ACL.cards[i].PIN, sizeof(cards[i].PIN), ""); + snprintf(ACL.cards[i].PIN, sizeof(cards[i].PIN), cards[i].PIN); snprintf(ACL.cards[i].name, sizeof(cards[i].name), cards[i].name); } diff --git a/pico/core/src/sdcard.c b/pico/core/src/sdcard.c index 577a520..49e8960 100644 --- a/pico/core/src/sdcard.c +++ b/pico/core/src/sdcard.c @@ -13,6 +13,8 @@ #include "../include/sdcard.h" #include "../include/wiegand.h" +const char *NO_PIN = "-----"; + void spi0_dma_isr(); datetime_t string2date(const char *); @@ -207,7 +209,10 @@ int sdcard_read_acl(CARD cards[], int *N) { if ((p = strtok(NULL, " ")) != NULL) { cards[ix].allowed = strncmp(p, "Y", 1) == 0 || strncmp(p, "y", 1) == 0; if ((p = strtok(NULL, " ")) != NULL) { - snprintf(cards[ix].PIN, sizeof(cards[ix].PIN), p); + if (strncmp(p, NO_PIN, CARD_PIN_SIZE) != 0) { + snprintf(cards[ix].PIN, sizeof(cards[ix].PIN), p); + } + if ((p = strtok(NULL, " ")) != NULL) { snprintf(cards[ix].name, sizeof(cards[ix].name), p); } @@ -257,7 +262,7 @@ int sdcard_write_acl(CARD cards[], int N) { card.end.month, card.end.day, card.allowed ? 'Y' : 'N', - card.PIN, + strncmp(card.PIN, "", CARD_PIN_SIZE) == 0 ? NO_PIN : card.PIN, card.name); if ((fr = f_printf(&file, "%s\n", record)) < 0) { diff --git a/pico/universal/common/src/universal.c b/pico/universal/common/src/universal.c index b51da43..331c443 100644 --- a/pico/universal/common/src/universal.c +++ b/pico/universal/common/src/universal.c @@ -19,15 +19,21 @@ void dispatch(uint32_t v) { on_card_read(v & 0x0fffffff); if (last_card.ok && mode == READER) { - enum ACCESS access; - if ((access = acl_allowed(last_card.facility_code, last_card.card_number, "")) == GRANTED) { + enum ACCESS access = acl_allowed(last_card.facility_code, last_card.card_number, ""); + + switch (access) { + case GRANTED: last_card.access = GRANTED; led_blink(1); door_unlock(5000); - } else if (access == NEEDS_PIN) { + break; + + case NEEDS_PIN: last_card.access = NEEDS_PIN; led_blink(1); - } else { + break; + + default: last_card.access = DENIED; led_blink(3); } diff --git a/pico/universal/pico/base/src/universal.c b/pico/universal/pico/base/src/universal.c index 59c438b..8d9300f 100644 --- a/pico/universal/pico/base/src/universal.c +++ b/pico/universal/pico/base/src/universal.c @@ -60,7 +60,7 @@ card last_card = { }; int main() { - bi_decl(bi_program_description("Pico-Wiegand interface")); + bi_decl(bi_program_description("Pico-Wiegand Universal Interface")); bi_decl(bi_program_version_string(VERSION)); stdio_init_all(); @@ -180,7 +180,7 @@ void sysinit() { static repeating_timer_t syscheck_rt; if (!initialised) { - puts(" *** WIEGAND REFERENCE IMPLEMENTATION"); + puts(" Pico-Wiegand Universal Interface"); if (!gpio_get(JUMPER_READ) && gpio_get(JUMPER_WRITE)) { mode = READER; diff --git a/pico/universal/pico/usb/src/universal.c b/pico/universal/pico/usb/src/universal.c index ce40c2e..042129f 100644 --- a/pico/universal/pico/usb/src/universal.c +++ b/pico/universal/pico/usb/src/universal.c @@ -61,7 +61,7 @@ card last_card = { }; int main() { - bi_decl(bi_program_description("Pico-Wiegand Reference interface (USB)")); + bi_decl(bi_program_description("Pico-Wiegand universal Interface (USB)")); bi_decl(bi_program_version_string(VERSION)); stdio_init_all(); @@ -181,7 +181,7 @@ void sysinit() { static repeating_timer_t syscheck_rt; if (!initialised) { - puts(" *** WIEGAND REFERENCE IMPLEMENTATION (USB)"); + puts(" Pico-Wiegand Universal Interface"); if (!gpio_get(JUMPER_READ) && gpio_get(JUMPER_WRITE)) { mode = READER; diff --git a/pico/universal/picow/base/src/universal.c b/pico/universal/picow/base/src/universal.c index 7e3c0c4..f4900f8 100644 --- a/pico/universal/picow/base/src/universal.c +++ b/pico/universal/picow/base/src/universal.c @@ -184,7 +184,7 @@ void sysinit() { static repeating_timer_t syscheck_rt; if (!initialised) { - puts(" *** WIEGAND REFERENCE IMPLEMENTATION"); + puts(" PicoW-Wiegand Universal Interface"); if (!gpio_get(JUMPER_READ) && gpio_get(JUMPER_WRITE)) { mode = READER; diff --git a/pico/universal/picow/wifi+usb/src/universal.c b/pico/universal/picow/wifi+usb/src/universal.c index 59dc132..c7cc608 100644 --- a/pico/universal/picow/wifi+usb/src/universal.c +++ b/pico/universal/picow/wifi+usb/src/universal.c @@ -193,7 +193,7 @@ void sysinit() { static repeating_timer_t syscheck_rt; if (!initialised) { - puts(" *** WIEGAND REFERENCE IMPLEMENTATION (USB)"); + puts(" PicoW-Wiegand Universal Interface (WiFi+USB)"); if (!gpio_get(JUMPER_READ) && gpio_get(JUMPER_WRITE)) { mode = READER; diff --git a/pico/universal/picow/wifi/src/universal.c b/pico/universal/picow/wifi/src/universal.c index 26c140b..1a04e13 100644 --- a/pico/universal/picow/wifi/src/universal.c +++ b/pico/universal/picow/wifi/src/universal.c @@ -191,7 +191,7 @@ void sysinit() { static repeating_timer_t syscheck_rt; if (!initialised) { - puts(" *** WIEGAND REFERENCE IMPLEMENTATION (WIFI)"); + puts(" PicoW-Wiegand Universal Interface (WiFi)"); if (!gpio_get(JUMPER_READ) && gpio_get(JUMPER_WRITE)) { mode = READER;