introduce nfc_dep_mode_t type instead of bool in nfc_initiator_select_dep_target()

This commit is contained in:
Romuald Conty 2010-10-13 19:59:39 +00:00
parent 124cc28bac
commit adba90684d
4 changed files with 20 additions and 10 deletions

View file

@ -62,7 +62,7 @@ main (int argc, const char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(!nfc_initiator_select_dep_target (pnd, false, NULL, &nti)) { if(!nfc_initiator_select_dep_target (pnd, NDM_PASSIVE, NULL, &nti)) {
nfc_perror(pnd, "nfc_initiator_select_dep_target"); nfc_perror(pnd, "nfc_initiator_select_dep_target");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View file

@ -167,7 +167,7 @@ typedef enum {
/** /**
* @struct nfc_dep_info_t * @struct nfc_dep_info_t
* @brief NFC tag information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 * @brief NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1)
*/ */
typedef struct { typedef struct {
/** NFCID3 */ /** NFCID3 */
@ -187,6 +187,15 @@ typedef struct {
size_t szGB; size_t szGB;
} nfc_dep_info_t; } nfc_dep_info_t;
/**
* @enum nfc_dep_mode_t
* @brief NFC D.E.P. (Data Exchange Protocol) active/passive mode
*/
typedef enum {
NDM_PASSIVE,
NDM_ACTIVE,
} nfc_dep_mode_t;
/** /**
* @struct nfc_iso14443a_info_t * @struct nfc_iso14443a_info_t
* @brief NFC ISO14443A tag (MIFARE) information * @brief NFC ISO14443A tag (MIFARE) information

View file

@ -868,14 +868,14 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
} }
bool bool
pn53x_initiator_select_dep_target(nfc_device_t * pnd, const bool bActiveDep, pn53x_initiator_select_dep_target(nfc_device_t * pnd, const nfc_dep_mode_t ndm,
const nfc_dep_info_t * pndiInitiator, const nfc_dep_info_t * pndiInitiator,
nfc_target_info_t * pnti) nfc_target_info_t * pnti)
{ {
if (pndiInitiator) { if (pndiInitiator) {
return pn53x_InJumpForDEP (pnd, bActiveDep, NULL, 0, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnti); return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnti);
} else { } else {
return pn53x_InJumpForDEP (pnd, bActiveDep, NULL, 0, NULL, NULL, 0, pnti); return pn53x_InJumpForDEP (pnd, ndm, NULL, 0, NULL, NULL, 0, pnti);
} }
} }
@ -890,7 +890,8 @@ pn53x_initiator_select_dep_target(nfc_device_t * pnd, const bool bActiveDep,
* @param[out] pnti nfc_target_info_t which will be filled by this function * @param[out] pnti nfc_target_info_t which will be filled by this function
*/ */
bool bool
pn53x_InJumpForDEP (nfc_device_t * pnd, const bool bActiveDep, pn53x_InJumpForDEP (nfc_device_t * pnd,
const nfc_dep_mode_t ndm,
const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData, const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData,
const byte_t * pbtNFCID3i, const byte_t * pbtNFCID3i,
const byte_t * pbtGB, const size_t szGB, const byte_t * pbtGB, const size_t szGB,
@ -903,13 +904,13 @@ pn53x_InJumpForDEP (nfc_device_t * pnd, const bool bActiveDep,
memcpy (abtCmd, pncmd_initiator_jump_for_dep, sizeof (pncmd_initiator_jump_for_dep)); memcpy (abtCmd, pncmd_initiator_jump_for_dep, sizeof (pncmd_initiator_jump_for_dep));
abtCmd[2] = (bActiveDep) ? 0x01 : 0x00; abtCmd[2] = (ndm == NDM_ACTIVE) ? 0x01 : 0x00;
// FIXME Baud rate in D.E.P. mode is hard-wired as 106kbps // FIXME Baud rate in D.E.P. mode is hard-wired as 106kbps
abtCmd[3] = 0x00; /* baud rate = 106kbps */ abtCmd[3] = 0x00; /* baud rate = 106kbps */
offset = 5; offset = 5;
if (pbtPassiveInitiatorData && !bActiveDep) { /* can't have passive initiator data when using active mode */ if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { /* can't have passive initiator data when using active mode */
abtCmd[4] |= 0x01; abtCmd[4] |= 0x01;
memcpy (abtCmd + offset, pbtPassiveInitiatorData, szPassiveInitiatorData); memcpy (abtCmd + offset, pbtPassiveInitiatorData, szPassiveInitiatorData);
offset += szPassiveInitiatorData; offset += szPassiveInitiatorData;

View file

@ -183,7 +183,7 @@ bool pn53x_initiator_poll_targets (nfc_device_t * pnd,
const nfc_modulation_t * pnmModulations, const size_t szModulations, const nfc_modulation_t * pnmModulations, const size_t szModulations,
const byte_t btPollNr, const byte_t btPeriod, const byte_t btPollNr, const byte_t btPeriod,
nfc_target_t * pntTargets, size_t * pszTargetFound); nfc_target_t * pntTargets, size_t * pszTargetFound);
bool pn53x_initiator_select_dep_target (nfc_device_t * pnd, const bool bActiveDep, bool pn53x_initiator_select_dep_target (nfc_device_t * pnd, nfc_dep_mode_t ndm,
const nfc_dep_info_t * pndiInitiator, const nfc_dep_info_t * pndiInitiator,
nfc_target_info_t * pnti); nfc_target_info_t * pnti);
bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits, bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,
@ -214,7 +214,7 @@ bool pn53x_InRelease (nfc_device_t * pnd, const uint8_t ui8Target);
bool pn53x_InAutoPoll (nfc_device_t * pnd, const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes, bool pn53x_InAutoPoll (nfc_device_t * pnd, const pn53x_target_type_t * ppttTargetTypes, const size_t szTargetTypes,
const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets, const byte_t btPollNr, const byte_t btPeriod, nfc_target_t * pntTargets,
size_t * pszTargetFound); size_t * pszTargetFound);
bool pn53x_InJumpForDEP (nfc_device_t * pnd, const bool bActiveDep, bool pn53x_InJumpForDEP (nfc_device_t * pnd, nfc_dep_mode_t ndm,
const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData, const byte_t * pbtPassiveInitiatorData, const size_t szPassiveInitiatorData,
const byte_t * pbtNFCID3i, const byte_t * pbtNFCID3i,
const byte_t * pbtGB, const size_t szGB, const byte_t * pbtGB, const size_t szGB,