コード例 #1
0
NFCSTATUS
phNciNfc_CoreRecvMgrDeRegisterCb(void *pCtx,
                                 pphNciNfc_CoreRegInfo_t pRegInfo,
                                 phNciNfc_NciCoreMsgType_t eMsgType)
{
    NFCSTATUS wStatus = NFCSTATUS_INVALID_PARAMETER;
    pphNciNfc_CoreContext_t pCoreCtx = (pphNciNfc_CoreContext_t)pCtx;
    void *pRegList = NULL;

    PH_LOG_NCI_FUNC_ENTRY();
    if((NULL != pCoreCtx) && (NULL != pRegInfo))
    {
        if(NULL != pRegInfo->pNotifyCb)
        {
            wStatus = NFCSTATUS_SUCCESS;
            switch(eMsgType)
            {
                case phNciNfc_e_NciCoreMsgTypeCntrlRsp:
                    pRegList = (void *) pCoreCtx->tRspCtx.aRspRegList;
                    PH_LOG_NCI_INFO_STR("De-registering response message call back...");
                    break;

                case phNciNfc_e_NciCoreMsgTypeCntrlNtf:
                    pRegList = (void *) pCoreCtx->tNtfCtx.aNtfRegList;
                    PH_LOG_NCI_INFO_STR("De-registering notification message  call back...");
                    break;

                case phNciNfc_e_NciCoreMsgTypeData:
                    pRegList = (void *) pCoreCtx->tDataCtx.aDataRegList;
                    PH_LOG_NCI_INFO_STR("De-registering data message call back...");
                    break;

                default:
                    PH_LOG_NCI_WARN_STR("Invalid message type");
                    wStatus = NFCSTATUS_INVALID_PARAMETER;
                    break;
            }
            if(NFCSTATUS_SUCCESS == wStatus)
            {
                wStatus = phNciNfc_CoreDeRegister(pRegList,pRegInfo,eMsgType);
            }
        }
        else
        {
            PH_LOG_NCI_WARN_STR("Invalid call back function pointer to register");
        }
    }
    else
    {
        PH_LOG_NCI_WARN_STR("Invalid input parameters");
    }
    PH_LOG_NCI_FUNC_EXIT();
    return wStatus;
}
コード例 #2
0
static
NFCSTATUS
phNciNfc_UpdateNfcIRemDevInfo(pphNciNfc_RemoteDevInformation_t pRemDevInf,
                          uint8_t *pBuff,
                          uint16_t wLen
                          )
{
    NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
    uint8_t *pRfNtfBuff = NULL;
    uint8_t RfTechSpecParamsLen = 0;

    PH_LOG_NCI_FUNC_ENTRY();

    if((NULL == pRemDevInf) || (NULL == pBuff) || (0 == wLen))
    {
        wStatus = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_INVALID_PARAMETER);
        PH_LOG_NCI_CRIT_STR(" Invalid Param(s)..");
    }
    else
    {
        pRemDevInf->bRfDiscId = pBuff[0];
        pRemDevInf->eRfIf = (phNciNfc_RfInterfaces_t)pBuff[1];

        if(phNciNfc_e_RfInterfacesNfceeDirect_RF != (pRemDevInf->eRfIf))
        {
            pRemDevInf->eRFProtocol = (phNciNfc_RfProtocols_t)pBuff[2];
            pRemDevInf->eRFTechMode = (phNciNfc_RfTechMode_t)pBuff[3];
            pRemDevInf->bMaxPayLoadSize = pBuff[4];
            pRemDevInf->bInitialCredit = pBuff[5];
            /* Obtain the len of RF tech specific parameters from Resp buff */
            RfTechSpecParamsLen = pBuff[6];
            pRemDevInf->bTechSpecificParamLen = RfTechSpecParamsLen;
            pRfNtfBuff = &(pBuff[7+RfTechSpecParamsLen]);

            pRemDevInf->eDataXchgRFTechMode = (phNciNfc_RfTechMode_t)*(pRfNtfBuff+0);
            pRemDevInf->bTransBitRate = *(pRfNtfBuff+1);
            pRemDevInf->bRecvBitRate = *(pRfNtfBuff+2);
        }
        else
        {
            PH_LOG_NCI_WARN_STR("Interface is NFCEE Direct RF,subsequent payload contents ignored..");
        }
    }
    PH_LOG_NCI_FUNC_EXIT();

    return wStatus;
}
コード例 #3
0
NFCSTATUS phNciNfc_DecrConnCredit(
                                   uint8_t bConnId
                                   )
{
    NFCSTATUS   wStatus = NFCSTATUS_FAILED;
    uint8_t     bConnListIdx;

    PH_LOG_NCI_FUNC_ENTRY();

    for(bConnListIdx = 0; bConnListIdx < (MAX_LOGICAL_CONNS+1) ; bConnListIdx++)
    {
        if(bConnId == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId)
        {
            if((TRUE == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].bIfActive) ||
                (CONNTYPE_STATIC == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId))
            {
                if(gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bNumCredits > 0)
                {
                    gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bNumCredits -= 1;
                    wStatus = NFCSTATUS_SUCCESS;
                }
                else
                {
                    PH_LOG_NCI_WARN_STR("No Credits available for this connId!!");
                }
            }
            else
            {
                PH_LOG_NCI_CRIT_STR(" Interface not active for this connection");
            }
            break;
        }
    }
    PH_LOG_NCI_FUNC_EXIT();

    return wStatus;
}
コード例 #4
0
NFCSTATUS phNciNfc_IncrConnCredits(
                                   uint8_t bConnId,
                                   uint8_t bVal
                                   )
{
    NFCSTATUS   wStatus = NFCSTATUS_FAILED;
    uint8_t     bConnListIdx;

    PH_LOG_NCI_FUNC_ENTRY();

    for(bConnListIdx = 0; bConnListIdx < (MAX_LOGICAL_CONNS+1) ; bConnListIdx++)
    {
        if(bConnId == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId)
        {
            if((TRUE == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].bIfActive) ||
                (CONNTYPE_STATIC == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId))
            {
                gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bNumCredits += bVal;

                if(gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bNumCredits > MAX_CREDITS_LIMIT)
                {
                    gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bNumCredits = MAX_CREDITS_LIMIT;
                    PH_LOG_NCI_WARN_STR(" Credit Limit xceeded for this Conn,Rounding to max value ..");
                }
                wStatus = NFCSTATUS_SUCCESS;
            }
            else
            {
                PH_LOG_NCI_CRIT_STR(" Interface not active for this connection");
            }
            break;
        }
    }
    PH_LOG_NCI_FUNC_EXIT();

    return wStatus;
}
コード例 #5
0
NFCSTATUS
phNciNfc_ProcessConnCreditNtf(
                        void               *psContext,
                        void               *pInfo,
                        NFCSTATUS          wStatus
                    )
{
    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
    pphNciNfc_CoreContext_t             pCoreCtx = (pphNciNfc_CoreContext_t)psContext;
    pphNciNfc_TransactInfo_t            pTransInfo = (pphNciNfc_TransactInfo_t)pInfo;
    phNciNfc_CoreGid_t                  tNtfGid;
    phNciNfc_CoreNciCoreNtfOid_t        tNtfOid;
    uint8_t                             bConnIdx;
    uint8_t                             bNewCredits = 0;
    uint8_t                             bNumOfEntries;
    uint8_t                             bEntrIdx;

    UNUSED(psContext);

    PH_LOG_NCI_FUNC_ENTRY();

    if( (NULL == pTransInfo) || (NULL == pCoreCtx) ||
        (NULL == pTransInfo->pbuffer) ||(0 == pTransInfo->wLength)
        || (PH_NCINFC_STATUS_OK != wStatus)
        )
    {
        status = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_FAILED);
        PH_LOG_NCI_INFO_STR(" Conn Notification invalid..");
    }
    else
    {
        tNtfGid = pCoreCtx->tReceiveInfo.HeaderInfo.Group_ID;
        tNtfOid = pCoreCtx->tReceiveInfo.HeaderInfo.Opcode_ID.OidType.NciCoreNtfOid;

        if(phNciNfc_e_CoreNciCoreGid == tNtfGid)
        {
            if(phNciNfc_e_NciCoreConnCreditNtfOid == tNtfOid)
            {
                PH_LOG_NCI_INFO_STR(" Core ConnCredits Notification received..");
                bNumOfEntries = pTransInfo->pbuffer[0];

                for(bEntrIdx = 0; bEntrIdx < bNumOfEntries; bEntrIdx++)
                {
                    status = phNciNfc_GetConnIndex(pTransInfo->pbuffer[1], &bConnIdx);

                    if(NFCSTATUS_SUCCESS == status)
                    {
                        gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bNumCredits += pTransInfo->pbuffer[2];

                        if(gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bNumCredits > MAX_CREDITS_LIMIT)
                        {
                            gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bNumCredits = MAX_CREDITS_LIMIT;
                            PH_LOG_NCI_INFO_STR(" Credits Limit xceeded for this Conn, Ignoring notif value ..");
                        }
                        else
                        {
                            PH_LOG_NCI_INFO_STR(" Credits updated for ConnId: 0x%x to 0x%x",
                                gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bConnId,
                                gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bNumCredits);
                        }

                        bNewCredits = gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnIdx].tConn.bNumCredits;
                    }
                    else
                    {
                        PH_LOG_NCI_INFO_X32MSG( " Failed to get Conn details for index..",bConnIdx);
                    }
                }
            }
            else
            {
                status = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_INVALID_PARAMETER);
                PH_LOG_NCI_INFO_STR(" Invalid Oid received..");
            }
        }
        else
        {
            status = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_INVALID_PARAMETER);
            PH_LOG_NCI_INFO_STR(" Invalid Gid received..");
        }
    }

    PH_LOG_NCI_INFO_STR("Credits awaited: %d, timerstatus: %d",
                        gphNciNfc_ConnMgmtInt.bCreditsAwaited,
                        gphNciNfc_ConnMgmtInt.tCWTimerIf.TimerStatus);

    /* Invoke the registered CB function if waiting for credits */
    if(TRUE == gphNciNfc_ConnMgmtInt.bCreditsAwaited)
    {
        if(gphNciNfc_ConnMgmtInt.tCWTimerIf.TimerStatus == 1)
        {
            PH_LOG_NCI_INFO_STR("Stopping Credit await timer..");

            (void)phOsalNfc_Timer_Stop(gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId);
            (void)phOsalNfc_Timer_Delete(gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId);

            gphNciNfc_ConnMgmtInt.tCWTimerIf.TimerStatus = 0;
            gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId = 0;
        }
        gphNciNfc_ConnMgmtInt.bCreditsAwaited = FALSE;

        if(NULL != gphNciNfc_ConnMgmtInt.pCrdtsNotify)
        {
            (void)(gphNciNfc_ConnMgmtInt.pCrdtsNotify)((gphNciNfc_ConnMgmtInt.pContext),bNewCredits,status);
        }
        else
        {
            PH_LOG_NCI_WARN_STR("No CB registered for credits availability!!");
        }
    }

    PH_LOG_NCI_FUNC_EXIT();

    return status;
}
コード例 #6
0
NFCSTATUS phNciNfc_RegForConnCredits(
                                     uint8_t bConnId,
                                     pphNciNfc_ConnCreditsNtf_t pNotify,
                                     void *pContext,
                                     uint32_t CreditTo
                                     )
{
    NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
    uint8_t     bConnListIdx;
    uint32_t TimerId;

    PH_LOG_NCI_FUNC_ENTRY();

    if((NULL == pNotify) || (NULL == pContext))
    {
        wStatus = PHNFCSTVAL(CID_NFC_NCI, NFCSTATUS_INVALID_PARAMETER);
        PH_LOG_NCI_INFO_STR(" Invalid Caller Layer Param(s) received ..");
    }
    else
    {
        for(bConnListIdx = 0; bConnListIdx < (MAX_LOGICAL_CONNS+1) ; bConnListIdx++)
        {
            if(bConnId == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId)
            {
                if((TRUE == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].bIfActive) ||
                    (CONNTYPE_STATIC == gphNciNfc_ConnMgmtInt.tConnInfo.tConnList[bConnListIdx].tConn.bConnId))
                {
                    wStatus = NFCSTATUS_SUCCESS;
                }
                else
                {
                    PH_LOG_NCI_CRIT_STR(" Interface not active for this connection");
                    wStatus = NFCSTATUS_FAILED;
                }
                break;
            }
        }

        if(NFCSTATUS_SUCCESS == wStatus)
        {
            gphNciNfc_ConnMgmtInt.bConnId = bConnId;
            gphNciNfc_ConnMgmtInt.pCrdtsNotify = pNotify;
            gphNciNfc_ConnMgmtInt.pContext = pContext;

            TimerId = phOsalNfc_Timer_Create();

            if (0 == TimerId)
            {
                PH_LOG_NCI_WARN_STR("Credit wait Timer Create failed!!");
                wStatus = NFCSTATUS_INSUFFICIENT_RESOURCES;
            }
            else
            {
                PH_LOG_NCI_INFO_STR("Credit wait Timer Created Successfully");

                gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId = TimerId;
                gphNciNfc_ConnMgmtInt.tCWTimerIf.TimerStatus = 0;

                PH_LOG_NCI_INFO_STR("Credit timeout set to %d, for ConnId 0x%x",CreditTo, bConnId);

                wStatus = phOsalNfc_Timer_Start(gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId,
                                                CreditTo,
                                                &phNciNfc_WaitCreditTimerCb,
                                                &gphNciNfc_ConnMgmtInt);

                if (NFCSTATUS_SUCCESS == wStatus)
                {
                    PH_LOG_NCI_INFO_STR("Credit wait timer started..");
                    gphNciNfc_ConnMgmtInt.tCWTimerIf.TimerStatus = 1;
                    /* Set the CreditsAwaited flag to indicate credit notif function to call the registered CB */
                    gphNciNfc_ConnMgmtInt.bCreditsAwaited = TRUE;
                }
                else
                {
                     PH_LOG_NCI_WARN_STR("Failed to start credit ntf wait timer!");
                     (void )phOsalNfc_Timer_Delete(gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId);
                     gphNciNfc_ConnMgmtInt.tCWTimerIf.dwTimerId = 0;
                     wStatus = NFCSTATUS_FAILED;
                }
            }
        }
    }

    PH_LOG_NCI_FUNC_EXIT();

    return wStatus;
}
コード例 #7
0
NFCSTATUS
phNciNfc_CoreRecvMgrRegisterCb(void *pCtx,
                               pphNciNfc_CoreRegInfo_t pRegInfo,
                               phNciNfc_NciCoreMsgType_t eMsgType)
{
    NFCSTATUS wStatus = NFCSTATUS_INVALID_PARAMETER;
    pphNciNfc_CoreContext_t pCoreCtx = (pphNciNfc_CoreContext_t)pCtx;
    uint8_t bCheckForEntry = 1;
    void *pRegList = NULL;

    PH_LOG_NCI_FUNC_ENTRY();
    if((NULL != pCoreCtx) && (NULL != pRegInfo))
    {
        if(NULL != pRegInfo->pNotifyCb)
        {
            wStatus = NFCSTATUS_SUCCESS;
            switch(eMsgType)
            {
                case phNciNfc_e_NciCoreMsgTypeCntrlRsp:
                    pRegList = (void *) pCoreCtx->tRspCtx.aRspRegList;
                    PH_LOG_NCI_INFO_STR("Registering for response message...");

                    /* Over write the existing Rsp entry if any exist */
                    bCheckForEntry = 0;
                    break;

                case phNciNfc_e_NciCoreMsgTypeCntrlNtf:
                    pRegList = (void *) pCoreCtx->tNtfCtx.aNtfRegList;
                    PH_LOG_NCI_INFO_STR("Registering for notification message...");

                    /* Whether there are notification registrations already present in the list or not,
                       register for this new notification */
                    bCheckForEntry = 0;
                    break;

                case phNciNfc_e_NciCoreMsgTypeData:
                    pRegList = (void *) pCoreCtx->tDataCtx.aDataRegList;
                    PH_LOG_NCI_INFO_STR("Registering for data message...");
                    /* Over write the existing Rsp entry if any exist */
                    bCheckForEntry = 0;
                    break;

                default:
                    PH_LOG_NCI_WARN_STR("Invalid message type");
                    wStatus = NFCSTATUS_INVALID_PARAMETER;
                    break;
            }
            if(NFCSTATUS_SUCCESS == wStatus)
            {
                wStatus = phNciNfc_CoreRegister(pRegList,pRegInfo,eMsgType);
            }
        }
        else
        {
            PH_LOG_NCI_WARN_STR("Invalid call back function pointer to register");
        }
    }
    else
    {
        PH_LOG_NCI_WARN_STR("Invalid input parameters");
    }
    PH_LOG_NCI_FUNC_EXIT();
    return wStatus;
}