nfc_initiator_target_is_present(): Support B2 ASK CT
This commit is contained in:
parent
a3a7111210
commit
9fd11d331b
1 changed files with 46 additions and 20 deletions
|
@ -1939,28 +1939,52 @@ static int pn53x_ISO14443B_I_is_present(struct nfc_device *pnd)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B'");
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B'");
|
||||||
// Sending R(NACK) in raw:
|
// Sending ATTRIB in raw:
|
||||||
if ((ret = pn53x_set_property_bool(pnd, NP_EASY_FRAMING, false)) < 0)
|
if ((ret = pn53x_set_property_bool(pnd, NP_EASY_FRAMING, false)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
uint8_t abtCmd[6] = {0x01, 0x0f}; // ATTRIB
|
uint8_t abtCmd[6] = {0x01, 0x0f};
|
||||||
memcpy(abtCmd+2, CHIP_DATA(pnd)->current_target->nti.nii.abtDIV, 4);
|
memcpy(abtCmd + 2, CHIP_DATA(pnd)->current_target->nti.nii.abtDIV, 4);
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
while (failures < 2) {
|
while (failures < 2) {
|
||||||
if ((ret = nfc_initiator_transceive_bytes(pnd, abtCmd, sizeof(abtCmd), NULL, 0, 300)) < 1) {
|
if ((ret = nfc_initiator_transceive_bytes(pnd, abtCmd, sizeof(abtCmd), NULL, 0, 300)) < 1) {
|
||||||
if ((ret == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Timeout
|
if ((ret == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Timeout
|
||||||
ret = NFC_ETGRELEASED;
|
ret = NFC_ETGRELEASED;
|
||||||
break;
|
|
||||||
} else { // Other errors can appear when card is tired-off, let's try again
|
|
||||||
failures++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = NFC_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
|
} else { // Other errors can appear when card is tired-off, let's try again
|
||||||
|
failures++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ret = NFC_SUCCESS;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
int ret2;
|
}
|
||||||
if ((ret2 = pn53x_set_property_bool(pnd, NP_EASY_FRAMING, true)) < 0)
|
int ret2;
|
||||||
ret = ret2;
|
if ((ret2 = pn53x_set_property_bool(pnd, NP_EASY_FRAMING, true)) < 0)
|
||||||
|
ret = ret2;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int pn53x_ISO14443B_CT_is_present(struct nfc_device *pnd)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B2 ASK CT");
|
||||||
|
// Sending SELECT in raw: (EASY_FRAMING is already supposed to be false)
|
||||||
|
uint8_t abtCmd[3] = {0x9f};
|
||||||
|
memcpy(abtCmd + 1, CHIP_DATA(pnd)->current_target->nti.nci.abtUID, 2);
|
||||||
|
int failures = 0;
|
||||||
|
while (failures < 2) {
|
||||||
|
if ((ret = nfc_initiator_transceive_bytes(pnd, abtCmd, sizeof(abtCmd), NULL, 0, 300)) < 1) {
|
||||||
|
if ((ret == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Timeout
|
||||||
|
ret = NFC_ETGRELEASED;
|
||||||
|
break;
|
||||||
|
} else { // Other errors can appear when card is tired-off, let's try again
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = NFC_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2011,8 +2035,10 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt)
|
||||||
case NMT_ISO14443BI:
|
case NMT_ISO14443BI:
|
||||||
ret = pn53x_ISO14443B_I_is_present(pnd);
|
ret = pn53x_ISO14443B_I_is_present(pnd);
|
||||||
break;
|
break;
|
||||||
case NMT_ISO14443B2SR:
|
|
||||||
case NMT_ISO14443B2CT:
|
case NMT_ISO14443B2CT:
|
||||||
|
ret = pn53x_ISO14443B_CT_is_present(pnd);
|
||||||
|
break;
|
||||||
|
case NMT_ISO14443B2SR:
|
||||||
default:
|
default:
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): card type not supported");
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): card type not supported");
|
||||||
ret = NFC_EDEVNOTSUPP;
|
ret = NFC_EDEVNOTSUPP;
|
||||||
|
|
Loading…
Add table
Reference in a new issue