From 7254e1b2eac5814ceea72dcb903beaa6e977a96f Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 3 Feb 2014 00:24:23 +0100 Subject: [PATCH] nfc_initiator_target_is_present(): Support Jewel --- libnfc/chips/pn53x.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 4a950f0..2cda23e 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1797,6 +1797,26 @@ static int pn53x_ISO14443A_4_is_present(struct nfc_device *pnd) return ret; } +static int pn53x_ISO14443A_Jewel_is_present(struct nfc_device *pnd) +{ + int ret; + log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping Jewel"); + uint8_t abtCmd[1] = {0x78}; + int failures = 0; + while (failures < 2) { + if ((ret = nfc_initiator_transceive_bytes(pnd, abtCmd, sizeof(abtCmd), NULL, 0, -1)) < 1) { + if ((ret == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Timeout + return NFC_ETGRELEASED; + } else { // Other errors can appear when card is tired-off, let's try again + failures++; + } + } else { + return NFC_SUCCESS; + } + } + return ret; +} + static int pn53x_ISO14443A_MFUL_is_present(struct nfc_device *pnd) { int ret; @@ -1957,6 +1977,8 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt) ret = pn53x_ISO14443B_4_is_present(pnd); break; case NMT_JEWEL: + ret = pn53x_ISO14443A_Jewel_is_present(pnd); + break; case NMT_ISO14443BI: case NMT_ISO14443B2SR: case NMT_ISO14443B2CT: