add timeout on nfc_target_init() and this function returns now received bytes count on success.
This commit is contained in:
parent
c80ebdca25
commit
239fd750c4
14 changed files with 22 additions and 21 deletions
|
|
@ -1589,7 +1589,7 @@ pn53x_initiator_deselect_target (struct nfc_device *pnd)
|
|||
#define SAK_ISO14443_4_COMPLIANT 0x20
|
||||
#define SAK_ISO18092_COMPLIANT 0x40
|
||||
int
|
||||
pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx)
|
||||
pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout)
|
||||
{
|
||||
pn53x_reset_settings(pnd);
|
||||
|
||||
|
|
@ -1742,7 +1742,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
|
|||
while (!targetActivated) {
|
||||
uint8_t btActivatedMode;
|
||||
|
||||
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, pszRx, &btActivatedMode)) < 0) {
|
||||
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, pszRx, &btActivatedMode, timeout)) < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -1807,7 +1807,7 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
|
|||
}
|
||||
}
|
||||
|
||||
return NFC_SUCCESS;
|
||||
return *pszRx;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -2420,7 +2420,7 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
|
|||
const uint8_t *pbtTkt, size_t szTkt,
|
||||
const uint8_t *pbtFeliCaParams,
|
||||
const uint8_t *pbtNFCID3t, const uint8_t *pbtGBt, const size_t szGBt,
|
||||
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte)
|
||||
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte, int timeout)
|
||||
{
|
||||
uint8_t abtCmd[39 + 47 + 48] = { TgInitAsTarget }; // Worst case: 39-byte base, 47 bytes max. for General Bytes, 48 bytes max. for Historical Bytes
|
||||
size_t szOptionalBytes = 0;
|
||||
|
|
@ -2469,7 +2469,7 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
|
|||
// Request the initialization as a target
|
||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
if ((res = pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, -1)) < 0)
|
||||
if ((res = pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx, timeout)) < 0)
|
||||
return res;
|
||||
|
||||
// Note: the first byte is skip:
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ int pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uin
|
|||
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);
|
||||
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar);
|
||||
int pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
int pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
|
|
@ -342,7 +342,7 @@ int pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
|
|||
const uint8_t *pbtTkt, size_t szTkt,
|
||||
const uint8_t *pbtFeliCaParams,
|
||||
const uint8_t *pbtNFCID3t, const uint8_t *pbtGB, const size_t szGB,
|
||||
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte);
|
||||
uint8_t *pbtRx, size_t *pszRx, uint8_t *pbtModeByte, int timeout);
|
||||
|
||||
// RFConfiguration
|
||||
int pn53x_RFConfiguration__RF_field (struct nfc_device *pnd, bool bEnable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue