From 35a9f321a9cb5db0e65b9579d11bee2ac9bb1c54 Mon Sep 17 00:00:00 2001 From: Sylvain Fonteneau Date: Thu, 9 Dec 2010 17:57:08 +0100 Subject: Fix missing send callback in error upon deactivation. Change-Id: I2a857c4e02fcf8c0f655a6fa960466f5ac4f191e --- src/phFriNfc_LlcpMacNfcip.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/phFriNfc_LlcpMacNfcip.c') diff --git a/src/phFriNfc_LlcpMacNfcip.c b/src/phFriNfc_LlcpMacNfcip.c index f4e069d..a0fad6c 100644 --- a/src/phFriNfc_LlcpMacNfcip.c +++ b/src/phFriNfc_LlcpMacNfcip.c @@ -91,6 +91,9 @@ static NFCSTATUS phFriNfc_LlcpMac_Nfcip_Activate (phFriNfc_LlcpMac_t *LlcpMac) static NFCSTATUS phFriNfc_LlcpMac_Nfcip_Deactivate (phFriNfc_LlcpMac_t *LlcpMac) { NFCSTATUS status = NFCSTATUS_SUCCESS; + phFriNfc_LlcpMac_Send_CB_t pfSendCB; + phFriNfc_LlcpMac_Reveive_CB_t pfRecvCB; + void *pContext; if(NULL == LlcpMac) { @@ -102,6 +105,40 @@ static NFCSTATUS phFriNfc_LlcpMac_Nfcip_Deactivate (phFriNfc_LlcpMac_t *LlcpMa LlcpMac->LinkState = phFriNfc_LlcpMac_eLinkDeactivated; } + if (LlcpMac->SendPending) + { + /* Reset Flag */ + LlcpMac->SendPending = FALSE; + + /* Save context in local variables */ + pfSendCB = LlcpMac->MacSend_Cb; + pContext = LlcpMac->MacSend_Context; + + /* Reset the pointer to the Send Callback */ + LlcpMac->MacSend_Cb = NULL; + LlcpMac->MacSend_Context = NULL; + + /* Call Send callback */ + pfSendCB(pContext, NFCSTATUS_FAILED); + } + + if (LlcpMac->RecvPending) + { + /* Reset Flag */ + LlcpMac->RecvPending = FALSE; + + /* Save context in local variables */ + pfRecvCB = LlcpMac->MacReceive_Cb; + pContext = LlcpMac->MacReceive_Context; + + /* Reset the pointer to the Receive Callback */ + LlcpMac->MacReceive_Cb = NULL; + LlcpMac->MacReceive_Context = NULL; + + /* Call Receive callback */ + pfRecvCB(pContext, NFCSTATUS_FAILED, NULL); + } + LlcpMac->LinkStatus_Cb(LlcpMac->LinkStatus_Context, LlcpMac->LinkState, NULL, @@ -187,6 +224,7 @@ static void phFriNfc_LlcpMac_Nfcip_Receive_Cb(void *pContext, LlcpMac->MacReceive_Context = NULL; /* Call the receive callback */ + LlcpMac->RecvPending = FALSE; pfReceiveCB(pReceiveContext, Status, LlcpMac->psReceiveBuffer); #ifdef LLCP_CHANGES -- cgit v1.2.3