nfc_initiator_select_passive_target(): grant NP_INFINITE_SELECT also for ISO14443B*
This commit is contained in:
parent
510228b6e0
commit
69c4d0768a
3 changed files with 70 additions and 47 deletions
|
@ -895,6 +895,7 @@ pn53x_set_property_bool(struct nfc_device *pnd, const nfc_property property, con
|
||||||
// TODO Made some research around this point:
|
// TODO Made some research around this point:
|
||||||
// timings could be tweak better than this, and maybe we can tweak timings
|
// timings could be tweak better than this, and maybe we can tweak timings
|
||||||
// to "gain" a sort-of hardware polling (ie. like PN532 does)
|
// to "gain" a sort-of hardware polling (ie. like PN532 does)
|
||||||
|
pnd->bInfiniteSelect = bEnable;
|
||||||
return pn53x_RFConfiguration__MaxRetries(pnd,
|
return pn53x_RFConfiguration__MaxRetries(pnd,
|
||||||
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
|
(bEnable) ? 0xff : 0x00, // MxRtyATR, default: active = 0xff, passive = 0x02
|
||||||
(bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01
|
(bEnable) ? 0xff : 0x01, // MxRtyPSL, default: 0x01
|
||||||
|
@ -1084,7 +1085,11 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
|
||||||
if ((res = nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, true)) < 0) {
|
if ((res = nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, true)) < 0) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
pnd->bEasyFraming = false;
|
if ((res = nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false)) < 0) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
bool found = false;
|
||||||
|
do {
|
||||||
if (nm.nmt == NMT_ISO14443B2SR) {
|
if (nm.nmt == NMT_ISO14443B2SR) {
|
||||||
// Some work to do before getting the UID...
|
// Some work to do before getting the UID...
|
||||||
uint8_t abtInitiate[] = "\x06\x00";
|
uint8_t abtInitiate[] = "\x06\x00";
|
||||||
|
@ -1093,6 +1098,9 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
|
||||||
uint8_t abtRx[1];
|
uint8_t abtRx[1];
|
||||||
// Getting random Chip_ID
|
// Getting random Chip_ID
|
||||||
if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) {
|
if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) {
|
||||||
|
if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
abtSelect[1] = abtRx[0];
|
abtSelect[1] = abtRx[0];
|
||||||
|
@ -1105,11 +1113,18 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
|
||||||
const uint8_t abtReqt[] = { 0x10 };
|
const uint8_t abtReqt[] = { 0x10 };
|
||||||
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
|
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
|
||||||
if ((res = pn53x_initiator_transceive_bytes(pnd, abtReqt, sizeof(abtReqt), abtTargetsData + 2, sizeof(abtTargetsData) - 2, timeout)) < 0) {
|
if ((res = pn53x_initiator_transceive_bytes(pnd, abtReqt, sizeof(abtReqt), abtTargetsData + 2, sizeof(abtTargetsData) - 2, timeout)) < 0) {
|
||||||
|
if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
szTargetsData = (size_t)res;
|
szTargetsData = (size_t)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = pn53x_initiator_transceive_bytes(pnd, pbtInitData, szInitData, abtTargetsData, sizeof(abtTargetsData), timeout)) < 0) {
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
szTargetsData = (size_t)res;
|
szTargetsData = (size_t)res;
|
||||||
|
@ -1136,6 +1151,11 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
|
||||||
}
|
}
|
||||||
szTargetsData = (size_t)res;
|
szTargetsData = (size_t)res;
|
||||||
}
|
}
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
} while (pnd->bInfiniteSelect);
|
||||||
|
if (! found)
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const pn53x_modulation pm = pn53x_nm_to_pm(nm);
|
const pn53x_modulation pm = pn53x_nm_to_pm(nm);
|
||||||
|
|
|
@ -57,6 +57,7 @@ nfc_device_new(const nfc_context *context, const nfc_connstring connstring)
|
||||||
res->bCrc = false;
|
res->bCrc = false;
|
||||||
res->bPar = false;
|
res->bPar = false;
|
||||||
res->bEasyFraming = false;
|
res->bEasyFraming = false;
|
||||||
|
res->bInfiniteSelect = false;
|
||||||
res->bAutoIso14443_4 = false;
|
res->bAutoIso14443_4 = false;
|
||||||
res->last_error = 0;
|
res->last_error = 0;
|
||||||
memcpy(res->connstring, connstring, sizeof(res->connstring));
|
memcpy(res->connstring, connstring, sizeof(res->connstring));
|
||||||
|
|
|
@ -203,6 +203,8 @@ struct nfc_device {
|
||||||
bool bPar;
|
bool bPar;
|
||||||
/** Should the chip handle frames encapsulation and chaining */
|
/** Should the chip handle frames encapsulation and chaining */
|
||||||
bool bEasyFraming;
|
bool bEasyFraming;
|
||||||
|
/** Should the chip try forever on select? */
|
||||||
|
bool bInfiniteSelect;
|
||||||
/** Should the chip switch automatically activate ISO14443-4 when
|
/** Should the chip switch automatically activate ISO14443-4 when
|
||||||
selecting tags supporting it? */
|
selecting tags supporting it? */
|
||||||
bool bAutoIso14443_4;
|
bool bAutoIso14443_4;
|
||||||
|
|
Loading…
Add table
Reference in a new issue