NFCSTATUS
 phHciNfc_Send_Admin_Event (
                      phHciNfc_sContext_t   *psHciContext,
                      void                  *pHwRef,
                      uint8_t               event,
                      uint8_t               length,
                      void                  *params
                     )
{
    phHciNfc_HCP_Packet_t       *hcp_packet = NULL;
    phHciNfc_AdminGate_Info_t   *p_admin_info=NULL;
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;

    if( (NULL == psHciContext) 
        || (NULL == pHwRef) 
      )
    {
      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        psHciContext->tx_total = 0 ;
        length +=  HCP_HEADER_LEN ;
        p_admin_info = psHciContext->p_admin_info;

        if( EVT_HOT_PLUG ==   event )
        {

            /* Use the HCP Packet Structure to Construct the send HCP
                * Packet data.
                */
            hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
            phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
                                    (uint8_t) HCI_ADMIN_PIPE_ID,
                                    HCP_MSG_TYPE_EVENT, event);
        }
        else
        {
            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INSTRUCTION);
        }

        if( NFCSTATUS_SUCCESS == status )
        {
            p_admin_info->admin_pipe_info->sent_msg_type = HCP_MSG_TYPE_EVENT;
            p_admin_info->admin_pipe_info->prev_msg = event ;
            p_admin_info->admin_pipe_info->param_info = params ;
            psHciContext->tx_total = length;
            psHciContext->response_pending = FALSE ;
            status = phHciNfc_Send_HCP( (void *)psHciContext, (void *)pHwRef );
            p_admin_info->admin_pipe_info->prev_status = NFCSTATUS_PENDING;
        }
    }

    return status;
}
Esempio n. 2
0
/*******************************************************************************
**
** Function         phDnldNfc_ReadLog
**
** Description      Retrieves log data from EEPROM
**
** Parameters       pData    - response buffer which gets updated with data from EEPROM
**                  pNotify  - notify caller after getting response
**                  pContext - caller context
**
** Returns          NFC status:
**                  NFCSTATUS_SUCCESS     - Read request to NFCC is successful
**                  NFCSTATUS_FAILED      - Read request failed due to internal error
**                  NFCSTATUS_NOT_ALLOWED - command not allowed
**                  Other command specific errors                -
**
*******************************************************************************/
NFCSTATUS phDnldNfc_ReadLog(pphDnldNfc_Buff_t pData, pphDnldNfc_RspCb_t pNotify, void *pContext)
{
    NFCSTATUS   wStatus = NFCSTATUS_SUCCESS;

    if((NULL == pNotify) || (NULL == pData) ||
       (NULL == pContext)
       )
    {
        NXPLOG_FWDNLD_E("Invalid Input Parameters!!");
        wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        if(phDnldNfc_TransitionIdle != gpphDnldContext->tDnldInProgress)
        {
            NXPLOG_FWDNLD_E("Dnld Cmd Request in Progress..Cannot Continue!!");
            wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_BUSY);
        }
        else
        {
            if((NULL != pData->pBuff) && (0 != pData->wLen))
            {
                (gpphDnldContext->tCmdId) = PH_DL_CMD_READ;
                (gpphDnldContext->FrameInp.Type) = phDnldNfc_FTRead;
                (gpphDnldContext->FrameInp.dwAddr) = PHDNLDNFC_EEPROM_LOG_START_ADDR;
                (gpphDnldContext->tRspBuffInfo.pBuff) = pData->pBuff;
                (gpphDnldContext->tRspBuffInfo.wLen) = pData->wLen;
                (gpphDnldContext->tUserData.pBuff) = NULL;
                (gpphDnldContext->tUserData.wLen) = 0;
                (gpphDnldContext->UserCb) = pNotify;
                (gpphDnldContext->UserCtxt) = pContext;

                memset(&(gpphDnldContext->tRWInfo),0,sizeof(gpphDnldContext->tRWInfo));

                wStatus = phDnldNfc_CmdHandler(gpphDnldContext,phDnldNfc_EventRead);

                if(NFCSTATUS_PENDING == wStatus)
                {
                    NXPLOG_FWDNLD_D("Read Request submitted successfully");
                }
                else
                {
                    NXPLOG_FWDNLD_E("Read Request Failed!!");
                }
            }
            else
            {
                NXPLOG_FWDNLD_E("Invalid Buff Parameters!!");
                wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_INVALID_PARAMETER);
            }
        }
    }

    return wStatus;
}
/*******************************************************************************
**
** Function         phTmlNfc_Write
**
** Description      Asynchronously writes given data block to hardware interface/driver
**                  Enables writer thread if there are no write requests pending
**                  Returns successfully once writer thread completes write operation
**                  Notifies upper layer using callback mechanism
**                  NOTE:
**                  * it is important to post a message with id PH_TMLNFC_WRITE_MESSAGE
**                    to IntegrationThread after data has been written to PN54X
**                  * if CRC needs to be computed, then input buffer should be capable to store
**                    two more bytes apart from length of packet
**
** Parameters       pBuffer              - data to be sent
**                  wLength              - length of data buffer
**                  pTmlWriteComplete    - pointer to the function to be invoked upon completion
**                  pContext             - context provided by upper layer
**
** Returns          NFC status:
**                  NFCSTATUS_PENDING             - command is yet to be processed
**                  NFCSTATUS_INVALID_PARAMETER   - at least one parameter is invalid
**                  NFCSTATUS_BUSY                - write request is already in progress
**
*******************************************************************************/
NFCSTATUS phTmlNfc_Write(uint8_t *pBuffer, uint16_t wLength, pphTmlNfc_TransactCompletionCb_t pTmlWriteComplete, void *pContext)
{
    NFCSTATUS wWriteStatus;

    /* Check whether TML is Initialized */

    if (NULL != gpphTmlNfc_Context)
    {
        if ((NULL != gpphTmlNfc_Context->pDevHandle) && (NULL != pBuffer) &&
                (PH_TMLNFC_RESET_VALUE != wLength) && (NULL != pTmlWriteComplete))
        {
            if (!gpphTmlNfc_Context->tWriteInfo.bThreadBusy)
            {
                /* Setting the flag marks beginning of a Write Operation */
                gpphTmlNfc_Context->tWriteInfo.bThreadBusy = TRUE;
                /* Copy the buffer, length and Callback function,
                   This shall be utilized while invoking the Callback function in thread */
                gpphTmlNfc_Context->tWriteInfo.pBuffer = pBuffer;
                gpphTmlNfc_Context->tWriteInfo.wLength = wLength;
                gpphTmlNfc_Context->tWriteInfo.pThread_Callback = pTmlWriteComplete;
                gpphTmlNfc_Context->tWriteInfo.pContext = pContext;

                wWriteStatus = NFCSTATUS_PENDING;
                //FIXME: If retry is going on. Stop the retry thread/timer
                if (phTmlNfc_e_EnableRetrans == gpphTmlNfc_Context->eConfig)
                {
                    /* Set retry count to default value */
                    //FIXME: If the timer expired there, and meanwhile we have created
                    // a new request. The expired timer will think that retry is still
                    // ongoing.
                    bCurrentRetryCount = gpphTmlNfc_Context->bRetryCount;
                    gpphTmlNfc_Context->bWriteCbInvoked = FALSE;
                }
                /* Set event to invoke Writer Thread */
                gpphTmlNfc_Context->tWriteInfo.bEnable = 1;
                sem_post(&gpphTmlNfc_Context->txSemaphore);
            }
            else
            {
                wWriteStatus = PHNFCSTVAL(CID_NFC_TML, NFCSTATUS_BUSY);
            }
        }
        else
        {
            wWriteStatus = PHNFCSTVAL(CID_NFC_TML, NFCSTATUS_INVALID_PARAMETER);
        }
    }
    else
    {
        wWriteStatus = PHNFCSTVAL(CID_NFC_TML, NFCSTATUS_NOT_INITIALISED);
    }

    return wWriteStatus;
}
Esempio n. 4
0
/*******************************************************************************
**
** Function         phDnldNfc_RawReq
**
** Description      Sends raw frame request to NFCC.
**                  It is currently used for sending an NCI RESET cmd after doing a production key update
**
** Parameters       pFrameData - input buffer, contains raw frame packet to be sent to NFCC
**                  pRspData   - response buffer received from NFCC
**                  pNotify    - notify caller after getting response
**                  pContext   - caller context
**
** Returns          NFC status:
**                  NFCSTATUS_SUCCESS     - GetSessionState request to NFCC is successful
**                  NFCSTATUS_FAILED      - GetSessionState request failed due to internal error
**                  NFCSTATUS_NOT_ALLOWED - command not allowed
**                  Other command specific errors                -
**
*******************************************************************************/
NFCSTATUS phDnldNfc_RawReq(pphDnldNfc_Buff_t pFrameData, pphDnldNfc_Buff_t pRspData, pphDnldNfc_RspCb_t pNotify, void *pContext)
{
    NFCSTATUS   wStatus = NFCSTATUS_SUCCESS;

    if((NULL == pFrameData) || (NULL == pNotify) || (NULL == pRspData) ||
       (NULL == pContext)
       )
    {
        NXPLOG_FWDNLD_E("Invalid Input Parameters!!");
        wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        if(phDnldNfc_TransitionIdle != gpphDnldContext->tDnldInProgress)
        {
            NXPLOG_FWDNLD_E("Raw Cmd Request in Progress..Cannot Continue!!");
            wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_BUSY);
        }
        else
        {
            if(((NULL != pFrameData->pBuff) && (0 != pFrameData->wLen)) &&
                ((NULL != pRspData->pBuff) && (0 != pRspData->wLen))
                )
            {
                (gpphDnldContext->tRspBuffInfo.pBuff) = pRspData->pBuff;
                (gpphDnldContext->tRspBuffInfo.wLen) = pRspData->wLen;
                (gpphDnldContext->FrameInp.Type) = phDnldNfc_FTRaw;
                (gpphDnldContext->tCmdId) = PH_DL_CMD_NONE;
                (gpphDnldContext->tUserData.pBuff) = pFrameData->pBuff;
                (gpphDnldContext->tUserData.wLen) = pFrameData->wLen;
                (gpphDnldContext->UserCb) = pNotify;
                (gpphDnldContext->UserCtxt) = pContext;

                wStatus = phDnldNfc_CmdHandler(gpphDnldContext,phDnldNfc_EventRaw);

                if(NFCSTATUS_PENDING == wStatus)
                {
                    NXPLOG_FWDNLD_D("RawFrame Request submitted successfully");
                }
                else
                {
                    NXPLOG_FWDNLD_E("RawFrame Request Failed!!");
                }
            }
            else
            {
                NXPLOG_FWDNLD_E("Invalid Buff Parameters!!");
                wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_INVALID_PARAMETER);
            }
        }
    }

    return wStatus;
}
NFCSTATUS phFriNfc_LlcpMac_ChkLlcp (phFriNfc_LlcpMac_t                  *LlcpMac, 
                                    phHal_sRemoteDevInformation_t       *psRemoteDevInfo,
                                    phFriNfc_LlcpMac_Chk_CB_t           ChkLlcpMac_Cb,
                                    void                                *pContext)
{
   NFCSTATUS status = NFCSTATUS_SUCCESS;
   if (NULL == LlcpMac || NULL == psRemoteDevInfo)
   {
      status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
   }
   else
   {
      /* Store the Remote Device info received from Device Discovery  */
      LlcpMac->psRemoteDevInfo = psRemoteDevInfo;

      if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Initiator)
      {
         /* Set the PeerRemoteDevType variable to the Target type */
         LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeTarget;
      }
      else if(LlcpMac->psRemoteDevInfo->RemDevType == phHal_eNfcIP1_Target)
      {
         /* Set the PeerRemoteDevType variable to the Initiator type */
         LlcpMac->PeerRemoteDevType = phFriNfc_LlcpMac_ePeerTypeInitiator;
      }

      switch(LlcpMac->psRemoteDevInfo->RemDevType)
      {
      case phHal_eNfcIP1_Initiator:
      case phHal_eNfcIP1_Target:
         {
            /* Set the MAC mapping type detected */
            LlcpMac->MacType = phFriNfc_LlcpMac_eTypeNfcip;

            /* Register the lower layer to the MAC mapping component */
            status = phFriNfc_LlcpMac_Nfcip_Register (LlcpMac); 
            if(status == NFCSTATUS_SUCCESS)
            {
               status  = LlcpMac->LlcpMacInterface.chk(LlcpMac,ChkLlcpMac_Cb,pContext);
            }
            else
            {
               status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_FAILED);
            }
         }break;
      default:
         {
            status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_DEVICE);
         }break;
      }
   }

   return status;
}
NFCSTATUS
phHciNfc_ReaderB_Set_LayerData(
                        void            *psContext,
                        void            *pHwRef,
                        phNfc_sData_t   *layer_data_info
                        )
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t         *psHciContext = 
                                (phHciNfc_sContext_t *)psContext ;

    if( (NULL == psHciContext) || (NULL == pHwRef) || 
        (NULL == layer_data_info) || (NULL == layer_data_info->buffer)
        || (0 == layer_data_info->length))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_b_info) || 
        (HCI_READER_B_ENABLE != 
        ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))->
        enable_rdr_b_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderB_Info_t     *ps_rdr_b_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *)
                        psHciContext->p_reader_b_info ;
        p_pipe_info = ps_rdr_b_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_DATA_INDEX;
            pipeid = ps_rdr_b_info->pipe_id ;
            p_pipe_info->param_info = (void *)layer_data_info->buffer;
            p_pipe_info->param_length = (uint8_t)
                                        layer_data_info->length;
            /* Fill the data buffer and send the command to the 
            device */
            status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                                pipeid, (uint8_t)ANY_SET_PARAMETER);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_SWP_Configure_Mode(
                              void              *psHciHandle,
                              void              *pHwRef,
                              uint8_t           uicc_mode
                          )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    static uint8_t          param = 0;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)
                                            psHciHandle);
    
    if( (NULL == psHciContext)||(NULL == pHwRef))
    {
      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if ( NULL == psHciContext->p_swp_info )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, 
                        NFCSTATUS_INVALID_HCI_INFORMATION);
    }
    else
    {
        phHciNfc_SWP_Info_t         *ps_swp_info=NULL;
        phHciNfc_Pipe_Info_t        *ps_pipe_info=NULL;
        
        ps_swp_info = (phHciNfc_SWP_Info_t*)psHciContext->p_swp_info;
       
        ps_pipe_info = ps_swp_info->p_pipe_info;
        if(NULL == ps_pipe_info)
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                                NFCSTATUS_INVALID_HCI_INFORMATION);
        }
        else
        {
            /* Switch the Mode of the SmartMx */
            param = uicc_mode;
            ps_pipe_info->param_info =(void*)&param ;
            ps_pipe_info->param_length = sizeof(param) ;
            status = phHciNfc_Send_SWP_Event( psHciContext, pHwRef,
                                            ps_swp_info->pipe_id, 
                                            NXP_EVT_SWP_SWITCH_MODE );

            /* Send the Success Status as this is an event */
            status = ((status == NFCSTATUS_PENDING)?
                    NFCSTATUS_SUCCESS : status);

        }/* End of else part*/
    } 
    return status;
}
/*!
 * \brief Receives the HCI Admin Event from the corresponding peripheral device.
 *
 * This function receives  the HCI Admin Events from the connected NFC Pheripheral
 * device
 */
static
 NFCSTATUS
 phHciNfc_Recv_Admin_Event (
                        void                *psContext,
                        void                *pHwRef,
                        uint8_t             *pEvent,
#ifdef ONE_BYTE_LEN
                        uint8_t             length
#else
                        uint16_t            length
#endif
                     )
{
    phHciNfc_sContext_t         *psHciContext = 
                                    (phHciNfc_sContext_t *)psContext ;
    phHciNfc_HCP_Packet_t       *hcp_packet = NULL;
    phHciNfc_HCP_Message_t      *hcp_message = NULL;
    uint8_t                     event = (uint8_t) HCP_MSG_INSTRUCTION_INVALID;
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;

    if( (NULL == psHciContext) 
        || (NULL == pHwRef) 
        || (HCP_HEADER_LEN > length ) 
      )
    {
      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        hcp_packet = (phHciNfc_HCP_Packet_t *)pEvent;
        hcp_message = &hcp_packet->msg.message;
        /* Get the Command instruction bits from the Message Header */
        event = (uint8_t) GET_BITS8( hcp_message->msg_header,
            HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN);

        if( EVT_HOT_PLUG ==   event )
        {
            status = phHciNfc_Send_Admin_Event ( psHciContext, pHwRef, 
                                EVT_HOT_PLUG, 0 ,NULL);

        }
        else
        {
            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INSTRUCTION);
        }


    }
    return status;
}
Esempio n. 9
0
NFCSTATUS
phHciNfc_Felica_Request_Mode(
                              phHciNfc_sContext_t   *psHciContext,
                              void                  *pHwRef)
{
    NFCSTATUS           status = NFCSTATUS_SUCCESS;
    static uint8_t      pres_chk_data[6] = {0};

    if( (NULL == psHciContext) || (NULL == pHwRef) )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        phHciNfc_Felica_Info_t          *ps_fel_info = NULL;
        phHciNfc_Pipe_Info_t            *ps_pipe_info = NULL;
        phHal_sFelicaInfo_t             *ps_rem_fel_info = NULL;

        ps_fel_info = (phHciNfc_Felica_Info_t *)
                            psHciContext->p_felica_info ;
        ps_pipe_info = ps_fel_info->p_pipe_info;
        
        if(NULL == ps_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            ps_rem_fel_info = 
                &(ps_fel_info->felica_info.RemoteDevInfo.Felica_Info);

            pres_chk_data[0] = sizeof(pres_chk_data);
            pres_chk_data[1] = 0x00; // Felica poll
            pres_chk_data[2] = 0xFF;
            pres_chk_data[3] = 0xFF;
            pres_chk_data[4] = 0x00;
            pres_chk_data[5] = 0x00;

            ps_pipe_info->param_info = pres_chk_data;
            ps_pipe_info->param_length = sizeof(pres_chk_data);
            status = phHciNfc_Send_Felica_Command(
                                        psHciContext, pHwRef, 
                                        ps_pipe_info->pipe.pipe_id, 
                                        NXP_FELICA_RAW);
        }
    }

    return status;
}
Esempio n. 10
0
NFCSTATUS
phHciNfc_Felica_Update_Info(
                             phHciNfc_sContext_t        *psHciContext,
                             uint8_t                    infotype,
                             void                       *fel_info
                             )
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    
    if (NULL == psHciContext)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if(NULL == psHciContext->p_felica_info)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_Felica_Info_t     *p_fel_info=NULL;
        p_fel_info = (phHciNfc_Felica_Info_t *)
                        psHciContext->p_felica_info ;

        switch(infotype)
        {
            case HCI_FELICA_ENABLE:
            {
                if (NULL != fel_info)
                {
                    p_fel_info->enable_felica_gate = 
                                        *((uint8_t *)fel_info);
                }
                break;
            }
            case HCI_FELICA_INFO_SEQ:
            {
                p_fel_info->current_seq = FELICA_SYSTEMCODE;
                p_fel_info->next_seq = FELICA_SYSTEMCODE;
                break;
            }           
            default:
            {
                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
                break;
            }
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_ReaderB_Update_Info(
                             phHciNfc_sContext_t        *psHciContext,
                             uint8_t                    infotype,
                             void                       *rdr_b_info
                             )
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    
    if (NULL == psHciContext)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if(NULL == psHciContext->p_reader_b_info)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderB_Info_t     *ps_rdr_b_info=NULL;
        ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *)
                        psHciContext->p_reader_b_info ;

        switch(infotype)
        {
            case HCI_READER_B_ENABLE:
            {
                if(NULL != rdr_b_info)
                {
                    ps_rdr_b_info->enable_rdr_b_gate = 
                                *((uint8_t *)rdr_b_info);
                }
                break;
            }
            case HCI_READER_B_INFO_SEQ:
            {
                ps_rdr_b_info->current_seq = RDR_B_PUPI;
                ps_rdr_b_info->next_seq = RDR_B_PUPI;
                break;
            }
            default:
            {
                status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
                break;
            }
        }
    }
    return status;
}
Esempio n. 12
0
static
NFCSTATUS
phHciNfc_LinkMgmt_InfoUpdate(
                                phHciNfc_sContext_t     *psHciContext,
                                phHal_sHwReference_t    *pHwRef,
                                uint8_t                 index,
                                uint8_t                 *reg_value,
                                uint8_t                 reg_length
                          )
{
    phHciNfc_LinkMgmt_Info_t    *p_link_mgmt_info=NULL;
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    uint8_t                     i=0;
    if( (NULL == psHciContext)
        || (NULL == pHwRef)
        || (NULL == reg_value)
        || (reg_length == 0)
      )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if ( NULL == psHciContext->p_link_mgmt_info )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
    }
    else
    {
        p_link_mgmt_info = (phHciNfc_LinkMgmt_Info_t *)
                                psHciContext->p_link_mgmt_info ;
        if (REC_ERROR_INDEX == index)
        {
            HCI_PRINT_BUFFER("\tHost Controller REC Error Count :",reg_value,reg_length);
            /* p_link_mgmt_info->hc_rec_error = reg_value[i] ; */
            for(i=0 ;(reg_length == REC_RETRY_LEN)&&(i < reg_length); i++)
            {
                p_link_mgmt_info->hc_rec_error |= 
                            (uint16_t)(reg_value[i] << (BYTE_SIZE * i));
            }
        }
        else
        {
            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
        } /* End of the Index Check */

    } /* End of Context and the Link information validity check */

    return status;
}
NFCSTATUS
phFriNfc_NdefSmtCrd_ConvertToReadOnly (
    phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
{
    NFCSTATUS   result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                  NFCSTATUS_INVALID_PARAMETER);
    uint8_t     sak = 0;

    if((NdefSmtCrdFmt != NULL)
        && (NdefSmtCrdFmt->CompletionRoutine->CompletionRoutine != NULL)
        && (NdefSmtCrdFmt->CompletionRoutine->Context != NULL))
    {
        sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Sak;
        switch (NdefSmtCrdFmt->psRemoteDevInfo->RemDevType)
        {
            case phHal_eMifare_PICC:
            {
                if (0x00 == sak)
                {
                    result = phFriNfc_MfUL_ConvertToReadOnly (NdefSmtCrdFmt);
                }
                else
                {
                    /* MIFARE classic 1k/4k is not supported */
                    result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
                }
                break;
            }

            case phHal_eISO14443_A_PICC:
            {
                result = phFriNfc_Desfire_ConvertToReadOnly (NdefSmtCrdFmt);
                break;
            }

            default :
            {
                /*  Remote device is not recognised.
                Probably not NDEF compliant */
                result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
                break;
            }
        }
    }
    return result;
}
Esempio n. 14
0
NFCSTATUS
phHciNfc_ReaderA_Fwi_Sfgt (
    void             *psHciHandle,
    void             *pHwRef
)
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);
    if( (NULL == psHciContext)
            || (NULL == pHwRef)
      )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_a_info) ||
            (HCI_READER_A_ENABLE !=
             ((phHciNfc_ReaderA_Info_t *)(psHciContext->p_reader_a_info))->
             enable_rdr_a_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderA_Info_t     *p_rdr_a_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_rdr_a_info = (phHciNfc_ReaderA_Info_t *)
                       psHciContext->p_reader_a_info ;
        p_pipe_info = p_rdr_a_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI,
                                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            p_pipe_info->reg_index = RDR_A_FWI_SFGT_INDEX;
            pipeid = p_rdr_a_info->pipe_id ;
            /* Fill the data buffer and send the command to the
            device */
            status =
                phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
                                           pipeid, (uint8_t)ANY_GET_PARAMETER);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_Delete_Pipe(
                        phHciNfc_sContext_t     *psHciContext,
                        void                    *pHwRef,
                        phHciNfc_Pipe_Info_t    *pPipeHandle
                    )
{
    NFCSTATUS       status=NFCSTATUS_SUCCESS;
    NFCSTATUS       cmd_status = NFCSTATUS_SUCCESS;

    if( (NULL == psHciContext)
        || (NULL == pHwRef)
        || (NULL == pPipeHandle)
     )
    {
      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        cmd_status = phHciNfc_Send_Admin_Cmd( psHciContext, pHwRef,
                            ADM_DELETE_PIPE, PIPEID_LEN, pPipeHandle );
        status = ( (cmd_status == NFCSTATUS_PENDING)?
                                        NFCSTATUS_SUCCESS : cmd_status);
    }

    return status;
}
NFCSTATUS
phHciNfc_Close_Pipe(
                        phHciNfc_sContext_t     *psHciContext,
                        void                    *pHwRef,
                        phHciNfc_Pipe_Info_t    *pPipeHandle
                    )
{
    uint8_t                 pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    NFCSTATUS               cmd_status = NFCSTATUS_SUCCESS;

    if( (NULL == psHciContext)
        || ( NULL == pHwRef )
        || ( NULL == pPipeHandle )
      )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        /* Obtain the pipe_id from the pipe_handle */
        pipe_id = pPipeHandle->pipe.pipe_id;

        if( (uint8_t)HCI_UNKNOWN_PIPE_ID > pipe_id)
        {
            cmd_status = phHciNfc_Send_Generic_Cmd(
                                        psHciContext, pHwRef, pipe_id,
                                        ANY_CLOSE_PIPE );

            status = ((cmd_status == NFCSTATUS_PENDING)?
                                NFCSTATUS_SUCCESS : cmd_status);
        }
    }
    return status;
}
static
NFCSTATUS
phHciNfc_Recv_Iso_B_Packet(
                           phHciNfc_sContext_t  *psHciContext,
                           uint8_t              *pResponse,
#ifdef ONE_BYTE_LEN
                           uint8_t             length
#else
                           uint16_t            length
#endif
                           )
{
    NFCSTATUS       status = NFCSTATUS_SUCCESS;
    uint8_t         i = 1;        
    
    psHciContext->rx_index = HCP_HEADER_LEN;
    /* command WR_XCHG_DATA: so give ISO 14443-4B data to the upper layer */
    HCI_PRINT_BUFFER("ISO 14443-4B Bytes received", pResponse, length); 
    if(FALSE != pResponse[(length - i)])
    {
        status = PHNFCSTVAL(CID_NFC_HCI, 
                            NFCSTATUS_RF_ERROR);
    }
    return status;
}
static
NFCSTATUS
phFriNfc_LlcpMac_Nfcip_Activate(
    _Inout_ phFriNfc_LlcpMac_t *LlcpMac
    )
{
   NFCSTATUS status  = NFCSTATUS_SUCCESS;

   PH_LOG_LLCP_FUNC_ENTRY();
   if(LlcpMac == NULL)
   {
       PH_LOG_LLCP_WARN_STR("Invalid 'LlcpMac' pointer");
      status = PHNFCSTVAL(CID_FRI_NFC_LLCP_MAC, NFCSTATUS_INVALID_PARAMETER);
   }
   else
   {
       PH_LOG_LLCP_INFO_STR("Invoking LinkStatus_Cb with link state 'phFriNfc_LlcpMac_eLinkActivated'");
      LlcpMac->LinkState = phFriNfc_LlcpMac_eLinkActivated;
      LlcpMac->LinkStatus_Cb(LlcpMac->LinkStatus_Context,
                             LlcpMac->LinkState,
                             &LlcpMac->sConfigParam,
                             LlcpMac->PeerRemoteDevType);
   }
   PH_LOG_LLCP_INFO_X32MSG("Return:",status);
   PH_LOG_LLCP_FUNC_EXIT();
   return status;
}
NFCSTATUS phFriNfc_OvrHal_Connect(phFriNfc_OvrHal_t              *OvrHal,
                                        phFriNfc_CplRt_t               *CompletionInfo,
                                        phHal_sRemoteDevInformation_t  *RemoteDevInfo,
                                        phHal_sDevInputParam_t         *DevInputParam)
{
    NFCSTATUS status = NFCSTATUS_PENDING;
         
    /* Check the Input Parameters */
    if((NULL == OvrHal) || (NULL == CompletionInfo) || (NULL == RemoteDevInfo) ||
        (NULL == DevInputParam))
    {
        status = PHNFCSTVAL(CID_FRI_NFC_OVR_HAL ,NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        phFriNfc_OvrHal_SetComplInfo(OvrHal, CompletionInfo, PH_FRINFC_OVRHAL_CON);

        status = phHal4Nfc_Connect(
                                    OvrHal->psHwReference, 
                                    RemoteDevInfo,                                    
                                    phFriNfc_OvrHal_CB_ConnectDisconnect,
                                    (void *)OvrHal
                                    );
    }

    return status;
}
static NFCSTATUS
phFriNfc_TopazDynamicFormat_ProcessWritingTermTlvBytes(phFriNfc_sNdefSmtCrdFmt_t* NdefSmtCrdFmt)
{
    static const uint8_t c_expectedResponse[] =
    {
        PH_FRINFC_TOPAZ_TLV_TERM_T, /* Terminator TLV */
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Rest of data bytes are zeros */
    };

    NFCSTATUS wStatus = NFCSTATUS_SUCCESS;

    PH_LOG_NDEF_FUNC_ENTRY();

    assert(NdefSmtCrdFmt != NULL);

    if ((*NdefSmtCrdFmt->SendRecvLength != sizeof(c_expectedResponse)) ||
        (0 != phOsalNfc_MemCompare(NdefSmtCrdFmt->SendRecvBuf,
                                   (void*)c_expectedResponse,
                                   sizeof(c_expectedResponse))))
    {
        PH_LOG_NDEF_WARN_STR("Unexpected response received. Formatting failed");
        wStatus = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_FORMAT_ERROR);
    }
    else
    {
        PH_LOG_NDEF_INFO_STR("Successfully formatted dynamic Topaz card");
    }

    PH_LOG_NDEF_FUNC_EXIT();
    return wStatus;
}
NFCSTATUS
phFriNfc_TopazFormat_Format(phFriNfc_sNdefSmtCrdFmt_t* NdefSmtCrdFmt)
{
    NFCSTATUS wStatus = NFCSTATUS_SUCCESS;

    PH_LOG_NDEF_FUNC_ENTRY();

    if (NdefSmtCrdFmt == NULL)
    {
        wStatus = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        NdefSmtCrdFmt->State = 0;

        phOsalNfc_SetMemory(&NdefSmtCrdFmt->AddInfo.Type1Info,
                            0,
                            sizeof(NdefSmtCrdFmt->AddInfo.Type1Info));

        NdefSmtCrdFmt->AddInfo.Type1Info.CurrentBlock = 0x01;
        NdefSmtCrdFmt->AddInfo.Type1Info.CurrentByte = 0;

        wStatus = phFriNfc_TopazFormat_WriteByte(NdefSmtCrdFmt,
                                                 NdefSmtCrdFmt->AddInfo.Type1Info.CurrentBlock,
                                                 NdefSmtCrdFmt->AddInfo.Type1Info.CurrentByte,
                                                 c_staticTopazFormat[NdefSmtCrdFmt->AddInfo.Type1Info.CurrentByte]);
    }

    PH_LOG_NDEF_FUNC_EXIT();
    return wStatus;
}
NFCSTATUS 
phFriNfc_ISO15693_Format (
    phFriNfc_sNdefSmtCrdFmt_t *psNdefSmtCrdFmt)
{
    NFCSTATUS                       result = NFCSTATUS_SUCCESS;
    phHal_sIso15693Info_t           *ps_rem_iso_15693_info = 
                        &(psNdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso15693_Info);
    
    
    if ((ISO15693_7TH_BYTE_UID_VALUE == 
        ps_rem_iso_15693_info->Uid[ISO15693_BYTE_7_INDEX]) 
        && (ISO15693_6TH_BYTE_UID_VALUE == 
        ps_rem_iso_15693_info->Uid[ISO15693_BYTE_6_INDEX]))
    {
        /* Check if the card is manufactured by NXP (6th byte 
        index of UID value = 0x04 and the 
        last byte of UID is 0xE0, only then the card detected 
        is NDEF compliant */
        psNdefSmtCrdFmt->State = ISO15693_FORMAT;

        /* GET system information command to get the card size */
        result = phFriNfc_ISO15693_H_FmtReadWrite (psNdefSmtCrdFmt, 
                            ISO15693_GET_SYSTEM_INFO_CMD, NULL, 0);
    }
    else
    {
        result = PHNFCSTVAL (CID_FRI_NFC_NDEF_SMTCRDFMT, 
                            NFCSTATUS_INVALID_DEVICE_REQUEST);
    }

    return result;
}
NFCSTATUS
phHciNfc_Admin_Release(
                                phHciNfc_sContext_t     *psHciContext,
                                void                    *pHwRef,
                                phHciNfc_HostID_t        host_type
                             )
{
    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
    phHciNfc_Pipe_Info_t                *p_pipe_info = NULL;

    if( (NULL == psHciContext) || (NULL == pHwRef) )
    {
      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        if( NULL != psHciContext->p_admin_info )
        {
            if(phHciNfc_UICCHostID != host_type)
            {
                p_pipe_info = psHciContext->p_pipe_list[PIPETYPE_STATIC_ADMIN];

                status = phHciNfc_Close_Pipe( psHciContext,
                                                    pHwRef, p_pipe_info );
            }

        }/* End of NULL Check for the Admin_Info */
    } /* End of Null Check for the Context */
    return status;
}
uint32_t phOsalNfc_Timer_Create(void)
{
    uint32_t i = 0;

    if (NULL == gpphOsalNfc_Context) {
        return PHNFCSTVAL(CID_NFC_OSAL, NFCSTATUS_INVALID_PARAMETER);
    }

    EnterCriticalSection(&gpphOsalNfc_Context->TimerLock);

    while (i < PH_MAX_OSAL_NUM_TIMERS) 
    {
        /* check whether the timer is free. If free then only it is created */
        if(gpphOsalNfc_Context->TimerList[i].pTimer == NULL)
        {
            gpphOsalNfc_Context->TimerList[i].pTimer = CreateThreadpoolTimer(phOsalNfc_TimerCallback, (void*)i, NULL);
            gpphOsalNfc_Context->TimerList[i].dwThreadId = GetCurrentThreadId();
            break;
        }

        i++;
    }

    LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock);
    
    if ((i == PH_MAX_OSAL_NUM_TIMERS) || (gpphOsalNfc_Context->TimerList[i].pTimer == NULL))
    {
        return PH_OSALNFC_INVALID_TIMER_ID;
    }
    
    return (i + PH_OSAL_TIMER_BASE_ADDRESS);
}
NFCSTATUS phFriNfc_OvrHal_Send(phFriNfc_OvrHal_t              *OvrHal,
                               phFriNfc_CplRt_t               *CompletionInfo,
                               phHal_sRemoteDevInformation_t  *RemoteDevInfo,
                               uint8_t                        *SendBuf,
                               uint16_t                       SendLength)
{
   NFCSTATUS status = NFCSTATUS_PENDING;

   /* Check the Input Parameters */
   if(   (NULL==OvrHal) || (NULL==CompletionInfo) || (NULL==RemoteDevInfo) || (NULL==SendBuf)  )
   {
      status = PHNFCSTVAL(CID_FRI_NFC_OVR_HAL ,NFCSTATUS_INVALID_PARAMETER);
   }
   else
   {
      /* Get the remote dev type */
      OvrHal->TransactInfo.remotePCDType = RemoteDevInfo->RemDevType;
      /* Save the receive buffer for use in callback */
      OvrHal->sSendData.buffer = SendBuf;
      OvrHal->sSendData.length = SendLength;
      
      /* Set the callback */
      phFriNfc_OvrHal_SetComplInfo(OvrHal, CompletionInfo, PH_FRINFC_OVRHAL_SND);

      /* Call the HAL 4.0 Receive Function */
      status = phHal4Nfc_Send( OvrHal->psHwReference,
                               &OvrHal->TransactInfo,
                               OvrHal->sSendData,
                               phFriNfc_OvrHal_CB_Send,
                               (void *)OvrHal);
   }
   return status;
}
/* This starts the timer */ 
NFCSTATUS phOsalNfc_Timer_Start(uint32_t    TimerId,
                          uint32_t     dueTimeMsec, 
                          ppCallBck_t  pCallback,
                          void         *pContext)
{
    uint32_t  uIndex;
    LONGLONG  DueTime;
    uint32_t  uWindow = (dueTimeMsec < 50) ? 0 : (dueTimeMsec / 4);

    if (NULL == gpphOsalNfc_Context ||
        PH_OSALNFC_TIMER_ID_INVALID == TimerId) {
        return PHNFCSTVAL(CID_NFC_OSAL, NFCSTATUS_INVALID_PARAMETER);
    }

    uIndex = TimerId - PH_OSAL_TIMER_BASE_ADDRESS;
    
    // Convert dueTimeMsec to relative filetime units (100ns)
    DueTime = Int32x32To64(dueTimeMsec, -10000);

    EnterCriticalSection(&gpphOsalNfc_Context->TimerLock);

    SetThreadpoolTimer(gpphOsalNfc_Context->TimerList[uIndex].pTimer, (FILETIME*)&DueTime, 0, uWindow);
    gpphOsalNfc_Context->TimerList[uIndex].pCallback = pCallback;
    gpphOsalNfc_Context->TimerList[uIndex].pContext  = pContext;

    LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock);

    return NFCSTATUS_SUCCESS;
}
NFCSTATUS
phNciNfc_SetConnCredentials(void *psNciContext)
{
    NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
    pphNciNfc_Context_t psNciCtxt = (pphNciNfc_Context_t )psNciContext;

    PH_LOG_NCI_FUNC_ENTRY();

    if(NULL == psNciCtxt)
    {
        wStatus = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_INVALID_PARAMETER);
        PH_LOG_NCI_CRIT_STR(" Invalid Context Param..");
    }
    else
    {
        /* Update Static conn info with conn details & device handle */
        wStatus = phNciNfc_UpdateConnDestInfo(psNciCtxt->tActvDevIf.pDevInfo->bRfDiscId,
                                              phNciNfc_e_REMOTE_NFC_ENDPOINT,
                                              psNciCtxt->tActvDevIf.pDevInfo);
        if(NFCSTATUS_SUCCESS == wStatus)
        {
            PH_LOG_NCI_INFO_STR("Conn Credentials updated successfully..");
        }
        else
        {
            PH_LOG_NCI_CRIT_STR("Conn Credentials update failed!!..");
        }
    }
    PH_LOG_NCI_FUNC_EXIT();
    return wStatus;
}
NFCSTATUS
phHciNfc_SWP_Protection(
                            void        *psHciHandle,
                            void        *pHwRef,
                            uint8_t     mode
                      )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    static uint8_t          param = 0 ;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);

    if((NULL == psHciContext)||(NULL == pHwRef))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if(NULL == psHciContext->p_swp_info)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_SWP_Info_t         *ps_swp_info=NULL;
        phHciNfc_Pipe_Info_t        *ps_pipe_info=NULL;
        
        ps_swp_info = (phHciNfc_SWP_Info_t*)psHciContext->p_swp_info;       
        ps_pipe_info = ps_swp_info->p_pipe_info;

        if(NULL == ps_pipe_info)
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                                NFCSTATUS_INVALID_HCI_INFORMATION);
        }
        else
        {
            ps_pipe_info->reg_index = NXP_SWP_PROTECTED_INDEX;
            /* Enable/Disable SWP Protection */
            param = (uint8_t)mode;
            ps_pipe_info->param_info =(void*)&param ;
            ps_pipe_info->param_length = sizeof(param) ;
            status = phHciNfc_Send_Generic_Cmd(psHciContext, pHwRef, 
                                        ps_swp_info->pipe_id, 
                                        (uint8_t)ANY_SET_PARAMETER);
        }

    }
    return status;
}
Esempio n. 29
0
static
NFCSTATUS
phHciNfc_Recv_Mifare_Packet(
    phHciNfc_sContext_t  *psHciContext,
    uint8_t              cmd,
    uint8_t              *pResponse,
#ifdef ONE_BYTE_LEN
    uint8_t              length
#else
    uint16_t             length
#endif
)
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;

    /* To remove "warning (VS C4100) : unreferenced formal parameter" */
    PHNFC_UNUSED_VARIABLE(pResponse);
    PHNFC_UNUSED_VARIABLE(length);

    if (NXP_MIFARE_RAW == cmd)
    {
#ifdef ENABLE_MIFARE_RAW
        uint8_t                 index = 0;
#ifndef HAL_SW_3A_STATUS
        if(phHal_eISO14443_3A_PICC == psHciContext->p_target_info->RemDevType)
        {
            index++;
            psHciContext->rx_index = (index + HCP_HEADER_LEN);
            HCI_PRINT_BUFFER("Mifare Bytes received", &pResponse[index], (length - index));
        }
        else
#endif
            if (RDR_A_MIFARE_STATUS == pResponse[index])  /* Status byte */
            {
                index++;
                psHciContext->rx_index = (index + HCP_HEADER_LEN);
                HCI_PRINT_BUFFER("Mifare Bytes received", &pResponse[index], (length - index));
            }
            else
            {
                status = PHNFCSTVAL(CID_NFC_HCI,
                                    NFCSTATUS_INVALID_HCI_RESPONSE);
            }
#else
        psHciContext->rx_index = HCP_HEADER_LEN;
        /* Give Mifare data to the upper layer */
        HCI_PRINT_BUFFER("Mifare Bytes received", pResponse, length);
#endif /* #ifdef ENABLE_MIFARE_RAW */
    }
    else
    {
        psHciContext->rx_index = HCP_HEADER_LEN;
        /* command NXP_MIFARE_CMD: so give Mifare data to the upper layer */
        HCI_PRINT_BUFFER("Mifare Bytes received", pResponse, length);
    }

    return status;
}
Esempio n. 30
0
/*-----------------------------------------------------------------------------

FUNCTION: phDal4Nfc_Register

PURPOSE:  DAL register function.

-----------------------------------------------------------------------------*/
NFCSTATUS phDal4Nfc_Register( phNfcIF_sReference_t  *psRefer,
                              phNfcIF_sCallBack_t if_cb, void *psIFConf )
{
    NFCSTATUS               result = NFCSTATUS_SUCCESS;

    if ((NULL != psRefer) &&
            (NULL != psRefer->plower_if) &&
            (NULL != if_cb.receive_complete) &&
            (NULL != if_cb.send_complete)
       )
    {
        /* Register the LLC functions to the upper layer */
        psRefer->plower_if->init           = phDal4Nfc_Init;
        psRefer->plower_if->release        = phDal4Nfc_Shutdown;
        psRefer->plower_if->send           = phDal4Nfc_Write;
        psRefer->plower_if->receive        = phDal4Nfc_Read;
        psRefer->plower_if->receive_wait   = phDal4Nfc_ReadWait;
        psRefer->plower_if->transact_abort = phDal4Nfc_ReadWaitCancel;
        psRefer->plower_if->unregister     = phDal4Nfc_Unregister;


        if (NULL != pgDalContext)
        {
            /* Copy the DAL context to the upper layer */
            psRefer->plower_if->pcontext = pgDalContext;
            /* Register the callback function from the upper layer */
            pgDalContext->cb_if.receive_complete = if_cb.receive_complete;
            pgDalContext->cb_if.send_complete = if_cb.send_complete;
            pgDalContext->cb_if.notify = if_cb.notify;
            /* Get the upper layer context */
            pgDalContext->cb_if.pif_ctxt = if_cb.pif_ctxt;
            /* Update the error state */
            result = NFCSTATUS_SUCCESS;
        }
        else
        {
            result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_NOT_INITIALISED);
        }
    }
    else /*Input parameters invalid*/
    {
        result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_INVALID_PARAMETER);
    }
    return result;
}