From d7e79795802f53a46e8a03a1d220b3cf00d832aa Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 30 May 2012 23:02:41 +0000 Subject: [PATCH] Listing passive targets now quit earlier if szTargets count is reached and in that case, leave with the latest tag selected. That's quite useful when you need to directly use 1 target because in contrast of nfc_initiator_select_passive_target, you don't need to prepare initiator data by hands --- libnfc/nfc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 560dc2c..acb2940 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -456,10 +456,6 @@ nfc_initiator_list_passive_targets(nfc_device *pnd, prepare_initiator_data(nm, &pbtInitData, &szInitDataLen); while (nfc_initiator_select_passive_target(pnd, nm, pbtInitData, szInitDataLen, &nt) > 0) { - nfc_initiator_deselect_target(pnd); - if (szTargets == szTargetFound) { - break; - } size_t i; bool seen = false; // Check if we've already seen this tag @@ -473,6 +469,10 @@ nfc_initiator_list_passive_targets(nfc_device *pnd, } memcpy(&(ant[szTargetFound]), &nt, sizeof(nfc_target)); szTargetFound++; + if (szTargets == szTargetFound) { + break; + } + nfc_initiator_deselect_target(pnd); // deselect has no effect on FeliCa and Jewel cards so we'll stop after one... // ISO/IEC 14443 B' cards are polled at 100% probability so it's not possible to detect correctly two cards at the same time if ((nm.nmt == NMT_FELICA) || (nm.nmt == NMT_JEWEL) || (nm.nmt == NMT_ISO14443BI) || (nm.nmt == NMT_ISO14443B2SR) || (nm.nmt == NMT_ISO14443B2CT)) {