15d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
25d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Copyright (C) 2010 NXP Semiconductors
35d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
45d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Licensed under the Apache License, Version 2.0 (the "License");
55d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * you may not use this file except in compliance with the License.
65d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * You may obtain a copy of the License at
75d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
85d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *      http://www.apache.org/licenses/LICENSE-2.0
95d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Unless required by applicable law or agreed to in writing, software
115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * distributed under the License is distributed on an "AS IS" BASIS,
125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * See the License for the specific language governing permissions and
145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * limitations under the License.
155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \file phLibNfc_Target.c
195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Project: NFC FRI 1.1
215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Date: Thu Oct 15 15:24:43 2009 $
235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Author: ing07299 $
245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Revision: 1.12 $
255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Aliases: NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK944_SDK,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK949_SDK_INT,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK1003_SDK,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1008_SDK,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $
265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly************************* Header Files ***************************************
315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfcStatus.h>
345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc.h>
355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHal4Nfc.h>
365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h>
375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_Internal.h>
385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_ndef_raw.h>
395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_initiator.h>
405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc_discovery.h>
415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Macro's  ****************************************
445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef STATIC_DISABLE
475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC static
485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly//#undef STATIC
505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC
515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Global Variables **********************************
545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration ***********************
585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Remote device receive callback */
615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_RemoteDev_Receive_Cb(
625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void            *context,
635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phNfc_sData_t   *rec_rsp_data,
645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                NFCSTATUS       status
655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                );
665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Remote device Send callback */
685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_RemoteDev_Send_Cb(
695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void        *Context,
705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                NFCSTATUS   status
715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                );
725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions ******************************
755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**
785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Interface used to receive data from initiator at target side during P2P
795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* communication.
805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phLibNfc_RemoteDev_Receive(phLibNfc_Handle       hRemoteDevice,
825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                pphLibNfc_Receive_RspCb_t  pReceiveRspCb,
835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                       *pContext
845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                )
855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS RetVal = NFCSTATUS_FAILED;
875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /*Check Lib Nfc is initialized*/
885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if((NULL == gpphLibContext)||
895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_NOT_INITIALISED;
925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/*Check application has sent valid parameters*/
935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateRelease)
945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_DESELECTED;
965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if((NULL == pReceiveRspCb)
985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pContext)
995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (0 == hRemoteDevice))
1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal= NFCSTATUS_INVALID_PARAMETER;
1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_SHUTDOWN;
1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if((TRUE == gpphLibContext->status.GenCb_pending_status)
1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL!=gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb)
1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(phHal_eNfcIP1_Target==
1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType))
1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /*Previous callback is pending or if initiator uses this api */
1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_REJECTED;
1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/*check for Discovered initiator handle and handle sent by application */
1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(gpphLibContext->sNfcIp_Context.Rem_Initiator_Handle != hRemoteDevice)
1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal= NFCSTATUS_INVALID_DEVICE;
1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1196e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas#ifdef LLCP_TRANSACT_CHANGES
1206e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    else if ((LLCP_STATE_RESET_INIT != gpphLibContext->llcp_cntx.sLlcpContext.state)
1216e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas            && (LLCP_STATE_CHECKED != gpphLibContext->llcp_cntx.sLlcpContext.state))
1226e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    {
1236e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas        RetVal = NFCSTATUS_BUSY;
1246e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    }
1256e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas#endif /* #ifdef LLCP_TRANSACT_CHANGES */
1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(eLibNfcHalStatePresenceChk ==
1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->LibNfcState.next_state)
1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb = NULL;
1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            RetVal = NFCSTATUS_PENDING;
1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /*Call below layer receive and register the callback with it*/
1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            PHDBG_INFO("LibNfc:P2P Receive In Progress");
1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            RetVal =phHal4Nfc_Receive(
1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            gpphLibContext->psHwReference,
1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            (phHal4Nfc_TransactInfo_t*)gpphLibContext->psTransInfo,
1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            (pphLibNfc_Receive_RspCb_t)
1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            phLibNfc_RemoteDev_Receive_Cb,
1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            (void *)gpphLibContext
1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            );
1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NFCSTATUS_PENDING == RetVal)
1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /*Update the Next state as Transaction*/
1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb= pReceiveRspCb;
1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx = pContext;
1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->status.GenCb_pending_status=TRUE;
1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->LibNfcState.next_state = eLibNfcHalStateTransaction;
1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            RetVal = NFCSTATUS_FAILED;
1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return RetVal;
1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**
1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Response callback for Remote Device Receive.
1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_RemoteDev_Receive_Cb(
1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    void            *context,
1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    phNfc_sData_t   *rec_rsp_data,
1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFCSTATUS       status
1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    )
1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    pphLibNfc_Receive_RspCb_t       pClientCb=NULL;
1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phLibNfc_LibContext_t   *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)context;
1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    void                    *pUpperLayerContext=NULL;
1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* Check for the context returned by below layer */
1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if(pLibNfc_Ctxt != gpphLibContext)
1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {   /*wrong context returned*/
1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        pClientCb = gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb;
1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        pUpperLayerContext = gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx;
1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb = NULL;
1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        gpphLibContext->sNfcIp_Context.pClientNfcIpRxCntx = NULL;
1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        gpphLibContext->status.GenCb_pending_status = FALSE;
1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {   /*shutdown called before completion of P2P receive allow
1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly              shutdown to happen */
1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            phLibNfc_Pending_Shutdown();
1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = NFCSTATUS_SHUTDOWN;
1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if(eLibNfcHalStateRelease == gpphLibContext->LibNfcState.next_state)
1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = NFCSTATUS_ABORTED;
1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if((NFCSTATUS_SUCCESS != status) &&
2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                (PHNFCSTATUS(status) != NFCSTATUS_MORE_INFORMATION ) )
2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /*During p2p receive operation initiator was removed
2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                from RF field of target*/
2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = NFCSTATUS_DESELECTED;
2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            else
2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = NFCSTATUS_SUCCESS;
2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /* Update current state */
2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phLibNfc_UpdateCurState(status,gpphLibContext);
2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if (NULL != pClientCb)
2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /*Notify to upper layer status and No. of bytes
2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly             actually received */
2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pClientCb(pUpperLayerContext, rec_rsp_data, status);
2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return;
2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**
2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Interface used to send data from target to initiator during P2P communication
2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphLibNfc_RemoteDev_Send(
2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        phLibNfc_Handle      hRemoteDevice,
2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        phNfc_sData_t *      pTransferData,
2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        pphLibNfc_RspCb_t    pSendRspCb,
2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                 *pContext
2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        )
2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS RetVal = NFCSTATUS_FAILED;
2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /*Check Lib Nfc stack is initilized*/
2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if((NULL == gpphLibContext)||
2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_NOT_INITIALISED;
2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateRelease)
2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_DESELECTED;
2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /*Check application has sent the valid parameters*/
2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if((NULL == pTransferData)
2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pSendRspCb)
2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pTransferData->buffer)
2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (0 == pTransferData->length)
2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pContext)
2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (0 == hRemoteDevice))
2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal= NFCSTATUS_INVALID_PARAMETER;
2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_SHUTDOWN;
2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly	else if((TRUE == gpphLibContext->status.GenCb_pending_status)
2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL!=gpphLibContext->sNfcIp_Context.pClientNfcIpRxCb)
2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(phHal_eNfcIP1_Target==
2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType))
2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /*Previous callback is pending or local device is Initiator
2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        then don't allow */
2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal = NFCSTATUS_REJECTED;
2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/*Check for Discovered initiator handle and handle sent by application */
2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(gpphLibContext->sNfcIp_Context.Rem_Initiator_Handle != hRemoteDevice)
2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal= NFCSTATUS_INVALID_DEVICE;
2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if((NULL!=gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb))
2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        RetVal =NFCSTATUS_BUSY ;
2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2786e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas#ifdef LLCP_TRANSACT_CHANGES
2796e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    else if ((LLCP_STATE_RESET_INIT != gpphLibContext->llcp_cntx.sLlcpContext.state)
2806e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas            && (LLCP_STATE_CHECKED != gpphLibContext->llcp_cntx.sLlcpContext.state))
2816e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    {
2826e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas        RetVal= NFCSTATUS_BUSY;
2836e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas    }
2846e286043593b281d161dad4969e05ba9c53ef6d1daniel_Tomas#endif /* #ifdef LLCP_TRANSACT_CHANGES */
2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(eLibNfcHalStatePresenceChk ==
2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->LibNfcState.next_state)
2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb = NULL;
2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            RetVal = NFCSTATUS_PENDING;
2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if(gpphLibContext->psTransInfo!=NULL)
2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                (void)memset(gpphLibContext->psTransInfo,
2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                0,
2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                sizeof(phLibNfc_sTransceiveInfo_t));
3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->psTransInfo->addr =UNKNOWN_BLOCK_ADDRESS;
3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /*pointer to send data */
3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->psTransInfo->sSendData.buffer =
3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    pTransferData->buffer;
3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /*size of send data*/
3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->psTransInfo->sSendData.length =
3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    pTransferData->length;
3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Copy remote device type */
3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                gpphLibContext->sNfcIp_Context.TransactInfoRole.remotePCDType =
3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    ((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType;
3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /*Call Hal4 Send API and register callback with it*/
3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                PHDBG_INFO("LibNfc:P2P send In Progress");
3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                RetVal= phHal4Nfc_Send(
3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                gpphLibContext->psHwReference,
3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                &(gpphLibContext->sNfcIp_Context.TransactInfoRole),
3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                gpphLibContext->psTransInfo->sSendData,
3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                (pphLibNfc_RspCb_t)
3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phLibNfc_RemoteDev_Send_Cb,
3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                (void *)gpphLibContext
3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                );
3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NFCSTATUS_PENDING == RetVal)
3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Update next state to transaction */
3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb= pSendRspCb;
3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx = pContext;
3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->status.GenCb_pending_status=TRUE;
3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->LibNfcState.next_state = eLibNfcHalStateTransaction;
3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            RetVal = NFCSTATUS_FAILED;
3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return RetVal;
3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Response callback for Remote Device Send.
3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phLibNfc_RemoteDev_Send_Cb(
3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            void        *Context,
3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFCSTATUS   status
3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            )
3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    pphLibNfc_RspCb_t       pClientCb=NULL;
3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phLibNfc_LibContext_t   *pLibNfc_Ctxt = (phLibNfc_LibContext_t *)Context;
3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    void                    *pUpperLayerContext=NULL;
3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    /* Check for the context returned by below layer */
3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if(pLibNfc_Ctxt != gpphLibContext)
3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {   /*wrong context returned*/
3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {   /*shutdown called before completion p2p send allow
3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly              shutdown to happen */
3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            phLibNfc_Pending_Shutdown();
3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = NFCSTATUS_SHUTDOWN;
3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else if(eLibNfcHalStateRelease == gpphLibContext->LibNfcState.next_state)
3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = NFCSTATUS_ABORTED;
3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            gpphLibContext->status.GenCb_pending_status = FALSE;
3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if((NFCSTATUS_SUCCESS != status) &&
3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                (PHNFCSTATUS(status) != NFCSTATUS_MORE_INFORMATION ) )
3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /*During p2p send operation initator was not present in RF
3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                field of target*/
3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = NFCSTATUS_DESELECTED;
3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            else
3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = NFCSTATUS_SUCCESS;
3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /* Update current state */
3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phLibNfc_UpdateCurState(status,gpphLibContext);
3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        pClientCb = gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb;
3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        pUpperLayerContext = gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx;
3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        gpphLibContext->sNfcIp_Context.pClientNfcIpTxCb = NULL;
3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        gpphLibContext->sNfcIp_Context.pClientNfcIpTxCntx = NULL;
3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if (NULL != pClientCb)
3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Notify to upper layer status and No. of bytes
3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly             actually written or send to initiator */
3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pClientCb(pUpperLayerContext, status);
3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return;
4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
405