nfc_initiator_select_passive_target() accepts NULL pbtInitData and provides default values
This commit is contained in:
parent
fd30e63b80
commit
415ad7cbac
2 changed files with 20 additions and 21 deletions
|
@ -22,6 +22,7 @@ Improvements:
|
||||||
- Save & restore NP_INFINITE_SELECT status when changing it internally
|
- Save & restore NP_INFINITE_SELECT status when changing it internally
|
||||||
- nfc-mfclassic: add format/wipe command (thanks to Adam Laurie)
|
- 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-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():
|
Fixes & improvements specific to nfc_initiator_target_is_present():
|
||||||
- Supports fully PN532 & PN533, not tested on other chips
|
- Supports fully PN532 & PN533, not tested on other chips
|
||||||
|
|
34
libnfc/nfc.c
34
libnfc/nfc.c
|
@ -500,12 +500,15 @@ nfc_initiator_init_secure_element(nfc_device *pnd)
|
||||||
*
|
*
|
||||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||||
* @param nm desired modulation
|
* @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.
|
* @param szInitData length of initiator data \a pbtInitData.
|
||||||
* @note pbtInitData is used with different kind of data depending on modulation type:
|
* @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 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 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).
|
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
|
* @param[out] pnt \a nfc_target struct pointer which will filled if available
|
||||||
*
|
*
|
||||||
|
@ -520,24 +523,19 @@ nfc_initiator_select_passive_target(nfc_device *pnd,
|
||||||
const uint8_t *pbtInitData, const size_t szInitData,
|
const uint8_t *pbtInitData, const size_t szInitData,
|
||||||
nfc_target *pnt)
|
nfc_target *pnt)
|
||||||
{
|
{
|
||||||
uint8_t abtInit[MAX(12, szInitData)];
|
uint8_t *abtInit = NULL;
|
||||||
size_t szInit;
|
uint8_t abtTmpInit[MAX(12, szInitData)];
|
||||||
|
size_t szInit = 0;
|
||||||
switch (nm.nmt) {
|
if (szInitData == 0) {
|
||||||
case NMT_ISO14443A:
|
// 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);
|
iso14443_cascade_uid(pbtInitData, szInitData, abtInit, &szInit);
|
||||||
break;
|
} else {
|
||||||
|
abtInit = abtTmpInit;
|
||||||
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);
|
memcpy(abtInit, pbtInitData, szInitData);
|
||||||
szInit = szInitData;
|
szInit = szInitData;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL(initiator_select_passive_target, pnd, nm, abtInit, szInit, pnt);
|
HAL(initiator_select_passive_target, pnd, nm, abtInit, szInit, pnt);
|
||||||
|
|
Loading…
Reference in a new issue