NFCSTATUS phLibNfc_Llcp_Close( phLibNfc_Handle hSocket )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if (hSocket == 0)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Get local infos */
   /* TODO: if connected abort and close else close only */
   result = phFriNfc_LlcpTransport_Close(psSocket);

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_SocketGetLocalOptions( phLibNfc_Handle                  hSocket,
                                               phLibNfc_Llcp_sSocketOptions_t*  psLocalOptions
                                               )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hSocket == 0) ||
       (psLocalOptions == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Get local options */
   result = phFriNfc_LlcpTransport_SocketGetLocalOptions(psSocket, psLocalOptions);

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_Listen( phLibNfc_Handle                  hSocket,
                                pphLibNfc_LlcpSocketListenCb_t   pListen_Cb,
                                void*                            pContext
                                )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* NOTE : psServiceName may be NULL, do not test it ! */
   if ((hSocket == 0) ||
       (pListen_Cb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Start listening for incoming connections */
   result = phFriNfc_LlcpTransport_Listen( psSocket,
                                           (pphFriNfc_LlcpTransportSocketListenCb_t)pListen_Cb,
                                           pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_GetRemoteInfo( phLibNfc_Handle                    hRemoteDevice,
                                       phLibNfc_Llcp_sLinkParameters_t*   pConfigInfo
                                       )
{
   NFCSTATUS result;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0) ||
       (pConfigInfo == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Get local infos */
   result = phFriNfc_Llcp_GetRemoteInfo(&gpphLibNfc_Context->llcp_cntx.sLlcpContext, pConfigInfo);

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_Bind( phLibNfc_Handle hSocket,
                              uint8_t         nSap,
                              phNfc_sData_t * psServiceName
                              )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();
   /* State checking */
   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Parameters checking */
   if (hSocket == 0)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Bind the socket to the designated port */
   result = phFriNfc_LlcpTransport_Bind(psSocket, nSap, psServiceName);

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
예제 #6
0
STATIC void phLibNfc_Switch_Swp_Mode_CB(
                                void  *context,
                                NFCSTATUS status                                        
                                )
{
    if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS)
    {       
        status = NFCSTATUS_FAILED;
    }
    if(gpphLibContext!= NULL)
	{
		if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
		{
		    /*If shutdown called in between allow shutdown to happen*/
			phLibNfc_Pending_Shutdown();
			status = NFCSTATUS_SHUTDOWN;
		}
	}
    if((NULL != context)&&(context == (void *)&phLibNfc_Ioctl_Cntx))
    {
        if(NULL != phLibNfc_Ioctl_Cntx.CliRspCb)
        {
            (*phLibNfc_Ioctl_Cntx.CliRspCb)(
                phLibNfc_Ioctl_Cntx.pCliCntx,
                phLibNfc_Ioctl_Cntx.pOutParam,
                status
                );
        }
    }
    return;
}
NFCSTATUS phLibNfc_Llcp_Deactivate( phLibNfc_Handle  hRemoteDevice )
{
   NFCSTATUS result;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if (hRemoteDevice == 0)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Start deactivation */
   result = phFriNfc_Llcp_Deactivate(&gpphLibNfc_Context->llcp_cntx.sLlcpContext);

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
static
void phLibNfc_Llcp_CheckLlcp_Cb(void *pContext, NFCSTATUS status)
{
    phLibNfc_LibContext_t      *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)pContext;
    NFCSTATUS                  RetStatus = NFCSTATUS_SUCCESS;
    pphLibNfc_ChkLlcpRspCb_t   pClientCb = NULL;
    void                       *pClientContext = NULL;
    phLibNfc_State_t State;

    PH_LOG_LLCP_FUNC_ENTRY();
    if(pLibNfc_Ctxt != gpphLibNfc_Context)
    {
        phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
    }
    else
    {
        State = phLibNfc_GetState(gpphLibNfc_Context);
        if(phLibNfc_StateReset == State)
        {
            RetStatus = NFCSTATUS_SHUTDOWN;
        }
        else
        {
            RetStatus = phLibNfc_IsAborted(State);
            if (NFCSTATUS_ABORTED != RetStatus)
            {
                if(status == NFCSTATUS_SUCCESS)
                {
                    /* Remote peer is LLCP compliant */
                    gpphLibNfc_Context->llcp_cntx.bIsLlcp = TRUE;
                }
                else if(PHNFCSTATUS(status)== NFCSTATUS_FAILED)
                {
                    RetStatus = NFCSTATUS_FAILED;
                    gpphLibNfc_Context->llcp_cntx.bIsLlcp = FALSE;
                }
                else
                {
                    RetStatus = NFCSTATUS_TARGET_LOST;
                }
            }
        }
        /* Update the current state */
        gpphLibNfc_Context->status.GenCb_pending_status = FALSE;

        /* Copy callback details */
        pClientCb = gpphLibNfc_Context->CBInfo.pClientLlcpCheckRespCb;
        pClientContext = gpphLibNfc_Context->CBInfo.pClientLlcpCheckRespCntx;

        /* Reset saved callback */
        gpphLibNfc_Context->CBInfo.pClientCkNdefCb = NULL;
        gpphLibNfc_Context->CBInfo.pClientCkNdefCntx = NULL;

        if(pClientCb != NULL)
        {
            pClientCb(pClientContext,RetStatus);
        }
    }
    PH_LOG_LLCP_FUNC_EXIT();
}
NFCSTATUS phLibNfc_Llcp_Socket( phLibNfc_Llcp_eSocketType_t      eType,
                                phLibNfc_Llcp_sSocketOptions_t*  psOptions,
                                phNfc_sData_t*                   psWorkingBuffer,
                                phLibNfc_Handle*                 phSocket,
                                pphLibNfc_LlcpSocketErrCb_t      pErr_Cb,
                                void*                            pContext
                                )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket;

   PH_LOG_LLCP_FUNC_ENTRY();
   
   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* NOTE: Transport Layer test psOption and psWorkingBuffer value */
   if ((phSocket == NULL)        ||
       (pErr_Cb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Get local infos */
   result = phFriNfc_LlcpTransport_Socket(&gpphLibNfc_Context->llcp_cntx.sLlcpTransportContext,
                                          eType,
                                          psOptions,
                                          psWorkingBuffer,
                                          &psSocket,
                                          pErr_Cb,
                                          pContext);
    if (NFCSTATUS_SUCCESS == result)
    {
        /* Send back the socket handle */
        *phSocket = (phLibNfc_Handle)psSocket;
    }
    else
    {
        *phSocket = NULL;
    }

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_SendTo( phLibNfc_Handle               hRemoteDevice,
                                phLibNfc_Handle               hSocket,
                                uint8_t                       nSap,
                                phNfc_sData_t*                psBuffer,
                                pphLibNfc_LlcpSocketSendCb_t  pSend_RspCb,
                                void*                         pContext
                                )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0)   ||
       (hSocket == 0)         ||
       (psBuffer == NULL)     ||
       (pSend_RspCb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Send data to the logical link */
   result = phFriNfc_LlcpTransport_SendTo( psSocket,
                                           nSap,
                                           psBuffer,
                                           pSend_RspCb,
                                           pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_ConnectByUri( phLibNfc_Handle                 hRemoteDevice,
                                      phLibNfc_Handle                 hSocket,
                                      phNfc_sData_t*                  psUri,
                                      pphLibNfc_LlcpSocketConnectCb_t pConnect_RspCb,
                                      void*                           pContext
                                      )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0)      ||
       (hSocket == 0)            ||
       (psUri   == NULL)         ||
       (pConnect_RspCb == NULL))
   {
      PH_LOG_LLCP_WARN_STR("phLibNfc_Llcp_ConnectByUri NFCSTATUS_INVALID_PARAMETER");
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
       PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Try to connect on a remote service, using SDP */
   result = phFriNfc_LlcpTransport_ConnectByUri( psSocket,
                                                 psUri,
                                                 pConnect_RspCb,
                                                 pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_Disconnect( phLibNfc_Handle                    hRemoteDevice,
                                    phLibNfc_Handle                    hSocket,
                                    pphLibNfc_LlcpSocketDisconnectCb_t pDisconnect_RspCb,
                                    void*                              pContext
                                    )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0) ||
       (hSocket == 0)       ||
       (pDisconnect_RspCb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Disconnect a logical link */
   result = phFriNfc_LlcpTransport_Disconnect( psSocket,
                                               pDisconnect_RspCb,
                                               pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_Accept( phLibNfc_Handle                  hSocket,
                                phLibNfc_Llcp_sSocketOptions_t*  psOptions,
                                phNfc_sData_t*                   psWorkingBuffer,
                                pphLibNfc_LlcpSocketErrCb_t      pErr_Cb,
                                pphLibNfc_LlcpSocketAcceptCb_t   pAccept_RspCb,
                                void*                            pContext
                                )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hSocket == 0)            ||
       (psOptions == NULL)       ||
       (psWorkingBuffer == NULL) ||
       (pErr_Cb == NULL)         ||
       (pAccept_RspCb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Accept incoming connection */
   result = phFriNfc_LlcpTransport_Accept( psSocket,
                                           psOptions,
                                           psWorkingBuffer,
                                           pErr_Cb,
                                           pAccept_RspCb,
                                           pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_RecvFrom( phLibNfc_Handle                   hRemoteDevice,
                                  phLibNfc_Handle                   hSocket,
                                  phNfc_sData_t*                    psBuffer,
                                  pphLibNfc_LlcpSocketRecvFromCb_t  pRecv_Cb,
                                  void*                             pContext
                                  )
{
   NFCSTATUS                        result;
   phFriNfc_LlcpTransport_Socket_t  *psSocket = (phFriNfc_LlcpTransport_Socket_t*)hSocket;

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0)   ||
       (hSocket == 0)         ||
       (psBuffer == NULL)     ||
       (pRecv_Cb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Receive data from the logical link */
   result = phFriNfc_LlcpTransport_RecvFrom( psSocket,
                                             psBuffer,
                                             pRecv_Cb,
                                             pContext );

   PH_LOG_LLCP_FUNC_EXIT();
   return PHNFCSTATUS(result);
}
NFCSTATUS phLibNfc_Llcp_DiscoverServices( phLibNfc_Handle     hRemoteDevice,
                                          phNfc_sData_t       *psServiceNameList,
                                          uint8_t             *pnSapList,
                                          uint8_t             nListSize,
                                          pphLibNfc_RspCb_t   pDiscover_Cb,
                                          void                *pContext
                                          )
{
   NFCSTATUS                           result;
   PHNFC_UNUSED_VARIABLE(hRemoteDevice);

   PH_LOG_LLCP_FUNC_ENTRY();

   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0)       ||
       (psServiceNameList == NULL) ||
       (pnSapList == NULL) ||
       (nListSize == 0) ||
       (pDiscover_Cb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   result = static_CheckDevice(hRemoteDevice);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   /* Prepare callback */
   gpphLibNfc_Context->CBInfo.pClientLlcpDiscoveryCb = pDiscover_Cb;
   gpphLibNfc_Context->CBInfo.pClientLlcpDiscoveryCntx = pContext;

   /* Call the component function */
   result = phFriNfc_LlcpTransport_DiscoverServices( &gpphLibNfc_Context->llcp_cntx.sLlcpTransportContext,
                                                     psServiceNameList,
                                                     pnSapList,
                                                     nListSize,
                                                     pDiscover_Cb,
                                                     pContext
                                                     );
   result = PHNFCSTATUS(result);
   if ((result == NFCSTATUS_PENDING) || (result == NFCSTATUS_SUCCESS))
   {
      /* Nothing to do */
   }
   else if (result != NFCSTATUS_FAILED)
   {
      result = NFCSTATUS_TARGET_LOST;
   }

   PH_LOG_LLCP_FUNC_EXIT();
   return result;
}
NFCSTATUS phLibNfc_Llcp_CheckLlcp( phLibNfc_Handle              hRemoteDevice,
                                   pphLibNfc_ChkLlcpRspCb_t     pCheckLlcp_RspCb,
                                   pphLibNfc_LlcpLinkStatusCb_t pLink_Cb,
                                   void*                        pContext
                                   )
{
   NFCSTATUS                           result;
   phLibNfc_sRemoteDevInformation_t*   psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t*)hRemoteDevice;
   phLibNfc_Handle ConnHandle = 0;

   PH_LOG_LLCP_FUNC_ENTRY();
   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((hRemoteDevice == 0)       ||
       (pCheckLlcp_RspCb == NULL) ||
       (pLink_Cb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* If local device is the Initiator (remote is Target), check if connection is correct */
   if (psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Target)
   {
      if(gpphLibNfc_Context->Connected_handle == NULL)
      {
         PH_LOG_LLCP_FUNC_EXIT();
         return NFCSTATUS_TARGET_NOT_CONNECTED;
      }

      /* Check if handle corresponds to connected one */
      result = phLibNfc_GetConnectedHandle(&ConnHandle);
      if(hRemoteDevice != ConnHandle)
      {
         PH_LOG_LLCP_FUNC_EXIT();
         return NFCSTATUS_INVALID_HANDLE;
      }
   }

   /* Prepare callback */
   gpphLibNfc_Context->CBInfo.pClientLlcpLinkCb = pLink_Cb;
   gpphLibNfc_Context->CBInfo.pClientLlcpLinkCntx = pContext;

   // DEBUG: Reset at least the state
   gpphLibNfc_Context->llcp_cntx.sLlcpContext.state = 0;

   /* Prepare callback */
   gpphLibNfc_Context->CBInfo.pClientLlcpCheckRespCb = pCheckLlcp_RspCb;
   gpphLibNfc_Context->CBInfo.pClientLlcpCheckRespCntx = pContext;

   /* Call the component function */
   result = phFriNfc_Llcp_ChkLlcp( &gpphLibNfc_Context->llcp_cntx.sLlcpContext,
                                   psRemoteDevInfo,
                                   phLibNfc_Llcp_CheckLlcp_Cb,
                                   gpphLibNfc_Context
                                   );
   result = PHNFCSTATUS(result);
   if (result == NFCSTATUS_PENDING)
   {
      gpphLibNfc_Context->status.GenCb_pending_status = TRUE;
   }
   else if (result == NFCSTATUS_SUCCESS)
   {
      /* Nothing to do */
   }
   else if (result != NFCSTATUS_FAILED)
   {
      result = NFCSTATUS_TARGET_LOST;
   }

   PH_LOG_LLCP_FUNC_EXIT();
   return result;
}
NFCSTATUS phLibNfc_Mgt_SetLlcp_ConfigParams( phLibNfc_Llcp_sLinkParameters_t* pConfigInfo,
                                             pphLibNfc_RspCb_t                pConfigRspCb,
                                             void*                            pContext
                                            )
{
   NFCSTATUS      result;
   phNfc_sData_t  sGeneralBytesBuffer;
   phLibNfc_sNfcIPCfg_t sNfcIPCfg;
   const uint8_t  pMagicBuffer[] = { 0x46, 0x66, 0x6D };

   PH_LOG_LLCP_FUNC_ENTRY();
   result = static_CheckState();
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return result;
   }

   if ((pConfigInfo == NULL) || (pConfigRspCb == NULL))
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return NFCSTATUS_INVALID_PARAMETER;
   }

   /* Save the config for later use */
   phOsalNfc_MemCopy( &gpphLibNfc_Context->llcp_cntx.sLocalParams,
           pConfigInfo,
           sizeof(phLibNfc_Llcp_sLinkParameters_t) );

   /* Copy magic number in NFCIP General Bytes */
   phOsalNfc_MemCopy(sNfcIPCfg.generalBytes, pMagicBuffer, sizeof(pMagicBuffer));
   sNfcIPCfg.generalBytesLength = sizeof(pMagicBuffer);

   /* Encode link parameters in TLV to configure P2P General Bytes */
   sGeneralBytesBuffer.buffer = sNfcIPCfg.generalBytes + sizeof(pMagicBuffer);
   sGeneralBytesBuffer.length = sizeof(sNfcIPCfg.generalBytes) - sizeof(pMagicBuffer);
   result = phFriNfc_Llcp_EncodeLinkParams( &sGeneralBytesBuffer,
                                            pConfigInfo,
                                            PHFRINFC_LLCP_VERSION);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return PHNFCSTATUS(result);
   }
   sNfcIPCfg.generalBytesLength += (uint8_t)sGeneralBytesBuffer.length;

   /* Set the P2P general bytes */
   result = phLibNfc_Mgt_SetP2P_ConfigParams(&sNfcIPCfg, pConfigRspCb, pContext);
   if (result != NFCSTATUS_PENDING)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return PHNFCSTATUS(result);
   }

   /* Resets the LLCP LLC component */
   result = phFriNfc_Llcp_Reset( &gpphLibNfc_Context->llcp_cntx.sLlcpContext,
                                 gpphLibNfc_Context->psOverHalCtxt,
                                 pConfigInfo,
                                 gpphLibNfc_Context->llcp_cntx.pRxBuffer,
                                 sizeof(gpphLibNfc_Context->llcp_cntx.pRxBuffer),
                                 gpphLibNfc_Context->llcp_cntx.pTxBuffer,
                                 sizeof(gpphLibNfc_Context->llcp_cntx.pTxBuffer),
                                 gpphLibNfc_Context->bDtaFlag,
                                 phLibNfc_Llcp_Link_Cb,
                                 gpphLibNfc_Context);
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return PHNFCSTATUS(result);
   }

   /* Resets the LLCP Transport component */
   result = phFriNfc_LlcpTransport_Reset( &gpphLibNfc_Context->llcp_cntx.sLlcpTransportContext,
                                          &gpphLibNfc_Context->llcp_cntx.sLlcpContext );
   if (result != NFCSTATUS_SUCCESS)
   {
      PH_LOG_LLCP_FUNC_EXIT();
      return PHNFCSTATUS(result);
   }

   PH_LOG_LLCP_FUNC_EXIT();
   return NFCSTATUS_PENDING;
}
예제 #18
0
STATIC  void phLibNfc_Ioctl_Mgmt_CB(void          *context,
                              phNfc_sData_t *pOutData,
                              NFCSTATUS      status )
{
    phLibNfc_Ioctl_Cntx_t *pIoctlCntx=NULL;

    if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS)
    {
        status = NFCSTATUS_FAILED;
    }
	if(gpphLibContext!= NULL)
	{
		if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
		{
		    /*If shutdown called in between allow shutdown to happen*/
			phLibNfc_Pending_Shutdown();
			status = NFCSTATUS_SHUTDOWN;
		}
	}
    pIoctlCntx= (phLibNfc_Ioctl_Cntx_t*)context;
    if( pIoctlCntx !=NULL)
    {
        switch(pIoctlCntx->IoctlCode)
        {
            case NFC_FW_DOWNLOAD:
            {
                /*Release the hardware reference memory*/
                phOsalNfc_FreeMemory(pIoctlCntx->psHwReference);
            }break;
            case NFC_MEM_READ:
            {

            }break;
            case NFC_MEM_WRITE:
            {

            }break;

			case PHLIBNFC_ANTENNA_TEST:
            {
            
            }break; 
			case PHLIBNFC_SWP_TEST:
            {
            
            }break;	
			case PHLIBNFC_PRBS_TEST:
            {
            
            }break;
            default:
            {
            }
        }
        pIoctlCntx->CliRspCb(pIoctlCntx->pCliCntx,pOutData,status);
		if(gpphLibContext!= NULL)
		{
			gpphLibContext->status.GenCb_pending_status=FALSE;
		}
    }
}
/**
* Check for target presence.
* Checks given target is present in RF filed or not
*/
NFCSTATUS phLibNfc_RemoteDev_CheckPresence( phLibNfc_Handle     hTargetDev,
        pphLibNfc_RspCb_t   pPresenceChk_RspCb,
        void*               pRspCbCtx
                                          )
{
    NFCSTATUS RetVal = NFCSTATUS_FAILED;
    phHal_sRemoteDevInformation_t *ps_rem_dev_info = NULL;
    /* Check for valid sate */
    if((NULL == gpphLibContext) ||
            (gpphLibContext->LibNfcState.cur_state
             == eLibNfcHalStateShutdown))
    {
        RetVal = NFCSTATUS_NOT_INITIALISED;
    }
    /* Check for valid parameters*/
    else if((NULL == pRspCbCtx) || (NULL == pPresenceChk_RspCb)
            || (hTargetDev == 0) )
    {
        RetVal= NFCSTATUS_INVALID_PARAMETER;
    }
    /* Check for DeInit call*/
    else if(gpphLibContext->LibNfcState.next_state
            == eLibNfcHalStateShutdown)
    {
        RetVal = NFCSTATUS_SHUTDOWN;
    }
    /* Check target is connected or not */
    else if( gpphLibContext->Connected_handle == 0)
    {
        RetVal = NFCSTATUS_TARGET_NOT_CONNECTED;
    }
    /* Check given handle is valid or not*/
    else if(hTargetDev != gpphLibContext->Connected_handle)
    {
        RetVal = NFCSTATUS_INVALID_HANDLE;
    }
#ifdef LLCP_TRANSACT_CHANGES
    else if ((LLCP_STATE_RESET_INIT != gpphLibContext->llcp_cntx.sLlcpContext.state)
             && (LLCP_STATE_CHECKED != gpphLibContext->llcp_cntx.sLlcpContext.state))
    {
        RetVal= NFCSTATUS_BUSY;
    }
#endif /* #ifdef LLCP_TRANSACT_CHANGES */
    else
    {
        ps_rem_dev_info = (phHal_sRemoteDevInformation_t *)
                          gpphLibContext->Connected_handle;
        if((phHal_eMifare_PICC == ps_rem_dev_info->RemDevType)
                &&(0 != ps_rem_dev_info->RemoteDevInfo.Iso14443A_Info.Sak)
                &&(TRUE == gpphLibContext->LastTrancvSuccess))
        {
            /* Call HAL4 API */
            RetVal =  phHal4Nfc_Transceive(
                          gpphLibContext->psHwReference,
                          gpphLibContext->psBufferedAuth,
                          (phHal_sRemoteDevInformation_t *)
                          gpphLibContext->Connected_handle,
                          (pphHal4Nfc_TransceiveCallback_t )
                          phLibNfc_ChkPresence_Trcv_Cb,
                          (void *)gpphLibContext
                      );

        }
        else
        {
            /* Call lower layer PresenceCheck function */
            RetVal = phHal4Nfc_PresenceCheck(gpphLibContext->psHwReference,
                                             phLibNfc_RemoteDev_CheckPresence_Cb,
                                             (void *)gpphLibContext);
        }
        if( NFCSTATUS_PENDING == PHNFCSTATUS(RetVal))
        {
            gpphLibContext->CBInfo.pClientPresChkCb = pPresenceChk_RspCb;
            gpphLibContext->CBInfo.pClientPresChkCntx = pRspCbCtx;
            /* Mark General callback pending status as TRUE*/
            gpphLibContext->status.GenCb_pending_status = TRUE;

            /* Update the state machine*/
            gpphLibContext->LibNfcState.next_state = eLibNfcHalStatePresenceChk;
        }
        else /* If return value is internal error(other than pending ) return NFCSTATUS_FAILED*/
        {
            RetVal = NFCSTATUS_FAILED;
        }
    }
    return RetVal;
}
/**
* Configure Discovery Modes.
* This function is used to configure ,start and stop the discovery wheel.
*/
NFCSTATUS phLibNfc_Mgt_ConfigureDiscovery (
    phLibNfc_eDiscoveryConfigMode_t DiscoveryMode,
    phLibNfc_sADD_Cfg_t             sADDSetup,
    pphLibNfc_RspCb_t               pConfigDiscovery_RspCb,
    void*                           pContext
)
{
    NFCSTATUS RetVal = NFCSTATUS_FAILED;
    phHal_sADD_Cfg_t           *psADDConfig;
    psADDConfig = (phHal_sADD_Cfg_t *)&(sADDSetup);


    if((NULL == gpphLibContext) ||
            (gpphLibContext->LibNfcState.cur_state
             == eLibNfcHalStateShutdown))
    {
        /*Lib Nfc not initialized*/
        RetVal = NFCSTATUS_NOT_INITIALISED;
    }
    /* Check for Valid parameters*/
    else if((NULL == pContext) || (NULL == pConfigDiscovery_RspCb))
    {
        RetVal= NFCSTATUS_INVALID_PARAMETER;
    }
    else if(gpphLibContext->LibNfcState.next_state
            == eLibNfcHalStateShutdown)
    {
        RetVal= NFCSTATUS_SHUTDOWN;
    }
    else
    {
        gpphLibContext->eLibNfcCfgMode =DiscoveryMode;
        gpphLibContext->sADDconfig = sADDSetup;
        if(gpphLibContext->status.DiscEnbl_status != TRUE)
        {

            /* call lower layer config API for the discovery
            configuration sent by the application */
            RetVal = phHal4Nfc_ConfigureDiscovery ( gpphLibContext->psHwReference,
                                                    DiscoveryMode,
                                                    psADDConfig,
                                                    (pphLibNfc_RspCb_t)
                                                    phLibNfc_config_discovery_cb,
                                                    (void*)gpphLibContext);
            if(PHNFCSTATUS(RetVal) == NFCSTATUS_PENDING)
            {
                gpphLibContext->status.DiscEnbl_status = TRUE;
                /* Copy discovery callback and its context */
                gpphLibContext->CBInfo.pClientDisConfigCb = pConfigDiscovery_RspCb;
                gpphLibContext->CBInfo.pClientDisCfgCntx = pContext;
                gpphLibContext->status.GenCb_pending_status = TRUE;
                gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConfigReady;
            }
            else
            {
                if (PHNFCSTATUS(RetVal) == NFCSTATUS_BUSY)
                {
                    RetVal = NFCSTATUS_BUSY;
                }
                else
                {
                    RetVal=NFCSTATUS_FAILED;
                }
            }

        }
        else
        {
            RetVal=NFCSTATUS_BUSY;
        }
    }
    return RetVal;
}
예제 #21
0
static 
void 
phLlcNfc_ConnectionTimeoutCb (
    uint32_t TimerId,
    void *pContext
)
{
    NFCSTATUS                   result = NFCSTATUS_SUCCESS;
    phNfc_sCompletionInfo_t     notifyinfo = {0};
    pphNfcIF_Notification_CB_t  notifyul = NULL;
    void                        *p_upperctxt = NULL;
    phLlcNfc_Frame_t            *ps_frame_info = NULL;
    phLlcNfc_Timerinfo_t        *ps_timer_info = NULL;
    PHNFC_UNUSED_VARIABLE(pContext);
    
    PH_LLCNFC_PRINT("\n\nLLC : CONNECTION TIMEOUT CB CALLED\n\n");
    if ((NULL != gpphLlcNfc_Ctxt) && (TimerId == 
        gpphLlcNfc_Ctxt->s_timerinfo.timer_id[PH_LLCNFC_CONNECTIONTIMER]) 
        && (PH_LLCNFC_CON_TO_BIT_VAL == 
        (gpphLlcNfc_Ctxt->s_timerinfo.timer_flag & 
        PH_LLCNFC_CON_TO_BIT_VAL)))
    {
        ps_frame_info = &(gpphLlcNfc_Ctxt->s_frameinfo);
        ps_timer_info = &(gpphLlcNfc_Ctxt->s_timerinfo);
        if (ps_timer_info->con_to_value > 0)
        {
#if !defined (CYCLIC_TIMER)
            phOsalNfc_Timer_Stop(
                    ps_timer_info->timer_id[PH_LLCNFC_CONNECTIONTIMER]);
            /* phLlcNfc_StopTimers(PH_LLCNFC_CONNECTIONTIMER, 0); */
#endif
            ps_timer_info->con_to_value = 0;
        
            if (0 == ps_timer_info->con_to_value)
            {
                PH_LLCNFC_DEBUG("TIMER EXPIRED RETRY COUNT : %02X\n", ps_frame_info->retry_cnt);
                phLlcNfc_StopTimers (PH_LLCNFC_CONNECTIONTIMER, 0);
                
                if (ps_frame_info->retry_cnt < PH_LLCNFC_MAX_RETRY_COUNT)
                {
                    /* Create a U frame */
                    result = phLlcNfc_H_CreateUFramePayload(gpphLlcNfc_Ctxt, 
                                        &(ps_frame_info->s_llcpacket),
                                        &(ps_frame_info->s_llcpacket.llcbuf_len), 
                                        phLlcNfc_e_rset);

                    if (NFCSTATUS_SUCCESS == result)
                    {
                        /* Call DAL write */
                        result = phLlcNfc_Interface_Write (gpphLlcNfc_Ctxt, 
                                (uint8_t*)&(ps_frame_info->s_llcpacket.s_llcbuf), 
                                (uint32_t)(ps_frame_info->s_llcpacket.llcbuf_len));
                    }
                    if (NFCSTATUS_PENDING == result)
                    {
                        /* Start the timer */
                        result = phLlcNfc_StartTimers(PH_LLCNFC_CONNECTIONTIMER, 0);
                        if (NFCSTATUS_SUCCESS == result)
                        {
                            ps_frame_info->retry_cnt++;
                            result = NFCSTATUS_PENDING;
                        }
                    }
                    else
                    {
                        if (NFCSTATUS_BUSY == PHNFCSTATUS(result))
                        {
                            result = NFCSTATUS_PENDING;
                        }
                    }
                }
                else
                {
                    PH_LLCNFC_PRINT("RETRY COUNT LIMIT REACHED \n");
                    if ((ps_frame_info->retry_cnt == PH_LLCNFC_MAX_RETRY_COUNT) 
                        && (NULL != gpphLlcNfc_Ctxt->cb_for_if.notify))
                    {
                        void            *p_hw_info = NULL;
                        uint8_t         type = 0;
                        
                        p_hw_info = gpphLlcNfc_Ctxt->phwinfo;
                        notifyinfo.status = PHNFCSTVAL(CID_NFC_LLC, 
                                            NFCSTATUS_BOARD_COMMUNICATION_ERROR);
                        
                        notifyul = gpphLlcNfc_Ctxt->cb_for_if.notify;
                        p_upperctxt = gpphLlcNfc_Ctxt->cb_for_if.pif_ctxt;
                        type = NFC_NOTIFY_ERROR;
                        if (init_u_rset_frame == ps_frame_info->sent_frame_type)
                        {
                            type = NFC_NOTIFY_INIT_FAILED;
                            /* Release if, the initialisation is not complete */
                            result = phLlcNfc_Release(gpphLlcNfc_Ctxt, p_hw_info);
                            gpphLlcNfc_Ctxt = NULL;
                        }
                        else
                        {
                            type = NFC_NOTIFY_DEVICE_ERROR;
                            notifyinfo.status = PHNFCSTVAL(CID_NFC_LLC, 
                                            NFCSTATUS_BOARD_COMMUNICATION_ERROR);
#if 0
                            phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 
#endif /* #if 0 */
                        }
                        /* Notify the upper layer */
                        notifyul(p_upperctxt, p_hw_info, type, &notifyinfo);
                    }
                }
            }
#if !defined (CYCLIC_TIMER)
            else
            {
                /* Start the timer again */
                phOsalNfc_Timer_Start(
                            ps_timer_info->timer_id[PH_LLCNFC_CONNECTIONTIMER], 
                            ps_timer_info->con_to_value, phLlcNfc_ConnectionTimeoutCb, NULL);
            }
#endif
        }
    }
    PH_LLCNFC_PRINT("\n\nLLC : CONNECTION TIMEOUT CB END\n\n");
}
//Display status code
const char* nfc_jni_get_status_name(NFCSTATUS status)
{
   #define STATUS_ENTRY(status) { status, #status }
 
   struct status_entry {
      NFCSTATUS   code;
      const char  *name;
   };

   const struct status_entry sNameTable[] = {
      STATUS_ENTRY(NFCSTATUS_SUCCESS),
      STATUS_ENTRY(NFCSTATUS_FAILED),
      STATUS_ENTRY(NFCSTATUS_INVALID_PARAMETER),
      STATUS_ENTRY(NFCSTATUS_INSUFFICIENT_RESOURCES),
      STATUS_ENTRY(NFCSTATUS_TARGET_LOST),
      STATUS_ENTRY(NFCSTATUS_INVALID_HANDLE),
      STATUS_ENTRY(NFCSTATUS_MULTIPLE_TAGS),
      STATUS_ENTRY(NFCSTATUS_ALREADY_REGISTERED),
      STATUS_ENTRY(NFCSTATUS_FEATURE_NOT_SUPPORTED),
      STATUS_ENTRY(NFCSTATUS_SHUTDOWN),
      STATUS_ENTRY(NFCSTATUS_ABORTED),
      STATUS_ENTRY(NFCSTATUS_REJECTED ),
      STATUS_ENTRY(NFCSTATUS_NOT_INITIALISED),
      STATUS_ENTRY(NFCSTATUS_PENDING),
      STATUS_ENTRY(NFCSTATUS_BUFFER_TOO_SMALL),
      STATUS_ENTRY(NFCSTATUS_ALREADY_INITIALISED),
      STATUS_ENTRY(NFCSTATUS_BUSY),
      STATUS_ENTRY(NFCSTATUS_TARGET_NOT_CONNECTED),
      STATUS_ENTRY(NFCSTATUS_MULTIPLE_PROTOCOLS),
      STATUS_ENTRY(NFCSTATUS_DESELECTED),
      STATUS_ENTRY(NFCSTATUS_INVALID_DEVICE),
      STATUS_ENTRY(NFCSTATUS_MORE_INFORMATION),
      STATUS_ENTRY(NFCSTATUS_RF_TIMEOUT),
      STATUS_ENTRY(NFCSTATUS_RF_ERROR),
      STATUS_ENTRY(NFCSTATUS_BOARD_COMMUNICATION_ERROR),
      STATUS_ENTRY(NFCSTATUS_INVALID_STATE),
      STATUS_ENTRY(NFCSTATUS_NOT_REGISTERED),
      STATUS_ENTRY(NFCSTATUS_RELEASED),
      STATUS_ENTRY(NFCSTATUS_NOT_ALLOWED),
      STATUS_ENTRY(NFCSTATUS_INVALID_REMOTE_DEVICE),
      STATUS_ENTRY(NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED),
      STATUS_ENTRY(NFCSTATUS_READ_FAILED),
      STATUS_ENTRY(NFCSTATUS_WRITE_FAILED),
      STATUS_ENTRY(NFCSTATUS_NO_NDEF_SUPPORT),
      STATUS_ENTRY(NFCSTATUS_EOF_NDEF_CONTAINER_REACHED),
      STATUS_ENTRY(NFCSTATUS_INVALID_RECEIVE_LENGTH),
      STATUS_ENTRY(NFCSTATUS_INVALID_FORMAT),
      STATUS_ENTRY(NFCSTATUS_INSUFFICIENT_STORAGE),
      STATUS_ENTRY(NFCSTATUS_FORMAT_ERROR),
   };

   int i = sizeof(sNameTable)/sizeof(status_entry);
 
   while(i>0)
   {
      i--;
      if (sNameTable[i].code == PHNFCSTATUS(status))
      {
         return sNameTable[i].name;
      }
   }

   return "UNKNOWN";
}
예제 #23
0
static 
void 
phLlcNfc_GuardTimeoutCb (
    uint32_t TimerId,
    void *pContext
)
{
    NFCSTATUS                   result = NFCSTATUS_SUCCESS;
    phLlcNfc_Timerinfo_t        *ps_timer_info = NULL;
    phLlcNfc_Frame_t            *ps_frame_info = NULL;
    phLlcNfc_LlcPacket_t        *ps_packet_info = NULL;
    uint8_t                     index = 0;
    uint8_t                     zero_to_index = 0;
#if defined (GUARD_TO_ERROR)
    phNfc_sCompletionInfo_t     notifyinfo = {0};
#endif /* #if defined (GUARD_TO_ERROR) */
    PHNFC_UNUSED_VARIABLE(pContext);

    PH_LLCNFC_PRINT("\n\nLLC : GUARD TIMEOUT CB CALLED \n\n");

    if ((NULL != gpphLlcNfc_Ctxt) && (TimerId == 
        gpphLlcNfc_Ctxt->s_timerinfo.timer_id[PH_LLCNFC_GUARDTIMER]) && 
        (PH_LLCNFC_GUARD_TO_BIT_VAL == 
        (gpphLlcNfc_Ctxt->s_timerinfo.timer_flag & 
        PH_LLCNFC_GUARD_TO_BIT_VAL)))
    {
        uint8_t                 timer_expired = FALSE;
        ps_frame_info = &(gpphLlcNfc_Ctxt->s_frameinfo);
        ps_timer_info = &(gpphLlcNfc_Ctxt->s_timerinfo);

#if !defined (CYCLIC_TIMER)
        phOsalNfc_Timer_Stop(
                    ps_timer_info->timer_id[PH_LLCNFC_GUARDTIMER]);
#endif

        PH_LLCNFC_DEBUG("NO OF TIMEOUT COUNT : 0x%02X\n", ps_timer_info->guard_to_count);
        /* Loop is completely depending on the number of different LLC  
           send called */
        while (index < ps_timer_info->guard_to_count) 
        {
            if (0 != ps_timer_info->guard_to_value[index])
            {
                if (ps_timer_info->guard_to_value[index] > 0)
                {
                    if (ps_timer_info->guard_to_value[index] >= 
                        PH_LLCNFC_RESOLUTION)
                    {
                        ps_timer_info->guard_to_value[index] = (uint16_t)
                            (ps_timer_info->guard_to_value[index] - 
                            PH_LLCNFC_RESOLUTION);
                    }
                    else
                    {
                        ps_timer_info->guard_to_value[index] = 0;
                    }
                }

                if (0 == ps_timer_info->guard_to_value[index])
                {
                    zero_to_index = index;
                    timer_expired = TRUE;
                }
            }
            index = (uint8_t)(index + 1);
        }

#if !defined (CYCLIC_TIMER)        
        /* Start the timer again */
        phOsalNfc_Timer_Start(
                    ps_timer_info->timer_id[PH_LLCNFC_GUARDTIMER], 
                    PH_LLCNFC_RESOLUTION, phLlcNfc_GuardTimeoutCb, NULL);
#endif
        PH_LLCNFC_DEBUG("TIMER EXPIRED : 0x%02X\n", timer_expired);        

        if (TRUE == timer_expired)
        {
            PH_LLCNFC_DEBUG("TIMER EXPIRED INDEX: 0x%02X\n", zero_to_index);
            PH_LLCNFC_DEBUG("TIMER EXPIRED NS INDEX: 0x%02X\n", ps_timer_info->timer_ns_value[zero_to_index]);
            PH_LLCNFC_DEBUG("TIMER EXPIRED RETRIES : 0x%02X\n", ps_timer_info->iframe_send_count[zero_to_index]);

            PH_LLCNFC_DEBUG("TIMER EXPIRED GUARD TIME-OUT COUNT: 0x%02X\n", ps_timer_info->guard_to_value[zero_to_index]);

            if ((0 == ps_timer_info->guard_to_value[zero_to_index]) && 
                (ps_timer_info->iframe_send_count[zero_to_index] < 
                LLC_GUARD_TIMER_RETRIES))
            {
                if (ps_frame_info->s_send_store.winsize_cnt > 0)
                {
                    uint8_t             start_index = 0;
                    uint8_t             timer_count = 0;
                    uint8_t             while_exit = FALSE;

                    timer_count = ps_timer_info->guard_to_count;

                    
                    /* Check before changing the index to resend, if index 
                        already exist then dont set the index */
                    while ((FALSE == while_exit) && (start_index < timer_count))
                    {
                        if (resend_i_frame == 
                            ps_timer_info->frame_type[start_index])
                        {
                            while_exit = TRUE;
                        }
                        else
                        {                     
                            start_index = (uint8_t)(start_index + 1);
                        }
                    }

                    if (TRUE == while_exit)
                    {
                        ps_timer_info->index_to_send = zero_to_index;
                    }

                    ps_timer_info->frame_type[zero_to_index] = (uint8_t)
                                                            resend_i_frame;
                    /* Now resend the frame stored */
                    result = phLlcNfc_H_SendTimedOutIFrame (gpphLlcNfc_Ctxt, 
                                            &(ps_frame_info->s_send_store), 
                                            0);
                }
            }
            else
            {
                if ((LLC_GUARD_TIMER_RETRIES == 
                    ps_timer_info->iframe_send_count[zero_to_index]) && 
                    (NULL != gpphLlcNfc_Ctxt->cb_for_if.notify))
                {
                    phLlcNfc_StopAllTimers ();
#if defined (GUARD_TO_ERROR)
                    
                    notifyinfo.status = PHNFCSTVAL(CID_NFC_LLC, 
                                        NFCSTATUS_BOARD_COMMUNICATION_ERROR);
#if 0
                    phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 
#endif /* #if 0 */
                    /* Resend done, no answer from the device */
                    gpphLlcNfc_Ctxt->cb_for_if.notify (
                                    gpphLlcNfc_Ctxt->cb_for_if.pif_ctxt,
                                    gpphLlcNfc_Ctxt->phwinfo, 
                                    NFC_NOTIFY_DEVICE_ERROR, 
                                    &notifyinfo);

#endif /* #if defined (GUARD_TO_ERROR) */

#if (!defined (GUARD_TO_ERROR) && defined (GUARD_TO_URSET))

                    PH_LLCNFC_PRINT("U-RSET IS SENT \n");
                    ps_packet_info = &(gpphLlcNfc_Ctxt->s_frameinfo.s_llcpacket);

                    result = phLlcNfc_H_CreateUFramePayload(gpphLlcNfc_Ctxt, 
                                        ps_packet_info, 
                                        &(ps_packet_info->llcbuf_len), 
                                        phLlcNfc_e_rset);

                    result = phLlcNfc_Interface_Write(gpphLlcNfc_Ctxt, 
                                    (uint8_t*)&(ps_packet_info->s_llcbuf), 
                                    (uint32_t)ps_packet_info->llcbuf_len);

                    ps_frame_info->write_status = result;
                    if (NFCSTATUS_PENDING == result)
                    {
                        /* Start the timer */
                        result = phLlcNfc_StartTimers (PH_LLCNFC_CONNECTIONTIMER, 0);
                        if (NFCSTATUS_SUCCESS == result)
                        {
                            ps_frame_info->retry_cnt = 0;
                            gpphLlcNfc_Ctxt->s_frameinfo.sent_frame_type = 
                                                                    u_rset_frame;
                            result = NFCSTATUS_PENDING;
                        }
                    }
                    else
                    {
                        if (NFCSTATUS_BUSY == PHNFCSTATUS (result))
                        {                        
                            ps_frame_info->write_wait_call = u_rset_frame;
                        }
                    }

#endif /* #if defined (GUARD_TO_ERROR) */
                }
            }
        }
    }
    PH_LLCNFC_PRINT("\n\nLLC : GUARD TIMEOUT CB END\n\n");
}