NFC Stack: ISO7816 now uses the 'repolling' mechanism of ISODEP module to avoid re-running a full polling loop

pull/7822/head
Donatien Garnier 2018-08-23 11:59:55 +01:00
parent e7b2ec347f
commit 1f1f5f183f
5 changed files with 17 additions and 4 deletions

View File

@ -18,7 +18,7 @@
#ifndef MBED_NFC_DEBUG_H
#define MBED_NFC_DEBUG_H
#if NFC_DEBUG && !defined(NDEBUG)
#if NFC_DEBUG && !defined(NDEBUG) && __DEBUG__
#ifdef __MODULE__
#define __NFC_MODULE__ __MODULE__
#else

View File

@ -120,7 +120,9 @@ void iso7816_disconnected(nfc_tech_iso7816_t *pIso7816, bool deselected)
pIso7816->pSelectedApp->deselected(pIso7816->pSelectedApp, pIso7816->pSelectedApp->pUserData);
pIso7816->pSelectedApp = NULL;
}
pIso7816->disconnectedCb(pIso7816, deselected, pIso7816->pUserData);
if (!deselected) {
pIso7816->disconnectedCb(pIso7816, pIso7816->pUserData);
}
}
nfc_err_t iso7816_parse(nfc_tech_iso7816_t *pIso7816)
@ -299,8 +301,13 @@ void iso_dep_disconnected_cb(nfc_tech_isodep_t *pIsodep, bool deselected, void *
(void) pIsodep;
NFC_DBG("ISO DEP disconnected");
NFC_DBG("ISO DEP %s", deselected ? "deselected" : "disconnected");
iso7816_disconnected(pIso7816, deselected);
if (deselected) {
// Re-connect immediately
nfc_tech_iso7816_connect(pIso7816);
}
}
void iso_dep_stream_transmit_cb(ac_buffer_t *pDataIn, bool *pClose, size_t maxLength, void *pUserParam)

View File

@ -53,7 +53,7 @@ typedef struct nfc_tech_iso7816_r_apdu nfc_tech_iso7816_r_apdu_t;
typedef struct nfc_tech_iso7816 nfc_tech_iso7816_t;
typedef void (*nfc_tech_iso7816_disconnected_cb)(nfc_tech_iso7816_t *pIso7816, bool deselected, void *pUserData);
typedef void (*nfc_tech_iso7816_disconnected_cb)(nfc_tech_iso7816_t *pIso7816, void *pUserData);
struct nfc_tech_iso7816_app;
typedef struct nfc_tech_iso7816_app nfc_tech_iso7816_app_t;

View File

@ -607,6 +607,7 @@ void command_transceiver_cb(nfc_transceiver_t *pTransceiver, nfc_err_t ret, void
}
if (pIsodepTarget->dep.frameState == ISO_DEP_TARGET_DEP_FRAME_DESELECT_SENT) {
NFC_DBG("Deselect sent and re-polled: %u", ret);
//We are now disconnected (deselected)
//Reset status
dep_init(pIsodepTarget);

View File

@ -945,6 +945,11 @@ void pn512_poll_iteration(pn512_t *pPN512, nfc_err_t ret)
pPN512->poll.state = pn512_polling_state_listen_wait_for_remote_field;
// Shortcut if target is halted (means RF field is still here)
if (pn512_register_read(pPN512, PN512_REG_MIFNFC) & 0x04) {
continue;
}
// Fix for PN512 bug that sometimes detects its own RF field
// if(pPN512->rf_on)
{