From 2f95fb254bac1f116f44215687069d02657e65a1 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Thu, 23 Sep 2010 16:26:06 +0000 Subject: [PATCH] Improve ATQB decoding: "PUPI", "Application Data", and "Protocol Info" is now available as separated fields. --- examples/nfc-utils.c | 8 ++++++-- include/nfc/nfc-types.h | 8 ++++++-- libnfc/chips/pn53x.c | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/examples/nfc-utils.c b/examples/nfc-utils.c index 883252a..2c14530 100644 --- a/examples/nfc-utils.c +++ b/examples/nfc-utils.c @@ -135,8 +135,12 @@ print_nfc_felica_info (const nfc_felica_info_t nfi) void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi) { - printf (" ATQB: "); - print_hex (nbi.abtAtqb, 12); + printf (" PUPI: "); + print_hex (nbi.abtPupi, 4); + printf (" Application Data: "); + print_hex (nbi.abtApplicationData, 4); + printf (" Protocol Info: "); + print_hex (nbi.abtProtocolInfo, 3); } /** diff --git a/include/nfc/nfc-types.h b/include/nfc/nfc-types.h index 38b86f2..048b0ea 100644 --- a/include/nfc/nfc-types.h +++ b/include/nfc/nfc-types.h @@ -231,8 +231,12 @@ typedef struct { * @brief NFC ISO14443B tag information */ typedef struct { -/** abtAtqb store ATQB (Answer To reQuest of type B) */ - byte_t abtAtqb[12]; +/** abtPupi store PUPI contained in ATQB (Answer To reQuest of type B) (see ISO14443-3) */ + byte_t abtPupi[4]; +/** abtApplicationData store Application Data contained in ATQB (see ISO14443-3) */ + byte_t abtApplicationData[4]; +/** abtProtocolInfo store Protocol Info contained in ATQB (see ISO14443-3) */ + byte_t abtProtocolInfo[3]; /** 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 d2e0885..a0601e7 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -369,10 +369,22 @@ pn53x_decode_target_data (const byte_t * pbtRawData, size_t szDataLen, nfc_chip_ // We skip the first byte: its the target number (Tg) pbtRawData++; - // Store the mandatory info - memcpy (pnti->nbi.abtAtqb, pbtRawData, 12); - pbtRawData += 12; + // Now we are in ATQB, we skip the first ATQB byte always equal to 0x50 + pbtRawData++; + + // Store the PUPI (Pseudo-Unique PICC Identifier) + memcpy (pnti->nbi.abtPupi, pbtRawData, 4); + pbtRawData += 4; + // Store the Application Data + memcpy (pnti->nbi.abtApplicationData, pbtRawData, 4); + pbtRawData += 4; + + // Store the Protocol Info + memcpy (pnti->nbi.abtProtocolInfo, pbtRawData, 3); + pbtRawData += 3; + + // We leave the ATQB field, we now enter in Card IDentifier szAttribRes = *(pbtRawData++); if (szAttribRes) { pnti->nbi.ui8CardIdentifier = *(pbtRawData++);