Esempio n. 1
0
/*******************************************************************************
**
** Function         NFA_EeDiscover
**
** Description      This function retrieves the NFCEE information from NFCC.
**                  The NFCEE information is reported in NFA_EE_DISCOVER_EVT.
**
**                  This function may be called when a system supports removable
**                  NFCEEs,
**
** Returns          NFA_STATUS_OK if information is retrieved successfully
**                  NFA_STATUS_FAILED If wrong state (retry later)
**                  NFA_STATUS_INVALID_PARAM If bad parameter
**
*******************************************************************************/
tNFA_STATUS NFA_EeDiscover(tNFA_EE_CBACK *p_cback)
{
    tNFA_EE_API_DISCOVER *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;

    NFA_TRACE_API0 ("NFA_EeDiscover()");

    if (nfa_ee_cb.em_state != NFA_EE_EM_STATE_INIT_DONE)
    {
        NFA_TRACE_ERROR1 ("NFA_EeDiscover bad em state: %d", nfa_ee_cb.em_state);
        status = NFA_STATUS_FAILED;
    }
    else if ((nfa_ee_cb.p_ee_disc_cback != NULL) || (p_cback == NULL))
    {
        NFA_TRACE_ERROR0 ("NFA_EeDiscover() in progress or NULL callback function");
        status = NFA_STATUS_INVALID_PARAM;
    }
    else if ((p_msg = (tNFA_EE_API_DISCOVER *) GKI_getbuf (sizeof(tNFA_EE_API_DISCOVER))) != NULL)
    {
        p_msg->hdr.event    = NFA_EE_API_DISCOVER_EVT;
        p_msg->p_cback      = p_cback;

        nfa_sys_sendmsg (p_msg);

        status = NFA_STATUS_OK;
    }

    return status;
}
Esempio n. 2
0
/*******************************************************************************
**
** Function         NFA_CeRegisterAidOnDH
**
** Description      Register listening callback for the specified ISODEP AID
**
**                  The NFA_CE_REGISTERED_EVT reports the status of the
**                  operation.
**
**                  If no AID is specified (aid_len=0), then p_conn_cback will
**                  will get notifications for any AIDs routed to the DH. This
**                  over-rides callbacks registered for specific AIDs.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Returns:
**                  NFA_STATUS_OK, if command accepted
**                  NFA_STATUS_FAILED: otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_CeRegisterAidOnDH (UINT8 aid[NFC_MAX_AID_LEN],
                                         UINT8           aid_len,
                                         tNFA_CONN_CBACK *p_conn_cback)
{
    tNFA_CE_MSG *p_msg;

    NFA_TRACE_API0 ("NFA_CeRegisterAidOnDH ()");

    /* Validate parameters */
    if (p_conn_cback==NULL)
        return (NFA_STATUS_INVALID_PARAM);

    if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL)
    {
        p_msg->reg_listen.hdr.event = NFA_CE_API_REG_LISTEN_EVT;
        p_msg->reg_listen.p_conn_cback = p_conn_cback;
        p_msg->reg_listen.listen_type = NFA_CE_REG_TYPE_ISO_DEP;

        /* Listen info */
        memcpy (p_msg->reg_listen.aid, aid, aid_len);
        p_msg->reg_listen.aid_len = aid_len;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_Enable
**
** Description      This function enables NFC. Prior to calling NFA_Enable,
**                  the NFCC must be powered up, and ready to receive commands.
**                  This function enables the tasks needed by NFC, opens the NCI
**                  transport, resets the NFC controller, downloads patches to
**                  the NFCC (if necessary), and initializes the NFC subsystems.
**
**                  This function should only be called once - typically when NFC
**                  is enabled during boot-up, or when NFC is enabled from a
**                  settings UI. Subsequent calls to NFA_Enable while NFA is
**                  enabling or enabled will be ignored. When the NFC startup
**                  procedure is completed, an NFA_DM_ENABLE_EVT is returned to the
**                  application using the tNFA_DM_CBACK.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_Enable (tNFA_DM_CBACK        *p_dm_cback,
                        tNFA_CONN_CBACK      *p_conn_cback)
{
    tNFA_DM_API_ENABLE *p_msg;

    NFA_TRACE_API0 ("NFA_Enable ()");

    /* Validate parameters */
    if ((!p_dm_cback) || (!p_conn_cback))
    {
        NFA_TRACE_ERROR0 ("NFA_Enable (): error null callback");
        return (NFA_STATUS_FAILED);
    }

    if ((p_msg = (tNFA_DM_API_ENABLE *) GKI_getbuf (sizeof (tNFA_DM_API_ENABLE))) != NULL)
    {
        p_msg->hdr.event    = NFA_DM_API_ENABLE_EVT;
        p_msg->p_dm_cback   = p_dm_cback;
        p_msg->p_conn_cback = p_conn_cback;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 4
0
/*******************************************************************************
**
** Function         NFA_EeRemoveAidRouting
**
** Description      This function is called to remove the given AID entry from the
**                  listen mode routing table. If the entry configures VS,
**                  it is also removed. The status of this operation is reported
**                  as the NFA_EE_REMOVE_AID_EVT.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Note:            NFA_EeUpdateNow() should be called after last NFA-EE function
**                  to change the listen mode routing is called.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**                  NFA_STATUS_INVALID_PARAM If bad parameter
**
*******************************************************************************/
tNFA_STATUS NFA_EeRemoveAidRouting(UINT8     aid_len,
                                   UINT8    *p_aid)
{
    tNFA_EE_API_REMOVE_AID *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;
    UINT16 size = sizeof(tNFA_EE_API_REMOVE_AID) + aid_len;

    NFA_TRACE_API0 ("NFA_EeRemoveAidRouting()");
    if ((aid_len == 0) || (p_aid == NULL) || (aid_len > NFA_MAX_AID_LEN))
    {
        NFA_TRACE_ERROR0 ("Bad AID");
        status = NFA_STATUS_INVALID_PARAM;
    }
    else if ((p_msg = (tNFA_EE_API_REMOVE_AID *) GKI_getbuf (size)) != NULL)
    {
        p_msg->hdr.event        = NFA_EE_API_REMOVE_AID_EVT;
        p_msg->aid_len          = aid_len;
        p_msg->p_aid            = (UINT8 *)(p_msg + 1);
        memcpy(p_msg->p_aid, p_aid, aid_len);

        nfa_sys_sendmsg (p_msg);

        status = NFA_STATUS_OK;
    }

    return status;
}
/*******************************************************************************
**
** Function         NFA_RwI93GetSysInfo
**
** Description:
**      Send Get system information command to the activated ISO 15693 tag.
**      If UID is provided then set UID[0]:MSB, ... UID[7]:LSB
**
**      When the operation has completed (or if an error occurs), the
**      app will be notified with NFA_I93_CMD_CPLT_EVT.
**
** Returns:
**      NFA_STATUS_OK if successfully initiated
**      NFA_STATUS_WRONG_PROTOCOL: ISO 15693 tag not activated
**      NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_RwI93GetSysInfo (UINT8 *p_uid)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwI93GetSysInfo ()");

    if (nfa_rw_cb.protocol != NFC_PROTOCOL_15693)
    {
        return (NFA_STATUS_WRONG_PROTOCOL);
    }

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        /* Fill in tNFA_RW_OPERATION struct */
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;
        p_msg->op        = NFA_RW_OP_I93_GET_SYS_INFO;

        if (p_uid)
        {
            p_msg->params.i93_cmd.uid_present = TRUE;
            memcpy (p_msg->params.i93_cmd.uid, p_uid, I93_UID_BYTE_LEN);
        }
        else
        {
            p_msg->params.i93_cmd.uid_present = FALSE;
        }

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 6
0
/*******************************************************************************
**
** Function         NFA_CeRegisterFelicaSystemCodeOnDH
**
** Description      Register listening callback for Felica system code
**
**                  The NFA_CE_REGISTERED_EVT reports the status of the
**                  operation.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Returns:
**                  NFA_STATUS_OK, if command accepted
**                  NFA_STATUS_FAILED: otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_CeRegisterFelicaSystemCodeOnDH (UINT16 system_code,
                                                UINT8 nfcid2[NCI_RF_F_UID_LEN],
                                                tNFA_CONN_CBACK *p_conn_cback)
{
    tNFA_CE_MSG *p_msg;

    NFA_TRACE_API0 ("NFA_CeRegisterFelicaSystemCodeOnDH ()");

    /* Validate parameters */
    if (p_conn_cback==NULL)
        return (NFA_STATUS_INVALID_PARAM);

    if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL)
    {
        p_msg->reg_listen.hdr.event = NFA_CE_API_REG_LISTEN_EVT;
        p_msg->reg_listen.p_conn_cback = p_conn_cback;
        p_msg->reg_listen.listen_type = NFA_CE_REG_TYPE_FELICA;

        /* Listen info */
        memcpy (p_msg->reg_listen.nfcid2, nfcid2, NCI_RF_F_UID_LEN);
        p_msg->reg_listen.system_code = system_code;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_RwLocateTlv
**
** Description:
**      Search for the Lock/Memory contril TLV on the activated Type1/Type2 tag
**
**      Data is returned to the application using the NFA_TLV_DETECT_EVT. When
**      search operation has completed, or if an error occurs, the app will be
**      notified with NFA_TLV_DETECT_EVT.
**
** Description      Perform the TLV detection procedure  using the appropriate
**                  method for the currently activated tag.
**
**                  Upon successful completion of TLV detection in T1/T2 tag, a
**                  NFA_TLV_DETECT_EVT will be sent, to notify the application
**                  of the TLV attributes (total lock/reserved bytes etc.).
**                  However if the TLV type specified is NDEF then it is same as
**                  calling NFA_RwDetectNDef and should expect to receive
**                  NFA_NDEF_DETECT_EVT instead of NFA_TLV_DETECT_EVT
**
**                  It is not mandatory to call this function -  NFA_RwDetectNDef,
**                  NFA_RwReadNDef and NFA_RwWriteNDef will perform TLV detection
**                  internally if not performed already. An application may call
**                  this API to check the a tag/card-emulator's total Reserved/
**                  Lock bytes before issuing a write-request.
**
** Returns:
**                  NFA_STATUS_OK if successfully initiated
**                  NFC_STATUS_REFUSED if tlv_type is NDEF & tag won't support NDEF
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_RwLocateTlv (UINT8 tlv_type)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwLocateTlv");

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;

        if (tlv_type == TAG_LOCK_CTRL_TLV)
        {
            p_msg->op = NFA_RW_OP_DETECT_LOCK_TLV;
        }
        else if (tlv_type == TAG_MEM_CTRL_TLV)
        {
            p_msg->op = NFA_RW_OP_DETECT_MEM_TLV;
        }
        else if (tlv_type == TAG_NDEF_TLV)
        {
            p_msg->op = NFA_RW_OP_DETECT_NDEF;
        }
        else
            return (NFA_STATUS_FAILED);

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 8
0
/*******************************************************************************
**
** Function         NFA_CeConfigureLocalTag
**
** Description      Configure local NDEF tag.
**
**                  Tag events will be notifed using the tNFA_CONN_CBACK
**                  (registered during NFA_Enable)
**
**                  The NFA_CE_LOCAL_TAG_CONFIGURED_EVT reports the status of the
**                  operation.
**
**                  Activation and deactivation are reported using the
**                  NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT events
**
**                  If a write-request is received to update the tag memory,
**                  an NFA_CE_NDEF_WRITE_CPLT_EVT will notify the application, along
**                  with a buffer containing the updated contents.
**
**                  To disable the local NDEF tag, set protocol_mask=0
**
**                  The NDEF data provided by p_ndef_data must be persistent
**                  as long as the local NDEF tag is enabled.
**
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function. Also, Input parameters p_uid and
**                  uid_len are reserved for future use.
**
** Returns:
**                  NFA_STATUS_OK,            if command accepted
**                  NFA_STATUS_INVALID_PARAM,
**                      if protocol_maks is not 0 and p_ndef_data is NULL
**                  (or)uid_len is not 0
**                  (or)if protocol mask is set for Type 1 or Type 2
**
**                  NFA_STATUS_FAILED:        otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_CeConfigureLocalTag (tNFA_PROTOCOL_MASK protocol_mask,
                                     UINT8     *p_ndef_data,
                                     UINT16    ndef_cur_size,
                                     UINT16    ndef_max_size,
                                     BOOLEAN   read_only,
                                     UINT8     uid_len,
                                     UINT8     *p_uid)

{
    tNFA_CE_MSG *p_msg;

    NFA_TRACE_API0 ("NFA_CeConfigureLocalTag ()");

    if (protocol_mask)
    {
        /* If any protocols are specified, then NDEF buffer pointer must be non-NULL */
        if (p_ndef_data == NULL)
        {
            NFA_TRACE_ERROR0 ("NFA_CeConfigureLocalTag: NULL ndef data pointer");
            return (NFA_STATUS_INVALID_PARAM);
        }

        if ((protocol_mask & NFA_PROTOCOL_MASK_T1T) || (protocol_mask & NFA_PROTOCOL_MASK_T2T))
        {
            NFA_TRACE_ERROR0 ("NFA_CeConfigureLocalTag: Cannot emulate Type 1 / Type 2 tag");
            return (NFA_STATUS_INVALID_PARAM);
        }

        if (uid_len)
        {
            NFA_TRACE_ERROR1 ("NFA_CeConfigureLocalTag: Cannot Set UID for Protocol_mask: 0x%x", protocol_mask);
            return (NFA_STATUS_INVALID_PARAM);
        }
    }
    if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL)
    {
        p_msg->local_tag.hdr.event = NFA_CE_API_CFG_LOCAL_TAG_EVT;

        /* Copy ndef info */
        p_msg->local_tag.protocol_mask  = protocol_mask;
        p_msg->local_tag.p_ndef_data    = p_ndef_data;
        p_msg->local_tag.ndef_cur_size  = ndef_cur_size;
        p_msg->local_tag.ndef_max_size  = ndef_max_size;
        p_msg->local_tag.read_only      = read_only;
        p_msg->local_tag.uid_len        = uid_len;

        if (uid_len)
            memcpy (p_msg->local_tag.uid, p_uid, uid_len);

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_HciRegister
**
** Description      This function will register an application with hci and
**                  returns an application handle and provides a mechanism to
**                  register a callback with HCI to receive NFA HCI event notification.
**                  When the application is registered (or if an error occurs),
**                  the app will be notified with NFA_HCI_REGISTER_EVT. Previous
**                  session information including allocated gates, created pipes
**                  and pipes states will be returned as part of tNFA_HCI_REGISTER data.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_HciRegister (char *p_app_name, tNFA_HCI_CBACK *p_cback, BOOLEAN b_send_conn_evts)
{
    tNFA_HCI_API_REGISTER_APP *p_msg;
    UINT8                     app_name_len;

    if (p_app_name == NULL)
    {
        NFA_TRACE_API0 ("NFA_HciRegister (): Invalid Application name");
        return (NFA_STATUS_FAILED);
    }

    if (p_cback == NULL)
    {
        NFA_TRACE_API0 ("NFA_HciRegister (): Application should provide callback function to register!");
        return (NFA_STATUS_FAILED);
    }

    NFA_TRACE_API1 ("NFA_HciRegister (): Application Name: %s", p_app_name);

    app_name_len = (UINT8) strlen (p_app_name);

    /* Register the application with HCI */
    if (  (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED)
        &&(p_app_name != NULL)
        &&(app_name_len <= NFA_MAX_HCI_APP_NAME_LEN)
        &&((p_msg = (tNFA_HCI_API_REGISTER_APP *) GKI_getbuf (sizeof (tNFA_HCI_API_REGISTER_APP))) != NULL))
    {
        p_msg->hdr.event  = NFA_HCI_API_REGISTER_APP_EVT;

        /* Save application name and callback */
        memset (p_msg->app_name, 0, sizeof (p_msg->app_name));
        BCM_STRNCPY_S (p_msg->app_name, sizeof (p_msg->app_name), p_app_name, NFA_MAX_HCI_APP_NAME_LEN);
        p_msg->p_cback          = p_cback;
        p_msg->b_send_conn_evts = b_send_conn_evts;

        nfa_sys_sendmsg (p_msg);
        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_EeGetLmrtRemainingSize
**
** Description      This function is called to get remaining size of the
**                  Listen Mode Routing Table.
**                  The remaining size is reported in NFA_EE_REMAINING_SIZE_EVT
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_EeGetLmrtRemainingSize (void)
{
    tNFA_EE_API_LMRT_SIZE *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;

    NFA_TRACE_API0 ("NFA_EeGetLmrtRemainingSize()");
    if ((p_msg = (tNFA_EE_API_LMRT_SIZE *) GKI_getbuf (sizeof(tNFA_EE_API_LMRT_SIZE))) != NULL)
    {
        p_msg->event    = NFA_EE_API_LMRT_SIZE_EVT;
        nfa_sys_sendmsg (p_msg);
        status = NFA_STATUS_OK;
    }

    return status;
}
/*******************************************************************************
**
** Function         NFA_HciDeregister
**
** Description      This function is called to deregister an application
**                  from HCI. The app will be notified by NFA_HCI_DEREGISTER_EVT
**                  after deleting all the pipes owned by the app and deallocating
**                  all the gates allocated to the app or if an error occurs.
**                  Even if deregistration fails, the app has to register again
**                  to provide a new cback function.
**
** Returns          NFA_STATUS_OK if the application is deregistered successfully
**                  NFA_STATUS_FAILED otherwise

*******************************************************************************/
tNFA_STATUS NFA_HciDeregister (char *p_app_name)
{
    tNFA_HCI_API_DEREGISTER_APP *p_msg;
    int                         xx;
    UINT8                       app_name_len;

    if (p_app_name == NULL)
    {
        NFA_TRACE_API0 ("NFA_HciDeregister (): Invalid Application");
        return (NFA_STATUS_FAILED);
    }

    NFA_TRACE_API1 ("NFA_HciDeregister (): Application Name: %s", p_app_name);
    app_name_len = (UINT8) strlen (p_app_name);

    if (app_name_len > NFA_MAX_HCI_APP_NAME_LEN)
        return (NFA_STATUS_FAILED);

    /* Find the application registration */
    for (xx = 0; xx < NFA_HCI_MAX_APP_CB; xx++)
    {
        if (  (nfa_hci_cb.cfg.reg_app_names[xx][0] != 0)
            &&(!strncmp (p_app_name, &nfa_hci_cb.cfg.reg_app_names[xx][0], app_name_len)) )
            break;
    }

    if (xx == NFA_HCI_MAX_APP_CB)
    {
        NFA_TRACE_ERROR1 ("NFA_HciDeregister (): Application Name: %s  NOT FOUND", p_app_name);
        return (NFA_STATUS_FAILED);
    }

    /* Deregister the application with HCI */
    if (  (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED)
        &&((p_msg = (tNFA_HCI_API_DEREGISTER_APP *) GKI_getbuf (sizeof (tNFA_HCI_API_DEREGISTER_APP))) != NULL) )
    {
        p_msg->hdr.event  = NFA_HCI_API_DEREGISTER_APP_EVT;

        memset (p_msg->app_name, 0, sizeof (p_msg->app_name));
        BCM_STRNCPY_S (p_msg->app_name, sizeof (p_msg->app_name), p_app_name, NFA_MAX_HCI_APP_NAME_LEN);

        nfa_sys_sendmsg (p_msg);
        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_StopRfDiscovery
**
** Description      Stop RF discovery
**
**                  An NFA_RF_DISCOVERY_STOPPED_EVT indicates whether stopping was successful or not.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_StopRfDiscovery (void)
{
    BT_HDR *p_msg;

    NFA_TRACE_API0 ("NFA_StopRfDiscovery ()");

    if ((p_msg = (BT_HDR *) GKI_getbuf (sizeof (BT_HDR))) != NULL)
    {
        p_msg->event = NFA_DM_API_STOP_RF_DISCOVERY_EVT;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_ResumeP2p
**
** Description      Resume P2P services.
**                  NFA_P2P_RESUMED_EVT will be returned after P2P services are.
**                  enables again.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_ResumeP2p (void)
{
    BT_HDR *p_msg;

    NFA_TRACE_API0 ("NFA_ResumeP2p ()");

    if ((p_msg = (BT_HDR *) GKI_getbuf (sizeof (BT_HDR))) != NULL)
    {
        p_msg->event = NFA_DM_API_RESUME_P2P_EVT;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_DisableListening
**
** Description      Disable listening
**                  NFA_LISTEN_DISABLED_EVT will be returned after stopping listening.
**                  This function is called to exclude listen at RF discovery.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_DisableListening (void)
{
    BT_HDR *p_msg;

    NFA_TRACE_API0 ("NFA_DisableListening ()");

    if ((p_msg = (BT_HDR *) GKI_getbuf (sizeof (BT_HDR))) != NULL)
    {
        p_msg->event = NFA_DM_API_DISABLE_LISTENING_EVT;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 15
0
/*******************************************************************************
**
** Function         NFA_EeUpdateNow
**
** Description      This function is called to send the current listen mode
**                  routing table and VS configuration to the NFCC (without waiting
**                  for NFA_EE_ROUT_TIMEOUT_VAL).
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_EeUpdateNow(void)
{
    BT_HDR *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;

    NFA_TRACE_API0 ("NFA_EeUpdateNow()");
    if ((p_msg = (BT_HDR *) GKI_getbuf (BT_HDR_SIZE)) != NULL)
    {
        p_msg->event    = NFA_EE_API_UPDATE_NOW_EVT;

        nfa_sys_sendmsg (p_msg);

        status = NFA_STATUS_OK;
    }

    return status;
}
/*******************************************************************************
**
** Function         NFA_RwDetectNDef
**
** Description      Perform the NDEF detection procedure  using the appropriate
**                  method for the currently activated tag.
**
**                  Upon successful completion of NDEF detection, a
**                  NFA_NDEF_DETECT_EVT will be sent, to notify the application
**                  of the NDEF attributes (NDEF total memory size, current
**                  size, etc.).
**
**                  It is not mandatory to call this function -  NFA_RwReadNDef
**                  and NFA_RwWriteNDef will perform NDEF detection internally if
**                  not performed already. This API may be called to get a
**                  tag's NDEF size before issuing a write-request.
**
** Returns:
**                  NFA_STATUS_OK if successfully initiated
**                  NFC_STATUS_REFUSED if tag does not support NDEF
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_RwDetectNDef (void)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwDetectNDef");

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;
        p_msg->op        = NFA_RW_OP_DETECT_NDEF;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*****************************************************************************
**
** Function         NFA_RwFormatTag
**
** Description      Check if the tag is NDEF Formatable. If yes Format the tag
**
**                  The NFA_RW_FORMAT_CPLT_EVT w/ status is used to
**                  indicate if tag is successfully formated or not
**
** Returns
**                  NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*****************************************************************************/
tNFA_STATUS NFA_RwFormatTag (void)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwFormatTag");

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16)(sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;
        p_msg->op        = NFA_RW_OP_FORMAT_TAG;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_UpdateRFCommParams
**
** Description      This function is called to update RF Communication parameters
**                  once the Frame RF Interface has been activated.
**
**                  An NFA_UPDATE_RF_PARAM_RESULT_EVT indicates whether updating
**                  was successful or not.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_UpdateRFCommParams (tNFA_RF_COMM_PARAMS *p_params)
{
    tNFA_DM_API_UPDATE_RF_PARAMS *p_msg;

    NFA_TRACE_API0 ("NFA_UpdateRFCommParams ()");

    if ((p_msg = (tNFA_DM_API_UPDATE_RF_PARAMS *) GKI_getbuf ((UINT16) (sizeof (tNFA_DM_API_UPDATE_RF_PARAMS)))) != NULL)
    {
        p_msg->hdr.event     = NFA_DM_API_UPDATE_RF_PARAMS_EVT;
        memcpy (&p_msg->params, p_params, sizeof (tNFA_RF_COMM_PARAMS));

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 19
0
/*****************************************************************************
**
** Function         NFA_RwPresenceCheck
**
** Description      Check if the tag is still in the field.
**
**                  The NFA_RW_PRESENCE_CHECK_EVT w/ status is used to
**                  indicate presence or non-presence.
**
** Returns
**                  NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*****************************************************************************/
tNFA_STATUS NFA_RwPresenceCheck (void)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwPresenceCheck");

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;
        p_msg->op        = NFA_RW_OP_PRESENCE_CHECK;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_ReleaseExclusiveRfControl
**
** Description      Release exclusive control of NFC. Once released, behavior
**                  prior to obtaining exclusive RF control will resume.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_ReleaseExclusiveRfControl (void)
{
    BT_HDR *p_msg;

    NFA_TRACE_API0 ("NFA_ReleaseExclusiveRfControl ()");

    if (!nfa_dm_cb.p_excl_conn_cback)
    {
        NFA_TRACE_ERROR0 ("NFA_ReleaseExclusiveRfControl (): Exclusive rf control is not in progress");
        return (NFA_STATUS_FAILED);
    }

    if ((p_msg = (BT_HDR *) GKI_getbuf (sizeof (BT_HDR))) != NULL)
    {
        p_msg->event = NFA_DM_API_RELEASE_EXCL_RF_CTRL_EVT;
        nfa_sys_sendmsg (p_msg);
        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/*******************************************************************************
**
** Function         NFA_Init
**
** Description      This function initializes control blocks for NFA
**
**                  p_hal_entry_tbl points to a table of HAL entry points
**
**                  NOTE: the buffer that p_hal_entry_tbl points must be
**                  persistent until NFA is disabled.
**
** Returns          none
**
*******************************************************************************/
void NFA_Init(tHAL_NFC_ENTRY *p_hal_entry_tbl)
{
    NFA_TRACE_API0 ("NFA_Init ()");
    nfa_sys_init();
    nfa_dm_init();
    nfa_p2p_init();
    nfa_cho_init();
    nfa_snep_init(FALSE);
    nfa_rw_init();
    nfa_ce_init();
    nfa_ee_init();
    if (nfa_ee_max_ee_cfg != 0)
    {
        nfa_dm_cb.get_max_ee    = p_hal_entry_tbl->get_max_ee;
        nfa_hci_init();
    }


    /* Initialize NFC module */
    NFC_Init (p_hal_entry_tbl);
}
/*******************************************************************************
**
** Function         NFA_SetRfDiscoveryDuration
**
** Description      Set the duration of the single discovery period in [ms].
**                  Allowable range: 0 ms to 0xFFFF ms.
**
**                  If discovery is already started, the application should
**                  call NFA_StopRfDiscovery prior to calling
**                  NFA_SetRfDiscoveryDuration, and then call
**                  NFA_StartRfDiscovery afterwards to restart discovery using
**                  the new duration.
**
** Note:            If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
**                  should happen before calling this function
**
** Returns:
**                  NFA_STATUS_OK, if command accepted
**                  NFA_STATUS_FAILED: otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_SetRfDiscoveryDuration (UINT16 discovery_period_ms)
{
    tNFA_DM_API_SET_RF_DISC_DUR *p_msg;

    NFA_TRACE_API0 ("NFA_SetRfDiscoveryDuration ()");

    /* Post the API message */
    if ((p_msg = (tNFA_DM_API_SET_RF_DISC_DUR *) GKI_getbuf (sizeof (BT_HDR))) != NULL)
    {
        p_msg->hdr.event = NFA_DM_API_SET_RF_DISC_DURATION_EVT;

        /* Set discovery duration */
        p_msg->rf_disc_dur_ms = discovery_period_ms;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
/******************************************************************************
**
** Function         NFA_EeUpdateNow
**
** Description      This function is called to send the current listen mode
**                  routing table and VS configuration to the NFCC (without waiting
**                  for NFA_EE_ROUT_TIMEOUT_VAL).
**
**                  The status of this operation is
**                  reported with the NFA_EE_UPDATED_EVT.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_SEMANTIC_ERROR is update is currently in progress
**                  NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_EeUpdateNow(void)
{
    BT_HDR *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;

    NFA_TRACE_API0 ("NFA_EeUpdateNow()");
    if (nfa_ee_cb.ee_wait_evt & NFA_EE_WAIT_UPDATE_ALL)
    {
        NFA_TRACE_ERROR0 ("update in progress");
        status = NFA_STATUS_SEMANTIC_ERROR;
    }
    else if ((p_msg = (BT_HDR *) GKI_getbuf (BT_HDR_SIZE)) != NULL)
    {
        p_msg->event    = NFA_EE_API_UPDATE_NOW_EVT;

        nfa_sys_sendmsg (p_msg);

        status = NFA_STATUS_OK;
    }

    return status;
}
/*******************************************************************************
**
** Function         NFA_RwI93StayQuiet
**
** Description:
**      Send Stay Quiet command to the activated ISO 15693 tag.
**
**      When the operation has completed (or if an error occurs), the
**      app will be notified with NFA_I93_CMD_CPLT_EVT.
**
** Returns:
**      NFA_STATUS_OK if successfully initiated
**      NFA_STATUS_WRONG_PROTOCOL: ISO 15693 tag not activated
**      NFA_STATUS_FAILED otherwise
**
*******************************************************************************/
tNFA_STATUS NFA_RwI93StayQuiet (void)
{
    tNFA_RW_OPERATION *p_msg;

    NFA_TRACE_API0 ("NFA_RwI93StayQuiet ()");

    if (nfa_rw_cb.protocol != NFC_PROTOCOL_15693)
    {
        return (NFA_STATUS_WRONG_PROTOCOL);
    }

    if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL)
    {
        /* Fill in tNFA_RW_OPERATION struct */
        p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT;
        p_msg->op        = NFA_RW_OP_I93_STAY_QUIET;

        nfa_sys_sendmsg (p_msg);

        return (NFA_STATUS_OK);
    }

    return (NFA_STATUS_FAILED);
}
Esempio n. 25
0
/*******************************************************************************
**
** Function         NFA_EeRegister
**
** Description      This function registers a callback function to receive the
**                  events from NFA-EE module.
**
** Returns          NFA_STATUS_OK if successfully initiated
**                  NFA_STATUS_FAILED otherwise
**                  NFA_STATUS_INVALID_PARAM If bad parameter
**
*******************************************************************************/
tNFA_STATUS NFA_EeRegister(tNFA_EE_CBACK *p_cback)
{
    tNFA_EE_API_REGISTER *p_msg;
    tNFA_STATUS status = NFA_STATUS_FAILED;

    NFA_TRACE_API0 ("NFA_EeRegister()");

    if (p_cback == NULL)
    {
        NFA_TRACE_ERROR0 ("NFA_EeRegister(): with NULL callback function");
        status = NFA_STATUS_INVALID_PARAM;
    }
    else if ((p_msg = (tNFA_EE_API_REGISTER *) GKI_getbuf (sizeof(tNFA_EE_API_REGISTER))) != NULL)
    {
        p_msg->hdr.event    = NFA_EE_API_REGISTER_EVT;
        p_msg->p_cback      = p_cback;

        nfa_sys_sendmsg (p_msg);

        status = NFA_STATUS_OK;
    }

    return status;
}
/*******************************************************************************
**
** Function         NFA_HciW4eSETransaction_Complete
**
** Description      This function is called to wait for eSE transaction
**                  to complete before NFCC shutdown or NFC service turn OFF
**
** Returns          None
**
*******************************************************************************/
void NFA_HciW4eSETransaction_Complete(tNFA_HCI_TRANSCV_STATE type)
{
    NFA_TRACE_API1 ("NFA_HciW4eSETransaction_Complete; type=%u", type);
    UINT8 retry_cnt = 0;
    UINT8 max_time =NFA_HCI_MAX_RSP_WAIT_TIME;

    if(type == Release)
    {
        nfa_hci_release_transcieve();
    }
    else
    {
        do
        {
            if(nfa_hci_cb.hci_state == NFA_HCI_STATE_WAIT_RSP)
            {
                sleep(1);
            }
            else
                break;
        }while(retry_cnt++ < max_time);
    }
    NFA_TRACE_API0 ("NFA_HciW4eSETransaction_Complete; End");
}
/*******************************************************************************
**
** Function         NFA_HciDebug
**
** Description      Debug function.
**
*******************************************************************************/
void NFA_HciDebug (UINT8 action, UINT8 size, UINT8 *p_data)
{
    int                 xx;
    tNFA_HCI_DYN_GATE   *pg = nfa_hci_cb.cfg.dyn_gates;
    tNFA_HCI_DYN_PIPE   *pp = nfa_hci_cb.cfg.dyn_pipes;
    BT_HDR              *p_msg;
    UINT8               *p;

    switch (action)
    {
    case NFA_HCI_DEBUG_DISPLAY_CB:
        NFA_TRACE_API0 ("NFA_HciDebug  Host List:");
        for (xx = 0; xx < NFA_HCI_MAX_APP_CB; xx++)
        {
            if (nfa_hci_cb.cfg.reg_app_names[xx][0] != 0)
            {
                NFA_TRACE_API2 ("              Host Inx:  %u   Name: %s", xx, &nfa_hci_cb.cfg.reg_app_names[xx][0]);
            }
        }

        NFA_TRACE_API0 ("NFA_HciDebug  Gate List:");
        for (xx = 0; xx < NFA_HCI_MAX_GATE_CB; xx++, pg++)
        {
            if (pg->gate_id != 0)
            {
                NFA_TRACE_API4 ("              Gate Inx: %x  ID: 0x%02x  Owner: 0x%04x  PipeInxMask: 0x%08x",
                                xx, pg->gate_id, pg->gate_owner, pg->pipe_inx_mask);
            }
        }

        NFA_TRACE_API0 ("NFA_HciDebug  Pipe List:");
        for (xx = 0; xx < NFA_HCI_MAX_PIPE_CB; xx++, pp++)
        {
            if (pp->pipe_id != 0)
            {
                NFA_TRACE_API6 ("              Pipe Inx: %x  ID: 0x%02x  State: %u  LocalGate: 0x%02x  Dest Gate: 0x%02x  Host: 0x%02x",
                    xx, pp->pipe_id, pp->pipe_state, pp->local_gate, pp->dest_gate, pp->dest_host);
            }
        }
        break;

    case NFA_HCI_DEBUG_SIM_HCI_EVENT:
        if ((p_msg = (BT_HDR *) GKI_getpoolbuf (NFC_RW_POOL_ID)) != NULL)
        {
            p = (UINT8 *) (p_msg + 1);

            p_msg->event  = NFA_HCI_CHECK_QUEUE_EVT;
            p_msg->len    = size;
            p_msg->offset = 0;

            memcpy (p, p_data, size);

            nfa_sys_sendmsg (p_msg);
        }
        break;

    case NFA_HCI_DEBUG_ENABLE_LOOPBACK:
        NFA_TRACE_API0 ("NFA_HciDebug  HCI_LOOPBACK_DEBUG = TRUE");
        HCI_LOOPBACK_DEBUG = TRUE;
        break;

    case NFA_HCI_DEBUG_DISABLE_LOOPBACK:
        NFA_TRACE_API0 ("NFA_HciDebug  HCI_LOOPBACK_DEBUG = FALSE");
        HCI_LOOPBACK_DEBUG = FALSE;
        break;
    }
}