/*******************************************************************************
**
** Function         nfa_ee_sys_disable
**
** Description      Deregister NFA EE from NFA SYS/DM
**
**
** Returns          None
**
*******************************************************************************/
void nfa_ee_sys_disable (void)
{
    UINT32  xx;
    tNFA_EE_ECB *p_cb;
    tNFA_EE_MSG     msg;

    NFA_TRACE_DEBUG0 ("nfa_ee_sys_disable ()");

    nfa_ee_cb.em_state = NFA_EE_EM_STATE_DISABLED;
    /* report NFA_EE_DEREGISTER_EVT to all registered to EE */
    for (xx = 0; xx < NFA_EE_MAX_CBACKS; xx++)
    {
        if (nfa_ee_cb.p_ee_cback[xx])
        {
            msg.deregister.index     = xx;
            nfa_ee_api_deregister (&msg);
        }
    }

    nfa_ee_cb.num_ee_expecting  = 0;
    p_cb = nfa_ee_cb.ecb;
    for (xx = 0; xx < nfa_ee_cb.cur_ee; xx++, p_cb++)
    {
        if (p_cb->conn_st == NFA_EE_CONN_ST_CONN)
        {
            if (nfa_sys_is_graceful_disable ())
            {
                /* Disconnect NCI connection on graceful shutdown */
                msg.disconnect.p_cb = p_cb;
                nfa_ee_api_disconnect (&msg);
                nfa_ee_cb.num_ee_expecting++;
            }
            else
            {
                /* fake NFA_EE_DISCONNECT_EVT on ungraceful shutdown */
                msg.conn.conn_id    = p_cb->conn_id;
                msg.conn.event      = NFC_CONN_CLOSE_CEVT;
                nfa_ee_nci_conn (&msg);
            }
        }
    }

    if (nfa_ee_cb.num_ee_expecting)
    {
        nfa_ee_cb.ee_flags |= NFA_EE_FLAG_WAIT_DISCONN;
        nfa_ee_cb.em_state  = NFA_EE_EM_STATE_DISABLING;
    }


    nfa_sys_stop_timer (&nfa_ee_cb.timer);
    nfa_sys_stop_timer (&nfa_ee_cb.discv_timer);

    /* If Application initiated NFCEE discovery, fake/report the event */
    nfa_ee_report_disc_done (FALSE);

    /* deregister message handler on NFA SYS */
    if (nfa_ee_cb.em_state == NFA_EE_EM_STATE_DISABLED)
        nfa_sys_deregister (NFA_ID_EE);

}
/*******************************************************************************
**
** Function         nfa_ee_check_disable
**
** Description      Check if it is safe to move to disabled state
**
** Returns          None
**
*******************************************************************************/
void nfa_ee_check_disable (void)
{
    if (!(nfa_ee_cb.ee_flags & NFA_EE_FLAG_WAIT_DISCONN))
    {
        nfa_ee_cb.em_state = NFA_EE_EM_STATE_DISABLED;
        nfa_sys_deregister (NFA_ID_EE);
    }
}
/*******************************************************************************
**
** Function         nfa_p2p_sys_disable
**
** Description      Deregister NFA P2P from NFA SYS/DM
**
**
** Returns          None
**
*******************************************************************************/
static void nfa_p2p_sys_disable (void)
{
    P2P_TRACE_DEBUG0 ("nfa_p2p_sys_disable()");

    nfa_sys_stop_timer (&nfa_p2p_cb.active_listen_restore_timer);

    /* deregister message handler on NFA SYS */
    nfa_sys_deregister (NFA_ID_P2P);
}
Exemple #4
0
/*******************************************************************************
**
** Function         nfa_rw_sys_disable
**
** Description      Clean up rw sub-system
**
**
** Returns          void
**
*******************************************************************************/
void nfa_rw_sys_disable (void)
{
    /* Return to idle */
    NFC_SetStaticRfCback (NULL);

    /* Stop presence check timer (if started) */
    nfa_rw_stop_presence_check_timer ();

    /* Free scratch buffer if any */
    nfa_rw_free_ndef_rx_buf ();

    /* Free pending command if any */
    if (nfa_rw_cb.p_pending_msg)
    {
        GKI_freebuf (nfa_rw_cb.p_pending_msg);
        nfa_rw_cb.p_pending_msg = NULL;
    }

    nfa_sys_deregister (NFA_ID_RW);
}