From ac663d02a141054a53c3f154f5990fde56fbe9a7 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 18 May 2010 10:57:38 +0000 Subject: [PATCH] Use pn53x_decode_target_data() to decode target data in nfc_initiator_select_tag(). Fix Issue 82. --- libnfc/nfc.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/libnfc/nfc.c b/libnfc/nfc.c index ef25bb2..abb7784 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -480,25 +480,7 @@ bool nfc_initiator_select_tag(const nfc_device_t* pnd, const nfc_modulation_t nm switch(nmInitModulation) { case NM_ISO14443A_106: - // Somehow they switched the lower and upper ATQA bytes around for the PN531 chipset - if (pnd->nc == NC_PN531) - { - pnti->nai.abtAtqa[0] = abtRx[3]; - pnti->nai.abtAtqa[1] = abtRx[2]; - } else { - memcpy(pnti->nai.abtAtqa,abtRx+2,2); - } - pnti->nai.btSak = abtRx[4]; - // Copy the NFCID1 - pnti->nai.szUidLen = abtRx[5]; - memcpy(pnti->nai.abtUid,abtRx+6,pnti->nai.szUidLen); - // Did we received an optional ATS (Smardcard ATR) - if (szRxLen > pnti->nai.szUidLen+6) { - pnti->nai.szAtsLen = abtRx[pnti->nai.szUidLen+6]; - memcpy(pnti->nai.abtAts,abtRx+pnti->nai.szUidLen+7,pnti->nai.szAtsLen); - } else { - pnti->nai.szAtsLen = 0; - } + if(!pn53x_decode_target_data(&abtRx[1], szRxLen-1, pnd->nc, NTT_GENERIC_PASSIVE_106, pnti)) return false; // Strip CT (Cascade Tag) to retrieve and store the _real_ UID // (e.g. 0x8801020304050607 is in fact 0x01020304050607)