From 9f38ae715de23ec2c118bd315d95e8cf0f2ae0d2 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 12 Jun 2012 16:51:47 +0000 Subject: [PATCH] pn53x: allow more delay for Card Presence command (tested on PN533 and PN532 in various contexts). --- libnfc/chips/pn53x.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 2178324..66b3064 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1681,7 +1681,10 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target nt) uint8_t abtRx[1]; int res = 0; - if ((res = pn53x_transceive(pnd, abtCmd, sizeof(abtCmd), abtRx, sizeof(abtRx), -1)) < 0) + // Card Presence command can take more time than default one: when a card is + // removed from the field, the PN53x took few hundred ms more to reply + // correctly. (ie. 700 ms should be enough to detect all tested cases) + if ((res = pn53x_transceive(pnd, abtCmd, sizeof(abtCmd), abtRx, sizeof(abtRx), 700)) < 0) return res; if (res == 1) { return NFC_SUCCESS;