nfc_target_receive_bytes() function returns now received bytes count on success and libnfc error code on failure.
This commit is contained in:
parent
a40e63ab9d
commit
ac6f652368
11 changed files with 35 additions and 35 deletions
|
|
@ -1779,7 +1779,7 @@ pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
int
|
||||
pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout)
|
||||
{
|
||||
uint8_t abtCmd[1];
|
||||
|
|
@ -1801,7 +1801,7 @@ pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszR
|
|||
} else {
|
||||
// TODO Support EasyFraming for other cases by software
|
||||
pnd->last_error = NFC_ENOTIMPL;
|
||||
return false;
|
||||
return pnd->last_error;
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
@ -1816,7 +1816,7 @@ pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszR
|
|||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
if (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, timeout) < 0)
|
||||
return false;
|
||||
return pnd->last_error;
|
||||
|
||||
// Save the received byte count
|
||||
*pszRx = szRx - 1;
|
||||
|
|
@ -1825,7 +1825,7 @@ pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszR
|
|||
memcpy (pbtRx, abtRx + 1, *pszRx);
|
||||
|
||||
// Everyting seems ok, return true
|
||||
return true;
|
||||
return *pszRx;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ int pn53x_initiator_deselect_target (struct nfc_device *pnd);
|
|||
// NFC device as Target functions
|
||||
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx);
|
||||
bool pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
|
||||
bool pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
int pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
bool pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
bool pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ nfc_emulate_target (nfc_device *pnd, struct nfc_emulator *emulator)
|
|||
}
|
||||
}
|
||||
if (res >= 0) {
|
||||
if (!nfc_target_receive_bytes(pnd, abtRx, &szRx, 0)) {
|
||||
if (nfc_target_receive_bytes(pnd, abtRx, &szRx, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ struct nfc_driver_t {
|
|||
|
||||
int (*target_init) (struct nfc_device *pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx);
|
||||
bool (*target_send_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
bool (*target_receive_bytes) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
int (*target_receive_bytes) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool (*target_send_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
|
||||
bool (*target_receive_bits) (struct nfc_device *pnd, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
|
||||
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
|||
|
||||
/**
|
||||
* @brief Receive bytes and APDU frames
|
||||
* @return Returns \c true if action was successfully performed; otherwise returns \c false.
|
||||
* @return Returns received bytes count on success, otherwise returns libnfc's error code
|
||||
*
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param[out] pbtRx pointer to Rx buffer
|
||||
|
|
@ -728,7 +728,7 @@ nfc_target_send_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx,
|
|||
* If timeout is not a null pointer, it specifies the maximum interval to wait for the function to be executed.
|
||||
* If timeout is a null pointer, the function blocks indefinitely (until an error is raised or function is completed).
|
||||
*/
|
||||
bool
|
||||
int
|
||||
nfc_target_receive_bytes (nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout)
|
||||
{
|
||||
HAL (target_receive_bytes, pnd, pbtRx, pszRx, timeout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue