diff options
author | cbdev <cb@cbcdn.com> | 2023-06-22 01:11:31 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2023-06-22 01:11:31 +0200 |
commit | e27446a8f8c470cc7a41cfeec1e6ffe4f23478e0 (patch) | |
tree | f16ca27ce915768b700de0d5be29f1206b7499ba /reader.c | |
parent | cb686cd6314d3e181bd91c0f2d449750c9429be7 (diff) | |
download | nfcommander-e27446a8f8c470cc7a41cfeec1e6ffe4f23478e0.tar.gz nfcommander-e27446a8f8c470cc7a41cfeec1e6ffe4f23478e0.tar.bz2 nfcommander-e27446a8f8c470cc7a41cfeec1e6ffe4f23478e0.zip |
Basic NTAG support
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++){ |