[libnfc] push by yob...@gmail.com - nfc_initiator_select_passive_target() accepts NULL pbtInitData and pro... on 2014-02-10 00:12 GMT

10 views
Skip to first unread message

lib...@googlecode.com

unread,
Feb 9, 2014, 7:13:05 PM2/9/14
to libnfc-...@googlegroups.com
Revision: 415ad7cbac02
Author: Philippe Teuwen <yob...@gmail.com>
Date: Mon Feb 10 00:07:11 2014 UTC
Log: nfc_initiator_select_passive_target() accepts NULL pbtInitData
and provides default values

http://code.google.com/p/libnfc/source/detail?r=415ad7cbac02

Modified:
/ChangeLog
/libnfc/nfc.c

=======================================
--- /ChangeLog Fri Feb 7 13:39:44 2014 UTC
+++ /ChangeLog Mon Feb 10 00:07:11 2014 UTC
@@ -22,6 +22,7 @@
- Save & restore NP_INFINITE_SELECT status when changing it internally
- nfc-mfclassic: add format/wipe command (thanks to Adam Laurie)
- nfc-jewel: new utility to read/write Topaz/Jewel tags (thanks to Pim 't
Hart)
+ - nfc_initiator_select_passive_target() provides defaults if
pbtInitData=NULL

Fixes & improvements specific to nfc_initiator_target_is_present():
- Supports fully PN532 & PN533, not tested on other chips
=======================================
--- /libnfc/nfc.c Sat Feb 1 01:32:57 2014 UTC
+++ /libnfc/nfc.c Mon Feb 10 00:07:11 2014 UTC
@@ -500,12 +500,15 @@
*
* @param pnd \a nfc_device struct pointer that represent currently used
device
* @param nm desired modulation
- * @param pbtInitData optional initiator data used for Felica, ISO14443B,
Topaz polling or to select a specific UID in ISO14443A.
+ * @param pbtInitData optional initiator data, NULL for using the default
values.
* @param szInitData length of initiator data \a pbtInitData.
* @note pbtInitData is used with different kind of data depending on
modulation type:
* - for an ISO/IEC 14443 type A modulation, pbbInitData contains the UID
you want to select;
- * - for an ISO/IEC 14443 type B modulation, pbbInitData contains
Application Family Identifier (AFI) (see ISO/IEC 14443-3);
- * - for a FeliCa modulation, pbbInitData contains polling payload (see
ISO/IEC 18092 11.2.2.5).
+ * - for an ISO/IEC 14443 type B modulation, pbbInitData contains
Application Family Identifier (AFI) (see ISO/IEC 14443-3)
+ and optionally a second byte = 0x01 if you want to use
probabilistic approach instead of timeslot approach;
+ * - for a FeliCa modulation, pbbInitData contains a 5-byte polling
payload (see ISO/IEC 18092 11.2.2.5).
+ * - for ISO14443B', ASK CTx and ST SRx, see corresponding standards
+ * - if NULL, default values adequate for the chosen modulation will be
used.
*
* @param[out] pnt \a nfc_target struct pointer which will filled if
available
*
@@ -520,24 +523,19 @@
const uint8_t *pbtInitData, const
size_t szInitData,
nfc_target *pnt)
{
- uint8_t abtInit[MAX(12, szInitData)];
- size_t szInit;
-
- switch (nm.nmt) {
- case NMT_ISO14443A:
- iso14443_cascade_uid(pbtInitData, szInitData, abtInit, &szInit);
- break;
-
- case NMT_JEWEL:
- case NMT_ISO14443B:
- case NMT_ISO14443BI:
- case NMT_ISO14443B2SR:
- case NMT_ISO14443B2CT:
- case NMT_FELICA:
- case NMT_DEP:
- memcpy(abtInit, pbtInitData, szInitData);
- szInit = szInitData;
- break;
+ uint8_t *abtInit = NULL;
+ uint8_t abtTmpInit[MAX(12, szInitData)];
+ size_t szInit = 0;
+ if (szInitData == 0) {
+ // Provide default values, if any
+ prepare_initiator_data(nm, &abtInit, &szInit);
+ } else if (nm.nmt == NMT_ISO14443A) {
+ abtInit = abtTmpInit;
+ iso14443_cascade_uid(pbtInitData, szInitData, abtInit, &szInit);
+ } else {
+ abtInit = abtTmpInit;
+ memcpy(abtInit, pbtInitData, szInitData);
+ szInit = szInitData;
}

HAL(initiator_select_passive_target, pnd, nm, abtInit, szInit, pnt);
Reply all
Reply to author
Forward
0 new messages