Replace nfc_target_info_t with nfc_target_t in API function, we now have a coherent struct to handle nfc_target_t, use it!
This commit is contained in:
parent
6f3fbcb6bf
commit
af88da1a9c
10 changed files with 76 additions and 85 deletions
|
@ -41,7 +41,7 @@ int
|
|||
main (int argc, const char *argv[])
|
||||
{
|
||||
nfc_device_t *pnd;
|
||||
nfc_target_info_t nti;
|
||||
nfc_target_t nt;
|
||||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
size_t szRx;
|
||||
byte_t abtTx[] = "Hello World!";
|
||||
|
@ -62,12 +62,11 @@ main (int argc, const char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(!nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NULL, &nti)) {
|
||||
if(!nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NULL, &nt)) {
|
||||
nfc_perror(pnd, "nfc_initiator_select_dep_target");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf( "This D.E.P. target have been found:\n" );
|
||||
print_nfc_dep_info (nti.ndi);
|
||||
print_nfc_target (nt);
|
||||
|
||||
printf ("Sending: %s\n", abtTx);
|
||||
if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx)) {
|
||||
|
|
|
@ -108,7 +108,7 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
for (i = 0; i < szDeviceFound; i++) {
|
||||
nfc_target_info_t anti[MAX_TARGET_COUNT];
|
||||
nfc_target_t ant[MAX_TARGET_COUNT];
|
||||
pnd = nfc_connect (&(pnddDevices[i]));
|
||||
|
||||
if (pnd == NULL) {
|
||||
|
@ -146,11 +146,11 @@ main (int argc, const char *argv[])
|
|||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, anti, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
size_t n;
|
||||
printf ("%d ISO14443A passive target(s) was found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
||||
for (n = 0; n < szTargetFound; n++) {
|
||||
print_nfc_iso14443a_info (anti[n].nai);
|
||||
print_nfc_iso14443a_info (ant[n].nti.nai);
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
@ -158,23 +158,23 @@ main (int argc, const char *argv[])
|
|||
nm.nmt = NMT_FELICA;
|
||||
nm.nbr = NBR_212;
|
||||
// List Felica tags
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, anti, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
size_t n;
|
||||
printf ("%d Felica (212 kbps) passive target(s) was found%s\n", (int) szTargetFound,
|
||||
(szTargetFound == 0) ? ".\n" : ":");
|
||||
for (n = 0; n < szTargetFound; n++) {
|
||||
print_nfc_felica_info (anti[n].nfi);
|
||||
print_nfc_felica_info (ant[n].nti.nfi);
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
||||
nm.nbr = NBR_424;
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, anti, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
size_t n;
|
||||
printf ("%d Felica (424 kbps) passive target(s) was found%s\n", (int) szTargetFound,
|
||||
(szTargetFound == 0) ? ".\n" : ":");
|
||||
for (n = 0; n < szTargetFound; n++) {
|
||||
print_nfc_felica_info (anti[n].nfi);
|
||||
print_nfc_felica_info (ant[n].nti.nfi);
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
@ -182,11 +182,11 @@ main (int argc, const char *argv[])
|
|||
nm.nmt = NMT_ISO14443B;
|
||||
nm.nbr = NBR_106;
|
||||
// List ISO14443B targets
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, anti, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
if (nfc_initiator_list_passive_targets (pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound)) {
|
||||
size_t n;
|
||||
printf ("%d ISO14443B passive target(s) was found%s\n", (int) szTargetFound, (szTargetFound == 0) ? ".\n" : ":");
|
||||
for (n = 0; n < szTargetFound; n++) {
|
||||
print_nfc_iso14443b_info (anti[n].nbi);
|
||||
print_nfc_iso14443b_info (ant[n].nti.nbi);
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
|
@ -194,11 +194,11 @@ main (int argc, const char *argv[])
|
|||
nm.nmt = NMT_JEWEL;
|
||||
nm.nbr = NBR_106;
|
||||
// List Jewel targets
|
||||
if (nfc_initiator_list_passive_targets(pnd, nm, anti, MAX_TARGET_COUNT, &szTargetFound )) {
|
||||
if (nfc_initiator_list_passive_targets(pnd, nm, ant, MAX_TARGET_COUNT, &szTargetFound )) {
|
||||
size_t n;
|
||||
printf("%d Jewel passive target(s) was found%s\n", (int)szTargetFound, (szTargetFound==0)?".\n":":");
|
||||
for(n=0; n<szTargetFound; n++) {
|
||||
print_nfc_jewel_info (anti[n].nji);
|
||||
print_nfc_jewel_info (ant[n].nti.nji);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nfc-utils.h"
|
||||
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_target_info_t nti;
|
||||
static nfc_target_t nt;
|
||||
static mifare_param mp;
|
||||
static mifare_classic_tag mtKeys;
|
||||
static mifare_classic_tag mtDump;
|
||||
|
@ -118,7 +118,7 @@ authenticate (uint32_t uiBlock)
|
|||
// Key file authentication.
|
||||
if (bUseKeyFile) {
|
||||
// Set the authentication information (uid)
|
||||
memcpy (mp.mpa.abtUid, nti.nai.abtUid, 4);
|
||||
memcpy (mp.mpa.abtUid, nt.nti.nai.abtUid, 4);
|
||||
|
||||
// Locate the trailer (with the keys) used for this sector
|
||||
uiTrailerBlock = get_trailer_block (uiBlock);
|
||||
|
@ -142,7 +142,7 @@ authenticate (uint32_t uiBlock)
|
|||
mc = (bUseKeyA) ? MC_AUTH_A : MC_AUTH_B;
|
||||
|
||||
// Set the authentication information (uid)
|
||||
memcpy (mp.mpa.abtUid, nti.nai.abtUid, 4);
|
||||
memcpy (mp.mpa.abtUid, nt.nti.nai.abtUid, 4);
|
||||
|
||||
for (key_index = 0; key_index < num_keys; key_index++) {
|
||||
memcpy (mp.mpa.abtKey, keys + (key_index * 6), 6);
|
||||
|
@ -182,7 +182,7 @@ read_card (void)
|
|||
// Show if the readout went well
|
||||
if (bFailure) {
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt)) {
|
||||
printf ("!\nError: tag was removed\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ write_card (void)
|
|||
// Show if the readout went well
|
||||
if (bFailure) {
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt)) {
|
||||
printf ("!\nError: tag was removed\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -447,13 +447,13 @@ main (int argc, const char *argv[])
|
|||
printf ("Connected to NFC reader: %s\n", pnd->acName);
|
||||
|
||||
// Try to find a MIFARE Classic tag
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt)) {
|
||||
printf ("Error: no tag was found\n");
|
||||
nfc_disconnect (pnd);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Test if we are dealing with a MIFARE compatible tag
|
||||
if ((nti.nai.btSak & 0x08) == 0) {
|
||||
if ((nt.nti.nai.btSak & 0x08) == 0) {
|
||||
printf ("Error: tag is not a MIFARE Classic card\n");
|
||||
nfc_disconnect (pnd);
|
||||
exit (EXIT_FAILURE);
|
||||
|
@ -465,14 +465,14 @@ main (int argc, const char *argv[])
|
|||
pbtUID = mtKeys.amb[0].mbm.abtUID;
|
||||
|
||||
// Compare if key dump UID is the same as the current tag UID
|
||||
if (memcmp (nti.nai.abtUid, pbtUID, 4) != 0) {
|
||||
if (memcmp (nt.nti.nai.abtUid, pbtUID, 4) != 0) {
|
||||
printf ("Expected MIFARE Classic %ck card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2],
|
||||
pbtUID[1], pbtUID[0]);
|
||||
}
|
||||
}
|
||||
// Get the info from the current tag
|
||||
pbtUID = nti.nai.abtUid;
|
||||
b4K = (nti.nai.abtAtqa[1] == 0x02);
|
||||
pbtUID = nt.nti.nai.abtUid;
|
||||
b4K = (nt.nti.nai.abtAtqa[1] == 0x02);
|
||||
printf ("Found MIFARE Classic %ck card with UID: %02x%02x%02x%02x\n", b4K ? '4' : '1', pbtUID[3], pbtUID[2],
|
||||
pbtUID[1], pbtUID[0]);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nfc-utils.h"
|
||||
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_target_info_t nti;
|
||||
static nfc_target_t nt;
|
||||
static mifare_param mp;
|
||||
static mifareul_tag mtDump;
|
||||
static uint32_t uiBlocks = 0xF;
|
||||
|
@ -121,7 +121,7 @@ write_card (void)
|
|||
// Show if the readout went well
|
||||
if (bFailure) {
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt)) {
|
||||
ERR ("tag was removed");
|
||||
return false;
|
||||
}
|
||||
|
@ -221,20 +221,20 @@ main (int argc, const char *argv[])
|
|||
printf ("Connected to NFC device: %s\n", pnd->acName);
|
||||
|
||||
// Try to find a MIFARE Ultralight tag
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmMifare, NULL, 0, &nt)) {
|
||||
ERR ("no tag was found\n");
|
||||
nfc_disconnect (pnd);
|
||||
return 1;
|
||||
}
|
||||
// Test if we are dealing with a MIFARE compatible tag
|
||||
|
||||
if (nti.nai.abtAtqa[1] != 0x44) {
|
||||
if (nt.nti.nai.abtAtqa[1] != 0x44) {
|
||||
ERR ("tag is not a MIFARE Ultralight card\n");
|
||||
nfc_disconnect (pnd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Get the info from the current tag (UID is stored little-endian)
|
||||
pbtUID = nti.nai.abtUid;
|
||||
pbtUID = nt.nti.nai.abtUid;
|
||||
printf ("Found MIFARE Ultralight card with UID: %02x%02x%02x%02x\n", pbtUID[3], pbtUID[2], pbtUID[1], pbtUID[0]);
|
||||
|
||||
if (bReadAction) {
|
||||
|
|
|
@ -160,7 +160,7 @@ main (int argc, const char *argv[])
|
|||
|
||||
case WIRED_CARD_MODE:
|
||||
{
|
||||
nfc_target_info_t nti;
|
||||
nfc_target_t nt;
|
||||
|
||||
// Set connected NFC device to initiator mode
|
||||
nfc_initiator_init (pnd);
|
||||
|
@ -185,14 +185,14 @@ main (int argc, const char *argv[])
|
|||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmSAM, NULL, 0, &nti)) {
|
||||
if (!nfc_initiator_select_passive_target (pnd, nmSAM, NULL, 0, &nt)) {
|
||||
nfc_perror (pnd, "nfc_initiator_select_passive_target");
|
||||
ERR ("%s", "Reading of SAM info failed.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf ("The following ISO14443A tag (SAM) was found:\n\n");
|
||||
print_nfc_iso14443a_info (nti.nai);
|
||||
print_nfc_iso14443a_info (nt.nti.nai);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -70,16 +70,16 @@ extern "C" {
|
|||
NFC_EXPORT bool nfc_initiator_init (nfc_device_t * pnd);
|
||||
NFC_EXPORT bool nfc_initiator_select_passive_target (nfc_device_t * pnd, const nfc_modulation_t nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_info_t * pti);
|
||||
nfc_target_t * pnt);
|
||||
NFC_EXPORT bool nfc_initiator_list_passive_targets (nfc_device_t * pnd, const nfc_modulation_t nm,
|
||||
nfc_target_info_t anti[], const size_t szTargets,
|
||||
nfc_target_t ant[], const size_t szTargets,
|
||||
size_t * pszTargetFound);
|
||||
NFC_EXPORT bool nfc_initiator_poll_targets (nfc_device_t * pnd, const nfc_modulation_t * pnmTargetTypes,
|
||||
const size_t szTargetTypes, const byte_t btPollNr, const byte_t btPeriod,
|
||||
nfc_target_t * pntTargets, size_t * pszTargetFound);
|
||||
NFC_EXPORT bool nfc_initiator_select_dep_target (nfc_device_t * pnd, const nfc_dep_mode_t ndm,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_info_t * pti);
|
||||
nfc_target_t * pnt);
|
||||
NFC_EXPORT bool nfc_initiator_deselect_target (nfc_device_t * pnd);
|
||||
NFC_EXPORT bool nfc_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
|
||||
byte_t * pbtRx, size_t * pszRx);
|
||||
|
|
|
@ -482,7 +482,7 @@ bool
|
|||
pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_info_t * pnti)
|
||||
nfc_target_t * pnt)
|
||||
{
|
||||
size_t szTargetsData;
|
||||
byte_t abtTargetsData[MAX_FRAME_LEN];
|
||||
|
@ -496,9 +496,10 @@ pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
return false;
|
||||
|
||||
// Is a tag info struct available
|
||||
if (pnti) {
|
||||
if (pnt) {
|
||||
pnt->nm = nm;
|
||||
// Fill the tag info struct with the values corresponding to this init modulation
|
||||
if (!pn53x_decode_target_data (abtTargetsData + 1, szTargetsData - 1, pnd->nc, nm.nmt, pnti)) {
|
||||
if (!pn53x_decode_target_data (abtTargetsData + 1, szTargetsData - 1, pnd->nc, nm.nmt, &(pnt->nti))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -876,12 +877,12 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
|
|||
bool
|
||||
pn53x_initiator_select_dep_target(nfc_device_t * pnd, const nfc_dep_mode_t ndm,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_info_t * pnti)
|
||||
nfc_target_t * pnt)
|
||||
{
|
||||
if (pndiInitiator) {
|
||||
return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnti);
|
||||
return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnt);
|
||||
} else {
|
||||
return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, NULL, NULL, 0, pnti);
|
||||
return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, NULL, NULL, 0, pnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -893,7 +894,7 @@ pn53x_initiator_select_dep_target(nfc_device_t * pnd, const nfc_dep_mode_t ndm,
|
|||
* @param pbtNFCID3i NFCID3 of the initiator
|
||||
* @param pbtGB General Bytes
|
||||
* @param szGB count of General Bytes
|
||||
* @param[out] pnti nfc_target_info_t which will be filled by this function
|
||||
* @param[out] pnt \a nfc_target_t which will be filled by this function
|
||||
*/
|
||||
bool
|
||||
pn53x_InJumpForDEP (nfc_device_t * pnd,
|
||||
|
@ -901,7 +902,7 @@ pn53x_InJumpForDEP (nfc_device_t * pnd,
|
|||
const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData,
|
||||
const byte_t * pbtNFCID3i,
|
||||
const byte_t * pbtGB, const size_t szGB,
|
||||
nfc_target_info_t * pnti)
|
||||
nfc_target_t * pnt)
|
||||
{
|
||||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
size_t szRx;
|
||||
|
@ -941,19 +942,21 @@ pn53x_InJumpForDEP (nfc_device_t * pnd,
|
|||
if (abtRx[1] != 1)
|
||||
return false;
|
||||
|
||||
// Is a target info struct available
|
||||
if (pnti) {
|
||||
memcpy (pnti->ndi.abtNFCID3, abtRx + 2, 10);
|
||||
pnti->ndi.btDID = abtRx[12];
|
||||
pnti->ndi.btBS = abtRx[13];
|
||||
pnti->ndi.btBR = abtRx[14];
|
||||
pnti->ndi.btTO = abtRx[15];
|
||||
pnti->ndi.btPP = abtRx[16];
|
||||
// Is a target struct available
|
||||
if (pnt) {
|
||||
pnt->nm.nmt = NMT_DEP;
|
||||
pnt->nm.nmt = NBR_UNDEFINED;
|
||||
memcpy (pnt->nti.ndi.abtNFCID3, abtRx + 2, 10);
|
||||
pnt->nti.ndi.btDID = abtRx[12];
|
||||
pnt->nti.ndi.btBS = abtRx[13];
|
||||
pnt->nti.ndi.btBR = abtRx[14];
|
||||
pnt->nti.ndi.btTO = abtRx[15];
|
||||
pnt->nti.ndi.btPP = abtRx[16];
|
||||
if(szRx > 17) {
|
||||
pnti->ndi.szGB = szRx - 17;
|
||||
memcpy (pnti->ndi.abtGB, abtRx + 17, pnti->ndi.szGB);
|
||||
pnt->nti.ndi.szGB = szRx - 17;
|
||||
memcpy (pnt->nti.ndi.abtGB, abtRx + 17, pnt->nti.ndi.szGB);
|
||||
} else {
|
||||
pnti->ndi.szGB = 0;
|
||||
pnt->nti.ndi.szGB = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -168,9 +168,9 @@ bool pn53x_wrap_frame (const byte_t * pbtTx, const size_t szTxBits, const byt
|
|||
size_t * pszFrameBits);
|
||||
bool pn53x_unwrap_frame (const byte_t * pbtFrame, const size_t szFrameBits, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData, nfc_chip_t nc, nfc_modulation_type_t nmt,
|
||||
bool pn53x_decode_target_data (const byte_t * pbtRawData, size_t szRawData,
|
||||
nfc_chip_t nc, nfc_modulation_type_t nmt,
|
||||
nfc_target_info_t * pnti);
|
||||
|
||||
bool pn53x_get_firmware_version (nfc_device_t * pnd);
|
||||
bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool bEnable);
|
||||
|
||||
|
@ -178,14 +178,14 @@ bool pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, cons
|
|||
bool pn53x_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_info_t * pnti);
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_initiator_poll_targets (nfc_device_t * pnd,
|
||||
const nfc_modulation_t * pnmModulations, const size_t szModulations,
|
||||
const byte_t btPollNr, const byte_t btPeriod,
|
||||
nfc_target_t * pntTargets, size_t * pszTargetFound);
|
||||
bool pn53x_initiator_select_dep_target (nfc_device_t * pnd, nfc_dep_mode_t ndm,
|
||||
const nfc_dep_info_t * pndiInitiator,
|
||||
nfc_target_info_t * pnti);
|
||||
nfc_target_t * pnti);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
|
||||
const byte_t * pbtTxPar, byte_t * pbtRx, size_t * pszRxBits,
|
||||
byte_t * pbtRxPar);
|
||||
|
@ -218,7 +218,7 @@ bool pn53x_InJumpForDEP (nfc_device_t * pnd, nfc_dep_mode_t ndm,
|
|||
const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData,
|
||||
const byte_t * pbtNFCID3i,
|
||||
const byte_t * pbtGB, const size_t szGB,
|
||||
nfc_target_info_t * pnti);
|
||||
nfc_target_t * pnt);
|
||||
bool pn53x_TgInitAsTarget (nfc_device_t * pnd, nfc_target_mode_t ntm,
|
||||
const byte_t * pbtMifareParams,
|
||||
const byte_t * pbtFeliCaParams,
|
||||
|
|
35
libnfc/nfc.c
35
libnfc/nfc.c
|
@ -268,23 +268,18 @@ nfc_initiator_init (nfc_device_t * pnd)
|
|||
* @param nm desired modulation
|
||||
* @param pbtInitData optional initiator data used for Felica, ISO14443B, Topaz polling or to select a specific UID in ISO14443A.
|
||||
* @param szInitData length of initiator data \a pbtInitData.
|
||||
* @param[out] pnti \a nfc_target_info_t struct pointer which will filled if available
|
||||
* @param[out] pnt \a nfc_target_t struct pointer which will filled if available
|
||||
*
|
||||
* The NFC device will try to find one available passive tag or emulated tag.
|
||||
*
|
||||
* The chip needs to know with what kind of tag it is dealing with, therefore
|
||||
* the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
|
||||
*
|
||||
* @note For every initial modulation type there is a different collection of
|
||||
* information returned (in nfc_target_info_t pointer pti) They all fit in the
|
||||
* data-type which is called nfc_target_info_t. This is a union which contains
|
||||
* the tag information that belongs to the according initial modulation type.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
const byte_t * pbtInitData, const size_t szInitData,
|
||||
nfc_target_info_t * pnti)
|
||||
nfc_target_t * pnt)
|
||||
{
|
||||
byte_t abtInit[MAX_FRAME_LEN];
|
||||
size_t szInit;
|
||||
|
@ -326,7 +321,7 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
break;
|
||||
}
|
||||
|
||||
return pn53x_initiator_select_passive_target (pnd, nm, abtInit, szInit, pnti);
|
||||
return pn53x_initiator_select_passive_target (pnd, nm, abtInit, szInit, pnt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,8 +330,8 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
*
|
||||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param nm desired modulation
|
||||
* @param[out] anti array of \a nfc_target_info_t that will be filled with targets info
|
||||
* @param szTargets size of \a anti (will be the max targets listed)
|
||||
* @param[out] ant array of \a nfc_target_t that will be filled with targets info
|
||||
* @param szTargets size of \a ant (will be the max targets listed)
|
||||
* @param[out] pszTargetFound pointer where target found counter will be stored
|
||||
*
|
||||
* The NFC device will try to find the available passive tags. Some NFC devices
|
||||
|
@ -345,19 +340,13 @@ nfc_initiator_select_passive_target (nfc_device_t * pnd,
|
|||
* communications. The chip needs to know with what kind of tag it is dealing
|
||||
* with, therefore the initial modulation and speed (106, 212 or 424 kbps)
|
||||
* should be supplied.
|
||||
*
|
||||
* @note For every initial modulation type there is a different collection of
|
||||
* information returned (in \a nfc_target_info_t array \e anti) They all fit in
|
||||
* the data-type which is called nfc_target_info_t. This is a union which
|
||||
* contains the tag information that belongs to the according initial
|
||||
* modulation type.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
||||
const nfc_modulation_t nm,
|
||||
nfc_target_info_t anti[], const size_t szTargets, size_t * pszTargetFound)
|
||||
nfc_target_t ant[], const size_t szTargets, size_t * pszTargetFound)
|
||||
{
|
||||
nfc_target_info_t nti;
|
||||
nfc_target_t nt;
|
||||
size_t szTargetFound = 0;
|
||||
byte_t *pbtInitData = NULL;
|
||||
size_t szInitDataLen = 0;
|
||||
|
@ -385,11 +374,11 @@ nfc_initiator_list_passive_targets (nfc_device_t * pnd,
|
|||
break;
|
||||
}
|
||||
|
||||
while (nfc_initiator_select_passive_target (pnd, nm, pbtInitData, szInitDataLen, &nti)) {
|
||||
while (nfc_initiator_select_passive_target (pnd, nm, pbtInitData, szInitDataLen, &nt)) {
|
||||
nfc_initiator_deselect_target (pnd);
|
||||
|
||||
if (szTargets > szTargetFound) {
|
||||
memcpy (&(anti[szTargetFound]), &nti, sizeof (nfc_target_info_t));
|
||||
memcpy (&(ant[szTargetFound]), &nt, sizeof (nfc_target_t));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -436,7 +425,7 @@ nfc_initiator_poll_targets (nfc_device_t * pnd,
|
|||
* @param pnd \a nfc_device_t struct pointer that represent currently used device
|
||||
* @param ndm desired D.E.P. mode (\a NDM_ACTIVE or \a NDM_PASSIVE for active, respectively passive mode)
|
||||
* @param ndiInitiator pointer \a nfc_dep_info_t struct that contains \e NFCID3 and \e General \e Bytes to set to the initiator device (optionnal, can be \e NULL)
|
||||
* @param[out] pnti is a \a nfc_target_info_t struct pointer where target information will be put.
|
||||
* @param[out] pnt is a \a nfc_target_t struct pointer where target information will be put.
|
||||
*
|
||||
* The NFC device will try to find an available D.E.P. target. The standards
|
||||
* (ISO18092 and ECMA-340) describe the modulation that can be used for reader
|
||||
|
@ -445,11 +434,11 @@ nfc_initiator_poll_targets (nfc_device_t * pnd,
|
|||
* @note \a nfc_dep_info_t will be returned when the target was acquired successfully.
|
||||
*/
|
||||
bool
|
||||
nfc_initiator_select_dep_target (nfc_device_t * pnd, const nfc_dep_mode_t ndm, const nfc_dep_info_t * pndiInitiator, nfc_target_info_t * pnti)
|
||||
nfc_initiator_select_dep_target (nfc_device_t * pnd, const nfc_dep_mode_t ndm, const nfc_dep_info_t * pndiInitiator, nfc_target_t * pnt)
|
||||
{
|
||||
pnd->iLastError = 0;
|
||||
|
||||
return pn53x_initiator_select_dep_target (pnd, ndm, pndiInitiator, pnti);
|
||||
return pn53x_initiator_select_dep_target (pnd, ndm, pndiInitiator, pnt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ test_access_storm (void)
|
|||
|
||||
for (i = 0; i < device_count; i++) {
|
||||
nfc_device_t *device;
|
||||
nfc_target_info_t anti[MAX_TARGET_COUNT];
|
||||
nfc_target_t ant[MAX_TARGET_COUNT];
|
||||
|
||||
device = nfc_connect (&(devices[i]));
|
||||
cut_assert_not_null (device, cut_message ("nfc_connect"));
|
||||
|
@ -60,7 +60,7 @@ test_access_storm (void)
|
|||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
res = nfc_initiator_list_passive_targets(device, nm, anti, MAX_TARGET_COUNT, &target_count);
|
||||
res = nfc_initiator_list_passive_targets(device, nm, ant, MAX_TARGET_COUNT, &target_count);
|
||||
cut_assert_true (res, cut_message ("nfc_initiator_list_passive_targets"));
|
||||
|
||||
nfc_disconnect (device);
|
||||
|
|
Loading…
Add table
Reference in a new issue