diff options
author | Arnaud Ferir <arnaud.ferir@trusted-logic.com> | 2010-12-15 11:55:06 +0100 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2011-01-18 13:07:22 -0800 |
commit | 1ec4ace9cd3079abd7c0b30d0976591c8c0f441e (patch) | |
tree | 5139f41b69cafae52c69f9e4de0a7a2f9b1cde34 | |
parent | 2cabc1d1656f6072bee0e43504cda869336fc390 (diff) | |
download | external_libnfc-nxp-1ec4ace9cd3079abd7c0b30d0976591c8c0f441e.zip external_libnfc-nxp-1ec4ace9cd3079abd7c0b30d0976591c8c0f441e.tar.gz external_libnfc-nxp-1ec4ace9cd3079abd7c0b30d0976591c8c0f441e.tar.bz2 |
Call the LLCP send callback in error cases.
This avoids an application to be stuck in a send request while the
LLCP link has been lost (i.e. remote peer lost).
Change-Id: I74982d497c410ae4bdb466afac013efc9eb17b03
-rw-r--r-- | src/phFriNfc_Llcp.c | 21 | ||||
-rw-r--r-- | src/phFriNfc_LlcpTransport_Connection.c | 5 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/phFriNfc_Llcp.c b/src/phFriNfc_Llcp.c index cfbda3a..ab9b768 100644 --- a/src/phFriNfc_Llcp.c +++ b/src/phFriNfc_Llcp.c @@ -143,6 +143,8 @@ static void phFriNfc_Llcp_Deallocate(phNfc_sData_t * pData) static NFCSTATUS phFriNfc_Llcp_InternalDeactivate( phFriNfc_Llcp_t *Llcp ) { + phFriNfc_Llcp_Send_CB_t pfSendCB; + void * pSendContext; if ((Llcp->state == PHFRINFC_LLCP_STATE_OPERATION_RECV) || (Llcp->state == PHFRINFC_LLCP_STATE_OPERATION_SEND) || (Llcp->state == PHFRINFC_LLCP_STATE_PAX) || @@ -154,6 +156,25 @@ static NFCSTATUS phFriNfc_Llcp_InternalDeactivate( phFriNfc_Llcp_t *Llcp ) /* Stop timer */ phOsalNfc_Timer_Stop(Llcp->hSymmTimer); + /* Return delayed send operation in error, in any */ + if (Llcp->psSendInfo != NULL) + { + phFriNfc_Llcp_Deallocate(Llcp->psSendInfo); + Llcp->psSendHeader = NULL; + Llcp->psSendSequence = NULL; + } + if (Llcp->pfSendCB != NULL) + { + /* Get Callback params */ + pfSendCB = Llcp->pfSendCB; + pSendContext = Llcp->pSendContext; + /* Reset callback params */ + Llcp->pfSendCB = NULL; + Llcp->pSendContext = NULL; + /* Call the callback */ + (pfSendCB)(pSendContext, NFCSTATUS_FAILED); + } + /* Notify service layer */ Llcp->pfLink_CB(Llcp->pLinkContext, phFriNfc_LlcpMac_eLinkDeactivated); diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c index 2056f45..fbe2dec 100644 --- a/src/phFriNfc_LlcpTransport_Connection.c +++ b/src/phFriNfc_LlcpTransport_Connection.c @@ -325,6 +325,11 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p else { /* Send CB error */ + if(psTransport->pSocketTable[psTransport->socketIndex].sLlcpHeader.ptype == PHFRINFC_LLCP_PTYPE_I && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL) + { + psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb(psTransport->pSocketTable[psTransport->socketIndex].pSendContext,status); + psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb = NULL; + } } } |