diff --git a/include/nfc/nfc-types.h b/include/nfc/nfc-types.h index 6ca57a4..2a9af34 100644 --- a/include/nfc/nfc-types.h +++ b/include/nfc/nfc-types.h @@ -293,7 +293,7 @@ typedef union { nfc_jewel_info nji; nfc_barcode_info nti; // "t" for Thinfilm, "b" already used nfc_dep_info ndi; - nfc_iso14443biclass_info nic; // iclass - nbi already used + nfc_iso14443biclass_info nhi; // hid iclass / picopass - nii already used } nfc_target_info; /** diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 44b862c..12b01fa 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -581,7 +581,7 @@ pn53x_decode_target_data(const uint8_t *pbtRawData, size_t szRawData, pn53x_type case NMT_ISO14443BICLASS: // Store the UID for(uint8_t i= 0 ; i < 8 ; ++i) - pnti->nic.abtUID[7 - i]= pbtRawData[i]; + pnti->nhi.abtUID[7 - i]= pbtRawData[i]; break; case NMT_ISO14443B2CT: @@ -1062,7 +1062,7 @@ pn53x_initiator_init(struct nfc_device *pnd) // iclass requires special modulation settings void pn53x_initiator_init_iclass_modulation(struct nfc_device *pnd) { - // send a bunch of low level commands I reverse engineered from a working iClass reader + // send a bunch of low level commands reverse engineered from a working iClass reader // original device was using a PN512 // // // TxModeReg - Defines the data rate and framing during transmission. @@ -1196,12 +1196,12 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd, abtReqt[0]= 0x0c; // iClass SELECT abtAnticol[0]= 0x81; // iClass ANTICOL if ((res = pn53x_initiator_transceive_bytes(pnd, abtReqt, sizeof(abtReqt), &abtAnticol[1], sizeof(abtAnticol) - 1, timeout)) < 0) { - log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "timeout on iClass anticol"); + log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "timeout on iClass anticol"); return res; } // write back anticol handle to get UID if ((res = pn53x_initiator_transceive_bytes(pnd, abtAnticol, 9, abtTargetsData, 10, timeout)) < 0) { - log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "timeout on iClass get UID"); + log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "timeout on iClass get UID"); return res; } log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "iClass raw UID: %02x %02x %02x %02x %02x %02x %02x %02x", abtTargetsData[0], abtTargetsData[1], abtTargetsData[2], abtTargetsData[3], abtTargetsData[4], abtTargetsData[5], abtTargetsData[6], abtTargetsData[7]); @@ -1210,6 +1210,15 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd, if ((res = pn53x_decode_target_data(abtTargetsData, szTargetsData, CHIP_DATA(pnd)->type, nm.nmt, &(nttmp.nti))) < 0) { return res; } + } else { + + if ((res = pn53x_initiator_transceive_bytes(pnd, pbtInitData, szInitData, abtTargetsData, sizeof(abtTargetsData), timeout)) < 0) { + if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout + continue; + } else + return res; + } + szTargetsData = (size_t)res; } if (nm.nmt == NMT_ISO14443B2CT) { diff --git a/libnfc/nfc-internal.c b/libnfc/nfc-internal.c index 0200aa4..07a3698 100644 --- a/libnfc/nfc-internal.c +++ b/libnfc/nfc-internal.c @@ -170,37 +170,33 @@ void prepare_initiator_data(const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t *pszInitiatorData) { switch (nm.nmt) { - case NMT_ISO14443B: { + case NMT_ISO14443B: // Application Family Identifier (AFI) must equals 0x00 in order to wakeup all ISO14443-B PICCs (see ISO/IEC 14443-3) *ppbtInitiatorData = (uint8_t *) "\x00"; *pszInitiatorData = 1; - } break; - case NMT_ISO14443BI: { + case NMT_ISO14443BI: // APGEN *ppbtInitiatorData = (uint8_t *) "\x01\x0b\x3f\x80"; *pszInitiatorData = 4; - } break; - case NMT_ISO14443B2SR: { + case NMT_ISO14443B2SR: // Get_UID *ppbtInitiatorData = (uint8_t *) "\x0b"; *pszInitiatorData = 1; - } break; - case NMT_ISO14443B2CT: { + case NMT_ISO14443B2CT: // SELECT-ALL *ppbtInitiatorData = (uint8_t *) "\x9F\xFF\xFF"; *pszInitiatorData = 3; - } break; - case NMT_FELICA: { + case NMT_FELICA: // polling payload must be present (see ISO/IEC 18092 11.2.2.5) *ppbtInitiatorData = (uint8_t *) "\x00\xff\xff\x01\x00"; *pszInitiatorData = 5; - } break; case NMT_ISO14443A: + case NMT_ISO14443BICLASS: case NMT_JEWEL: case NMT_BARCODE: case NMT_DEP: diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 55e8926..8e003c2 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -1390,6 +1390,8 @@ str_nfc_modulation_type(const nfc_modulation_type nmt) return "ISO/IEC 14443-4B"; case NMT_ISO14443BI: return "ISO/IEC 14443-4B'"; + case NMT_ISO14443BICLASS: + return "ISO/IEC 14443-2B-3B iClass (Picopass)"; case NMT_ISO14443B2CT: return "ISO/IEC 14443-2B ASK CTx"; case NMT_ISO14443B2SR: diff --git a/libnfc/target-subr.c b/libnfc/target-subr.c index e6b143c..3bd97e4 100644 --- a/libnfc/target-subr.c +++ b/libnfc/target-subr.c @@ -679,7 +679,7 @@ snprint_nfc_target(char *dst, size_t size, const nfc_target *pnt, bool verbose) snprint_nfc_iso14443b2sr_info(dst + off, size - off, &pnt->nti.nsi, verbose); break; case NMT_ISO14443BICLASS: - snprint_nfc_iso14443biclass_info(dst + off, size - off, &pnt->nti.nic, verbose); + snprint_nfc_iso14443biclass_info(dst + off, size - off, &pnt->nti.nhi, verbose); break; case NMT_ISO14443B2CT: snprint_nfc_iso14443b2ct_info(dst + off, size - off, &pnt->nti.nci, verbose);