New function nfc_initiator_target_is_present() to test is a previously selected target is in the field.

This commit is contained in:
Romuald Conty 2012-05-27 22:34:21 +00:00
parent 2c9275adde
commit 8f08431ddf
12 changed files with 49 additions and 1 deletions

View file

@ -199,6 +199,13 @@ pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szT
if (pbtRx[0] & 0x40) { abort(); } // MI detected
CHIP_DATA(pnd)->last_status_byte = pbtRx[0] & 0x3f;
break;
case Diagnose:
if (pbtTx[1] == 0x06) { // Diagnose: Card presence detection
CHIP_DATA(pnd)->last_status_byte = pbtRx[0] & 0x3f;
} else {
CHIP_DATA(pnd)->last_status_byte = 0;
};
break;
case InDeselect:
case InRelease:
if (CHIP_DATA(pnd)->type == RCS360) {
@ -1624,6 +1631,22 @@ pn53x_initiator_deselect_target (struct nfc_device *pnd)
return pn53x_InDeselect (pnd, 0); // 0 mean deselect all selected targets
}
int
pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt)
{
// TODO Check if nt is equal to current target
const uint8_t abtCmd[] = { Diagnose, 0x06 };
uint8_t abtRx[1];
int res = 0;
if ((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, sizeof (abtRx), -1)) < 0)
return res;
if (res==1) {
return NFC_SUCCESS;
}
return NFC_ETGRELEASED;
}
#define SAK_ISO14443_4_COMPLIANT 0x20
#define SAK_ISO18092_COMPLIANT 0x40
int

View file

@ -334,6 +334,7 @@ int pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint
int pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
uint8_t *pbtRx, uint32_t *cycles);
int pn53x_initiator_deselect_target (struct nfc_device *pnd);
int pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt);
// NFC device as Target functions
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRxLen, int timeout);