diff options
Diffstat (limited to 'reader.c')
-rw-r--r-- | reader.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -86,6 +86,24 @@ int reader_init(){ return reader_init_backend(); } +static void reader_print_tag(nfc_tag_info_t tag){ + size_t n = 0; + char* type = "UNST"; + switch(tag.type){ + case tag_unset: type = "UNST"; break; + case tag_unknown: type = "UNKN"; break; + case tag_mifare1: type = "MFR1"; break; + case tag_ntag: type = "NTAG"; break; + case tag_desfire: type = "DESF"; break; + } + + printf("[%s", type); + for(n = 0; n < tag.uid_length; n++){ + printf(" %02X", tag.uid[n]); + } + printf("]"); +} + static void reader_expire(){ size_t n = 0; for(n = 0; n < MAX_TAGS; n++){ @@ -101,16 +119,22 @@ static int reader_process(){ //new tag tags[n].flags |= FLAG_ACTIVE; if(tags[n].flags & FLAG_TAG_LOCKED){ - printf("A tag was detected (slot %lu), but no key is known\n", n); + printf("Slot %2lu: ", n); + reader_print_tag(tags[n].info); + printf(" locked, unusable\n"); return 0; } if(tags[n].flags & FLAG_TAG_UNPROGRAMMED){ - printf("Unprogrammed tag detected (slot %lu)\n", n); + printf("Slot %2lu: ", n); + reader_print_tag(tags[n].info); + printf(" unprogrammed\n"); //TODO return 0; } if(tags[n].flags & FLAG_TAG_DATA_VALID){ - printf("Command tag detected (slot %lu)\n", n); + printf("Slot %2lu: ", n); + reader_print_tag(tags[n].info); + printf(" valid\n"); //TODO return 0; } @@ -136,7 +160,7 @@ int reader_tag_present(uint8_t flags, nfc_tag_info_t tag){ size_t n = 0; //sanitize input flags - flags &= (FLAG_TAG_DATA_VALID | FLAG_TAG_UNPROGRAMMED | FLAG_TAG_LOCKED); + flags &= (TAG_STATUS_FLAGS); //check if tag already known for(n = 0; n < MAX_TAGS; n++){ |