DEP enhancements:
- Add timeout on InJumpForDEP (pn53x) and initiator_select_dep (libnfc API) - test_dep now works again (except 424Kbps) - Fix ndi.ndm feeling when select a DEP target Important: test_dep does not work on PN53x_USB devices after running previous tests
This commit is contained in:
parent
3b657ee547
commit
c286eec920
8 changed files with 123 additions and 47 deletions
|
|
@ -1038,7 +1038,8 @@ bool
|
|||
pn53x_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)
|
||||
nfc_target *pnt,
|
||||
const int timeout)
|
||||
{
|
||||
const uint8_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x00 }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number)
|
||||
const uint8_t * pbtPassiveInitiatorData = NULL;
|
||||
|
|
@ -1056,9 +1057,9 @@ pn53x_initiator_select_dep_target(nfc_device *pnd,
|
|||
}
|
||||
|
||||
if (pndiInitiator) {
|
||||
return pn53x_InJumpForDEP (pnd, ndm, nbr, pbtPassiveInitiatorData, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnt);
|
||||
return pn53x_InJumpForDEP (pnd, ndm, nbr, pbtPassiveInitiatorData, pndiInitiator->abtNFCID3, pndiInitiator->abtGB, pndiInitiator->szGB, pnt, timeout);
|
||||
} else {
|
||||
return pn53x_InJumpForDEP (pnd, ndm, nbr, pbtPassiveInitiatorData, NULL, NULL, 0, pnt);
|
||||
return pn53x_InJumpForDEP (pnd, ndm, nbr, pbtPassiveInitiatorData, NULL, NULL, 0, pnt, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2199,7 +2200,8 @@ pn53x_InJumpForDEP (nfc_device *pnd,
|
|||
const uint8_t *pbtPassiveInitiatorData,
|
||||
const uint8_t *pbtNFCID3i,
|
||||
const uint8_t *pbtGBi, const size_t szGBi,
|
||||
nfc_target *pnt)
|
||||
nfc_target *pnt,
|
||||
const int timeout)
|
||||
{
|
||||
// Max frame size = 1 (Command) + 1 (ActPass) + 1 (Baud rate) + 1 (Next) + 5 (PassiveInitiatorData) + 10 (NFCID3) + 48 (General bytes) = 67 bytes
|
||||
uint8_t abtCmd[67] = { InJumpForDEP, (ndm == NDM_ACTIVE) ? 0x01 : 0x00 };
|
||||
|
|
@ -2259,7 +2261,7 @@ pn53x_InJumpForDEP (nfc_device *pnd,
|
|||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
// Try to find a target, call the transceive callback function of the current device
|
||||
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, 0))
|
||||
if (!pn53x_transceive (pnd, abtCmd, offset, abtRx, &szRx, timeout))
|
||||
return false;
|
||||
|
||||
// Make sure one target has been found, the PN53X returns 0x00 if none was available
|
||||
|
|
@ -2270,6 +2272,7 @@ pn53x_InJumpForDEP (nfc_device *pnd,
|
|||
if (pnt) {
|
||||
pnt->nm.nmt = NMT_DEP;
|
||||
pnt->nm.nbr = nbr;
|
||||
pnt->nti.ndi.ndm = ndm;
|
||||
memcpy (pnt->nti.ndi.abtNFCID3, abtRx + 2, 10);
|
||||
pnt->nti.ndi.btDID = abtRx[12];
|
||||
pnt->nti.ndi.btBS = abtRx[13];
|
||||
|
|
|
|||
|
|
@ -287,7 +287,8 @@ bool pn53x_initiator_poll_target (nfc_device *pnd,
|
|||
bool pn53x_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);
|
||||
nfc_target *pnt,
|
||||
const int timeout);
|
||||
bool pn53x_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits,
|
||||
const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits,
|
||||
uint8_t *pbtRxPar);
|
||||
|
|
@ -328,7 +329,8 @@ bool pn53x_InJumpForDEP (nfc_device *pnd,
|
|||
const uint8_t *pbtPassiveInitiatorData,
|
||||
const uint8_t *pbtNFCID3i,
|
||||
const uint8_t *pbtGB, const size_t szGB,
|
||||
nfc_target *pnt);
|
||||
nfc_target *pnt,
|
||||
const int timeout);
|
||||
bool pn53x_TgInitAsTarget (nfc_device *pnd, pn53x_target_mode ptm,
|
||||
const uint8_t *pbtMifareParams,
|
||||
const uint8_t *pbtTkt, size_t szTkt,
|
||||
|
|
|
|||
|
|
@ -571,6 +571,7 @@ read:
|
|||
if (timeout == USB_INFINITE_TIMEOUT) {
|
||||
usb_timeout = USB_TIMEOUT_PER_PASS;
|
||||
} else {
|
||||
// A user-provided timeout is set, we have to cut it in multiple chunk to be able to keep an nfc_abort_command() mecanism
|
||||
remaining_time -= USB_TIMEOUT_PER_PASS;
|
||||
if (remaining_time <= 0) {
|
||||
pnd->iLastError = ECOMTIMEOUT;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ struct nfc_driver_t {
|
|||
bool (*initiator_init) (nfc_device *pnd);
|
||||
bool (*initiator_select_passive_target) (nfc_device *pnd, const nfc_modulation nm, const uint8_t * pbtInitData, const size_t szInitData, nfc_target * pnt);
|
||||
bool (*initiator_poll_target) (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) (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt);
|
||||
bool (*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);
|
||||
bool (*initiator_deselect_target) (nfc_device *pnd);
|
||||
bool (*initiator_transceive_bytes) (nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
bool (*initiator_transceive_bits) (nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar);
|
||||
|
|
|
|||
|
|
@ -432,9 +432,9 @@ nfc_initiator_poll_target (nfc_device *pnd,
|
|||
bool
|
||||
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 nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout)
|
||||
{
|
||||
HAL (initiator_select_dep_target, pnd, ndm, nbr, pndiInitiator, pnt);
|
||||
HAL (initiator_select_dep_target, pnd, ndm, nbr, pndiInitiator, pnt, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue