Fix a couple of bugs that occur when NFC tag reset fails.

1. In the NfcCxSequence class, fix an issue where synchronous completion
of a sequence isn't handled correctly.

2. Fix an issue where if tag activation fails, the driver will not be
able to exit RF discovery mode. This prevents NFC from working until the
driver is restarted.
This commit is contained in:
Chris Gunn 2019-01-02 14:13:57 -08:00
Родитель 18907d656d
Коммит 8d9a463980
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -93,6 +93,7 @@ Return Value:
if (sequenceStatus != STATUS_PENDING)
{
// The sequence handler completed synchronously (success or failure).
// Defer the completed handler to avoid reentrancy issues.
TRACE_LINE(LEVEL_INFO, "Sequence handler completed synchronously. Deferring complete function. %!STATUS!", sequenceStatus);
// Ensure that the complete function is called when the sequence is next resumed.
@ -101,6 +102,8 @@ Return Value:
// Queue the sequence handler.
NfcCxSequenceDispatchResume(RFInterface, sequence, sequenceStatus, Param1, Param2);
// Sequence will complete asynchronously.
status = STATUS_PENDING;
goto Done;
}

Просмотреть файл

@ -1485,14 +1485,18 @@ NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemot
void* pContext
)
{
// NOTE:
// If a tag ever fails to activate, then the NFC Controller will trigger the CORE_GENERIC_ERROR_NTF event
// with DISCOVERY_TARGET_ACTIVATION_FAILED error code. If this happens, this function must still be
// invoked so that the RF_DEACTIVATE_CMD command is issued, which will place the NFC Controller back in
// the RFST_IDLE state.
NFCSTATUS wRetVal = NFCSTATUS_SUCCESS;
pphNciNfc_RemoteDevInformation_t pNciRemoteDevInfo;
pphNciNfc_RemoteDevInformation_t pNciRemoteDevHandle;
phLibNfc_Event_t TrigEvent = phLibNfc_EventDeActivate;
phLibNfc_sRemoteDevInformation_t *pLibRemoteDevHandle;
pphLibNfc_Context_t pLibContext = phLibNfc_GetContext();
phNfc_eDiscAndDisconnMode_t DisconnType;
void* param1 = NULL;
PH_LOG_LIBNFC_FUNC_ENTRY();
wRetVal = phLibNfc_IsInitialised(pLibContext);
@ -1510,8 +1514,9 @@ NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemot
{
wRetVal= NFCSTATUS_SHUTDOWN;
}
else if(pLibContext->Connected_handle==0)
else if(pLibContext->Connected_handle == NULL && ReleaseType == NFC_DEVICE_SLEEP)
{
// The caller is asking for the current tag to be deactivated (sleep) but there isn't a connected tag.
PH_LOG_LIBNFC_CRIT_STR("Target not connected");
wRetVal = NFCSTATUS_TARGET_NOT_CONNECTED;
}
@ -1542,6 +1547,8 @@ NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemot
}
else
{
phLibNfc_Event_t TrigEvent = phLibNfc_EventDeActivate;
/* Map actual release type to internal release type */
switch(ReleaseType)
{
@ -1595,7 +1602,7 @@ NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemot
wRetVal = phLibNfc_StateHandler(pLibContext,
TrigEvent,
(void *)DisconnType,
param1,
NULL,
NULL);
if( NFCSTATUS_PENDING == PHNFCSTATUS(wRetVal))