From 7e2ddedfc13b7fd89c58c0d359d00dbbdfb0f847 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Thu, 23 Sep 2010 10:12:10 +0000 Subject: [PATCH] Fix ISO14443-B ATTRIB_RES decoding. (Thanks to Phil) --- examples/nfc-utils.c | 2 -- include/nfc/nfc-types.h | 5 +++-- libnfc/chips/pn53x.c | 9 ++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/nfc-utils.c b/examples/nfc-utils.c index fd2b521..883252a 100644 --- a/examples/nfc-utils.c +++ b/examples/nfc-utils.c @@ -137,8 +137,6 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi) { printf (" ATQB: "); print_hex (nbi.abtAtqb, 12); - printf (" ATTRIB_RES: "); - print_hex (nbi.abtAttribRes, nbi.szAttribRes); } /** diff --git a/include/nfc/nfc-types.h b/include/nfc/nfc-types.h index f0bc0b3..e63c24e 100644 --- a/include/nfc/nfc-types.h +++ b/include/nfc/nfc-types.h @@ -229,9 +229,10 @@ typedef struct { * @brief NFC ISO14443B tag information */ typedef struct { +/** abtAtqb store ATQB (Answer To reQuest of type B) */ byte_t abtAtqb[12]; - size_t szAttribRes; - byte_t abtAttribRes[64]; +/** ui8CardIdentifier store CID (Card Identifier) attributted by PCD to the PICC */ + uint8_t ui8CardIdentifier; } nfc_iso14443b_info_t; /** diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index e2210e3..5aeb4c4 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -321,6 +321,8 @@ bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szDataLen, nfc_chip_t nc, nfc_target_type_t ntt, nfc_target_info_t * pnti) { + uint8_t szAttribRes; + switch (ntt) { case NTT_MIFARE: case NTT_GENERIC_PASSIVE_106: @@ -371,9 +373,10 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szDataLen, nfc_chip_ memcpy (pnti->nbi.abtAtqb, pbtRawData, 12); pbtRawData += 12; - // FIXME This part is not correct: ATTRIB_RES should be decoded but I can't find the right document that explains how to CORRECTLY decode this frame - pnti->nbi.szAttribRes = *(pbtRawData++); - memcpy (pnti->nbi.abtAttribRes, pbtRawData, pnti->nbi.szAttribRes); + szAttribRes = *(pbtRawData++); + if (szAttribRes) { + pnti->nbi.ui8CardIdentifier = *(pbtRawData++); + } break; case NTT_FELICA_212: