summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/phFriNfc_LlcpTransport.c22
-rw-r--r--src/phFriNfc_LlcpTransport.h8
-rw-r--r--src/phLibNfc_Internal.h4
-rw-r--r--src/phLibNfc_llcp.c41
4 files changed, 73 insertions, 2 deletions
diff --git a/src/phFriNfc_LlcpTransport.c b/src/phFriNfc_LlcpTransport.c
index 408f058..ddc8c6a 100644
--- a/src/phFriNfc_LlcpTransport.c
+++ b/src/phFriNfc_LlcpTransport.c
@@ -200,6 +200,28 @@ NFCSTATUS phFriNfc_LlcpTransport_Reset (phFriNfc_LlcpTransport_t *pLlcpTran
return status;
}
+/* TODO: comment function Transport CloseAll */
+NFCSTATUS phFriNfc_LlcpTransport_CloseAll (phFriNfc_LlcpTransport_t *pLlcpTransport)
+{
+ NFCSTATUS status = NFCSTATUS_SUCCESS;
+ uint8_t i;
+
+ /* Check for NULL pointers */
+ if(pLlcpTransport == NULL)
+ {
+ status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER);
+ }
+
+ /* Close all sockets */
+ for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++)
+ {
+ phFriNfc_LlcpTransport_Close(&pLlcpTransport->pSocketTable[i]);
+ }
+
+ return status;
+}
+
+
/**
* \ingroup grp_lib_nfc
* \brief <b>Get the local options of a socket</b>.
diff --git a/src/phFriNfc_LlcpTransport.h b/src/phFriNfc_LlcpTransport.h
index 0cc3721..7d77634 100644
--- a/src/phFriNfc_LlcpTransport.h
+++ b/src/phFriNfc_LlcpTransport.h
@@ -269,6 +269,14 @@ NFCSTATUS phFriNfc_LlcpTransport_Reset (phFriNfc_LlcpTransport_t *pLlcpSock
/**
+* \ingroup grp_fri_nfc
+* \brief <b>Close all existing sockets</b>.
+*
+*/
+NFCSTATUS phFriNfc_LlcpTransport_CloseAll (phFriNfc_LlcpTransport_t *pLlcpSocketTable);
+
+
+/**
* \ingroup grp_lib_nfc
* \brief <b>Get the local options of a socket</b>.
*
diff --git a/src/phLibNfc_Internal.h b/src/phLibNfc_Internal.h
index 0803101..10018ec 100644
--- a/src/phLibNfc_Internal.h
+++ b/src/phLibNfc_Internal.h
@@ -130,6 +130,10 @@ typedef struct phLibNfc_Hal_CB_Info
pphLibNfc_ChkLlcpRspCb_t pClientLlcpCheckRespCb;
void *pClientLlcpCheckRespCntx;
+ /*LLCP Link CB*/
+ pphLibNfc_LlcpLinkStatusCb_t pClientLlcpLinkCb;
+ void *pClientLlcpLinkCntx;
+
}phLibNfc_Hal_CB_Info_t;
typedef struct phLibNfc_NdefInfo
diff --git a/src/phLibNfc_llcp.c b/src/phLibNfc_llcp.c
index c72e1b7..86b15cf 100644
--- a/src/phLibNfc_llcp.c
+++ b/src/phLibNfc_llcp.c
@@ -39,6 +39,9 @@ NFCSTATUS static_CheckDevice(phLibNfc_Handle hRemoteDevice);
STATIC
void phLibNfc_Llcp_CheckLlcp_Cb(void *pContext,NFCSTATUS status);
+STATIC
+void phLibNfc_Llcp_Link_Cb(void *pContext,phLibNfc_Llcp_eLinkStatus_t status);
+
/* --------------------------- Internal functions ------------------------------ */
STATIC NFCSTATUS static_CheckState()
@@ -189,6 +192,10 @@ NFCSTATUS phLibNfc_Llcp_CheckLlcp( phLibNfc_Handle hRemoteDevice,
}
}
+ /* Prepare callback */
+ gpphLibContext->CBInfo.pClientLlcpLinkCb = pLink_Cb;
+ gpphLibContext->CBInfo.pClientLlcpLinkCntx = pContext;
+
/* Resets the LLCP LLC component */
result = phFriNfc_Llcp_Reset( &gpphLibContext->llcp_cntx.sLlcpContext,
gpphLibContext->psOverHalCtxt,
@@ -197,8 +204,8 @@ NFCSTATUS phLibNfc_Llcp_CheckLlcp( phLibNfc_Handle hRemoteDevice,
sizeof(gpphLibContext->llcp_cntx.pRxBuffer),
gpphLibContext->llcp_cntx.pTxBuffer,
sizeof(gpphLibContext->llcp_cntx.pTxBuffer),
- pLink_Cb,
- pContext);
+ phLibNfc_Llcp_Link_Cb,
+ gpphLibContext);
if (result != NFCSTATUS_SUCCESS)
{
return PHNFCSTATUS(result);
@@ -246,6 +253,36 @@ NFCSTATUS phLibNfc_Llcp_CheckLlcp( phLibNfc_Handle hRemoteDevice,
return result;
}
+/* LLCP link callback */
+STATIC
+void phLibNfc_Llcp_Link_Cb(void *pContext, phLibNfc_Llcp_eLinkStatus_t status)
+{
+ phLibNfc_LibContext_t *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)pContext;
+ pphLibNfc_LlcpLinkStatusCb_t pClientCb = NULL;
+ void *pClientContext = NULL;
+
+ if(pLibNfc_Ctxt != gpphLibContext)
+ {
+ /*wrong context returned from below layer*/
+ phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
+ }
+ else
+ {
+ /* Close all sockets */
+ phFriNfc_LlcpTransport_CloseAll(&gpphLibContext->llcp_cntx.sLlcpTransportContext);
+
+ /* Copy callback details */
+ pClientCb = gpphLibContext->CBInfo.pClientLlcpLinkCb;
+ pClientContext = gpphLibContext->CBInfo.pClientLlcpLinkCntx;
+
+ /* Trigger the callback */
+ if(pClientCb != NULL)
+ {
+ pClientCb(pClientContext, status);
+ }
+ }
+}
+
/* Response callback for phLibNfc_Ndef_CheckNdef */
STATIC
void phLibNfc_Llcp_CheckLlcp_Cb(void *pContext, NFCSTATUS status)