From 3a007f1fc48bf06cd553259413e95b4e1f478b46 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 12 Oct 2009 12:38:14 +0000 Subject: [PATCH] lsnfc now detect MIFARE Classic and MIFARE DESFire. --- src/lsnfc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lsnfc.c b/src/lsnfc.c index 9c36f7a..192367c 100644 --- a/src/lsnfc.c +++ b/src/lsnfc.c @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see */ @@ -38,6 +38,7 @@ void print_hex(byte_t* pbtData, size_t szDate) int main(int argc, const char* argv[]) { tag_info ti; + uint8_t tag_count = 0; // Try to open the NFC device pdi = nfc_connect(NULL); @@ -81,10 +82,16 @@ int main(int argc, const char* argv[]) if ((ti.tia.abtAtqa[0] == 0x00) && (ti.tia.abtAtqa[1] == 0x44)) { printf("MIFARE Ultralight "); printf("(UID="); print_hex(ti.tia.abtUid,ti.tia.szUidLen); printf(")\n"); + } else if ((ti.tia.abtAtqa[0] == 0x03) && (ti.tia.abtAtqa[1] == 0x44)) { + printf("MIFARE DESFire 4k"); + printf("(UID="); print_hex(ti.tia.abtUid,ti.tia.szUidLen); printf(")\n"); } else if (ti.tia.btSak & 0x08) { printf("MIFARE Classic "); - if ((ti.tia.abtAtqa[0] == 0x00) && (ti.tia.abtAtqa[1] == 0x04)) printf("1k "); - if ((ti.tia.abtAtqa[0] == 0x03) && (ti.tia.abtAtqa[1] == 0x44)) printf("4k "); + if (ti.tia.abtAtqa[1] != 0x02) { + printf("1k "); + } else { + printf("4k "); + } printf("(UID="); print_hex(ti.tia.abtUid,ti.tia.szUidLen); printf(")\n"); } else { printf("Unknown tag type: "); @@ -100,6 +107,7 @@ int main(int argc, const char* argv[]) printf("\n"); } nfc_initiator_deselect_tag(pdi); + tag_count++; } else if (nfc_initiator_select_tag(pdi,IM_FELICA_212,abtFelica,5,&ti) || nfc_initiator_select_tag(pdi,IM_FELICA_424,abtFelica,5,&ti)) // Poll for a Felica tag { printf("The following (NFC) Felica tag was found:\n\n"); @@ -122,9 +130,9 @@ int main(int argc, const char* argv[]) printf("Jewel\n"); } else { no_more_tag = true; - printf("No more tag.\n"); } } while (no_more_tag != true); + printf("%d tag(s) have been found.\n", tag_count); nfc_disconnect(pdi); return 1;