diff options
-rw-r--r-- | src/phFriNfc_Llcp.c | 6 | ||||
-rw-r--r-- | src/phFriNfc_LlcpMacNfcip.c | 38 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/phFriNfc_Llcp.c b/src/phFriNfc_Llcp.c index 86ab6ed..cfbda3a 100644 --- a/src/phFriNfc_Llcp.c +++ b/src/phFriNfc_Llcp.c @@ -933,9 +933,6 @@ static void phFriNfc_Llcp_Receive_CB( void *pContext, NFCSTATUS result = NFCSTATUS_SUCCESS; phFriNfc_Llcp_sPacketHeader_t sPacketHeader; - /* Parse header */ - phFriNfc_Llcp_Buffer2Header(psData->buffer, 0, &sPacketHeader); - /* Check reception status and for pending disconnection */ if ((status != NFCSTATUS_SUCCESS) || (Llcp->bDiscPendingFlag == TRUE)) { @@ -947,6 +944,9 @@ static void phFriNfc_Llcp_Receive_CB( void *pContext, return; } + /* Parse header */ + phFriNfc_Llcp_Buffer2Header(psData->buffer, 0, &sPacketHeader); + if (sPacketHeader.ptype != PHFRINFC_LLCP_PTYPE_SYMM) { LLCP_PRINT_BUFFER("\nReceived LLCP packet :", psData->buffer, psData->length); 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 |