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:
Romuald Conty 2010-10-14 11:44:43 +00:00
parent 6f3fbcb6bf
commit af88da1a9c
10 changed files with 76 additions and 85 deletions

View file

@ -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;

View file

@ -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,