nfc_initiator_select_dep_target() function returns nox libnf error code and fix some uses of nfc_initiator_transceive_bytes() function.

This commit is contained in:
Audrey Diacre 2011-12-21 09:15:44 +00:00
parent 0f5cc5683d
commit c41d7de8ca
12 changed files with 58 additions and 57 deletions

View file

@ -1082,7 +1082,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
return NFC_ECHIP;
}
bool
int
pn53x_initiator_select_dep_target(struct nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator,
@ -2243,7 +2243,7 @@ pn53x_InAutoPoll (struct nfc_device *pnd,
* @param szGBi count of General Bytes
* @param[out] pnt \a nfc_target which will be filled by this function
*/
bool
int
pn53x_InJumpForDEP (struct nfc_device *pnd,
const nfc_dep_mode ndm,
const nfc_baud_rate nbr,
@ -2271,7 +2271,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
case NBR_847:
case NBR_UNDEFINED:
pnd->last_error = NFC_EINVARG;
return false;
return pnd->last_error;
break;
}
@ -2291,7 +2291,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
case NBR_847:
case NBR_UNDEFINED:
pnd->last_error = NFC_EINVARG;
return false;
return pnd->last_error;
break;
}
}
@ -2310,13 +2310,14 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
size_t szRx = sizeof (abtRx);
int res = 0;
// Try to find a target, call the transceive callback function of the current device
if (pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, timeout) < 0)
return false;
if ((res = pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, timeout)) < 0)
return res;
// Make sure one target has been found, the PN53X returns 0x00 if none was available
if (abtRx[1] != 1)
return false;
return NFC_ECHIP;
// Is a target struct available
if (pnt) {
@ -2336,7 +2337,7 @@ pn53x_InJumpForDEP (struct nfc_device *pnd,
pnt->nti.ndi.szGB = 0;
}
}
return true;
return NFC_SUCCESS;
}
int

View file

@ -294,7 +294,7 @@ int pn53x_initiator_poll_target (struct nfc_device *pnd,
const nfc_modulation *pnmModulations, const size_t szModulations,
const uint8_t uiPollNr, const uint8_t uiPeriod,
nfc_target *pnt);
bool pn53x_initiator_select_dep_target (struct nfc_device *pnd,
int pn53x_initiator_select_dep_target (struct nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator,
nfc_target *pnt,
@ -335,7 +335,7 @@ int pn53x_InAutoPoll (struct nfc_device *pnd, const pn53x_target_type *ppttTa
const uint8_t btPollNr, const uint8_t btPeriod, nfc_target *pntTargets,
size_t *pszTargetFound,
const int timeout);
bool pn53x_InJumpForDEP (struct nfc_device *pnd,
int pn53x_InJumpForDEP (struct nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const uint8_t *pbtPassiveInitiatorData,
const uint8_t *pbtNFCID3i,

View file

@ -135,7 +135,7 @@ struct nfc_driver_t {
int (*initiator_init) (struct nfc_device *pnd);
int (*initiator_select_passive_target) (struct nfc_device *pnd, const nfc_modulation nm, const uint8_t * pbtInitData, const size_t szInitData, nfc_target * pnt);
int (*initiator_poll_target) (struct nfc_device *pnd, const nfc_modulation * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target * pnt);
bool (*initiator_select_dep_target) (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout);
int (*initiator_select_dep_target) (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout);
bool (*initiator_deselect_target) (struct nfc_device *pnd);
int (*initiator_transceive_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout);
bool (*initiator_transceive_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);

View file

@ -433,7 +433,7 @@ nfc_initiator_poll_target (nfc_device *pnd,
/**
* @brief Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
* @return Returns 0 on success, otherwise returns libnfc's error code (negative value).
*
* @param pnd \a nfc_device 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)
@ -446,7 +446,7 @@ nfc_initiator_poll_target (nfc_device *pnd,
*
* @note \a nfc_dep_info will be returned when the target was acquired successfully.
*/
bool
int
nfc_initiator_select_dep_target (nfc_device *pnd,
const nfc_dep_mode ndm, const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout)