Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92a6cf91 authored by YK Jeffrey Chao's avatar YK Jeffrey Chao Committed by Android Git Automerger
Browse files

am 53853129: am 8ea4bac4: Change the log display API called in the BT PAN call-out functions

* commit '53853129':
  Change the log display API called in the BT PAN call-out functions
parents bf01af07 53853129
Loading
Loading
Loading
Loading
+40 −62
Original line number Diff line number Diff line
@@ -16,36 +16,25 @@
 *
 ******************************************************************************/

/************************************************************************************
/******************************************************************************
 *
 *  Filename:      bta_pan_co.c
 *
 *  Description:   PAN stack callout api
 *
 *
 ***********************************************************************************/
 ******************************************************************************/
#include "bta_api.h"
#include "bta_pan_api.h"
#include "bta_pan_ci.h"
#include "bta_pan_co.h"
#include "pan_api.h"
#include "gki.h"
//#include "btui.h"
//#include "btui_int.h"
#include <hardware/bluetooth.h>
#include <hardware/bt_pan.h>
#include "btif_pan_internal.h"
#include "bd.h"


#include <cutils/log.h>
#define info(fmt, ...)  ALOGI ("%s: " fmt,__FUNCTION__,  ## __VA_ARGS__)
#define debug(fmt, ...) ALOGD ("%s: " fmt,__FUNCTION__,  ## __VA_ARGS__)
#define warn(fmt, ...) ALOGW ("## WARNING : %s: " fmt "##",__FUNCTION__,  ## __VA_ARGS__)
#define error(fmt, ...) ALOGE ("## ERROR : %s: " fmt "##",__FUNCTION__,  ## __VA_ARGS__)
#define asrt(s) if(!(s)) ALOGE ("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__)


#include <string.h>


/*******************************************************************************
@@ -60,8 +49,7 @@
*******************************************************************************/
UINT8 bta_pan_co_init(UINT8 *q_level)
{

    ALOGD("bta_pan_co_init");
    BTIF_TRACE_API0("bta_pan_co_init");

    /* set the q_level to 30 buffers */
    *q_level = 30;
@@ -70,10 +58,7 @@ UINT8 bta_pan_co_init(UINT8 *q_level)
    return (BTA_PAN_RX_PUSH_BUF | BTA_PAN_RX_PUSH | BTA_PAN_TX_PULL);
}




/*******************************************************************************
/******************************************************************************
**
** Function         bta_pan_co_open
**
@@ -86,18 +71,20 @@ UINT8 bta_pan_co_init(UINT8 *q_level)
** Returns          void
**
*******************************************************************************/

void bta_pan_co_open(UINT16 handle, UINT8 app_id, tBTA_PAN_ROLE local_role, tBTA_PAN_ROLE peer_role, BD_ADDR peer_addr)
void bta_pan_co_open(UINT16 handle, UINT8 app_id, tBTA_PAN_ROLE local_role,
                            tBTA_PAN_ROLE peer_role, BD_ADDR peer_addr)
{
    ALOGD("bta_pan_co_open:app_id:%d, local_role:%d, peer_role:%d, handle:%d",
            app_id, local_role, peer_role, handle);
    BTIF_TRACE_API4("bta_pan_co_open:app_id:%d, local_role:%d, peer_role:%d, "
                    "handle:%d", app_id, local_role, peer_role, handle);
    btpan_conn_t* conn = btpan_find_conn_addr(peer_addr);
    if(conn == NULL)
        conn = btpan_new_conn(handle, peer_addr, local_role, peer_role);
    if(conn)
    {
        ALOGD("bta_pan_co_open:tap_fd:%d, open_count:%d, conn->handle:%d should = handle:%d, local_role:%d, remote_role:%d",
             btpan_cb.tap_fd, btpan_cb.open_count, conn->handle, handle, conn->local_role, conn->remote_role);
        BTIF_TRACE_DEBUG6("bta_pan_co_open:tap_fd:%d, open_count:%d, "
            "conn->handle:%d should = handle:%d, local_role:%d, remote_role:%d",
             btpan_cb.tap_fd, btpan_cb.open_count, conn->handle, handle,
             conn->local_role, conn->remote_role);
        //refresh the role & bt address

        btpan_cb.open_count++;
@@ -117,7 +104,6 @@ void bta_pan_co_open(UINT16 handle, UINT8 app_id, tBTA_PAN_ROLE local_role, tBTA
    }
}


/*******************************************************************************
**
** Function         bta_pan_co_close
@@ -131,11 +117,11 @@ void bta_pan_co_open(UINT16 handle, UINT8 app_id, tBTA_PAN_ROLE local_role, tBTA
*******************************************************************************/
void bta_pan_co_close(UINT16 handle, UINT8 app_id)
{
    ALOGD("bta_pan_co_close:app_id:%d, handle:%d", app_id, handle);
    BTIF_TRACE_API2("bta_pan_co_close:app_id:%d, handle:%d", app_id, handle);
    btpan_conn_t* conn = btpan_find_conn_handle(handle);
    if(conn && conn->state == PAN_STATE_OPEN)
    {
        ALOGD("bta_pan_co_close");
        BTIF_TRACE_DEBUG0("bta_pan_co_close");

        // let bta close event reset this handle as it needs
        // the handle to find the connection upon CLOSE
@@ -182,36 +168,40 @@ void bta_pan_co_tx_path(UINT16 handle, UINT8 app_id)
    BOOLEAN            ext;
    BOOLEAN         forward;

    ALOGD("bta_pan_co_tx_path, handle:%d, app_id:%d", handle, app_id);
    BTIF_TRACE_API2("bta_pan_co_tx_path, handle:%d, app_id:%d", handle, app_id);

    btpan_conn_t* conn = btpan_find_conn_handle(handle);
    if(conn && conn->state != PAN_STATE_OPEN)
    {
        ALOGE("bta_pan_co_tx_path: cannot find pan connction or conn is not opened, conn:%p, conn->state:%d", conn, conn->state);
        BTIF_TRACE_ERROR2("bta_pan_co_tx_path: cannot find pan connction or conn"
            "is not opened, conn:%p, conn->state:%d", conn, conn->state);
        return;
    }
    do
    {

        /* read next data buffer from pan */
        if ((p_buf = bta_pan_ci_readbuf(handle, src, dst, &protocol,
                                 &ext, &forward)))
        {
            ALOGD("bta_pan_co_tx_path, calling btapp_tap_send, p_buf->len:%d, offset:%d", p_buf->len, p_buf->offset);
            BTIF_TRACE_DEBUG2("bta_pan_co_tx_path, calling btapp_tap_send, "
                "p_buf->len:%d, offset:%d", p_buf->len, p_buf->offset);
            if(is_empty_eth_addr(conn->eth_addr) && is_valid_bt_eth_addr(src))
            {
                ALOGD("pan bt peer addr: %02x:%02x:%02x:%02x:%02x:%02x, update its ethernet addr: %02x:%02x:%02x:%02x:%02x:%02x",
                        conn->peer[0], conn->peer[1], conn->peer[2], conn->peer[3],conn->peer[4], conn->peer[5],
                        src[0], src[1], src[2], src[3],src[4], src[5]);
                BTIF_TRACE_DEBUG6("pan bt peer addr: %02x:%02x:%02x:%02x:%02x:%02x",
                    conn->peer[0], conn->peer[1], conn->peer[2],
                    conn->peer[3],conn->peer[4], conn->peer[5]);
                BTIF_TRACE_DEBUG6("     update its ethernet addr: "
                    "%02x:%02x:%02x:%02x:%02x:%02x", src[0], src[1], src[2],
                    src[3],src[4], src[5]);
                memcpy(conn->eth_addr, src, sizeof(conn->eth_addr));

            }
            btpan_tap_send(btpan_cb.tap_fd, src, dst, protocol, (char*)(p_buf + 1) + p_buf->offset, p_buf->len, ext, forward);
            btpan_tap_send(btpan_cb.tap_fd, src, dst, protocol,
                (char*)(p_buf + 1) + p_buf->offset, p_buf->len, ext, forward);
            GKI_freebuf(p_buf);
        }

    } while (p_buf != NULL);

}

/*******************************************************************************
@@ -228,13 +218,7 @@ void bta_pan_co_tx_path(UINT16 handle, UINT8 app_id)
*******************************************************************************/
void bta_pan_co_rx_path(UINT16 handle, UINT8 app_id)
{


    UINT8           i;

    ALOGD("bta_pan_co_rx_path not used");


    BTIF_TRACE_API0("bta_pan_co_rx_path not used");
}

/*******************************************************************************
@@ -250,11 +234,11 @@ void bta_pan_co_rx_path(UINT16 handle, UINT8 app_id)
** Returns          void
**
*******************************************************************************/
void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst, UINT16 protocol, UINT8 *p_data,
void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst,
                                UINT16 protocol, UINT8 *p_data,
                                UINT16 len, BOOLEAN ext, BOOLEAN forward)
{
     ALOGD("bta_pan_co_tx_write not used");

     BTIF_TRACE_API0("bta_pan_co_tx_write not used");
}

/*******************************************************************************
@@ -270,13 +254,11 @@ void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst,
** Returns          TRUE if flow enabled
**
*******************************************************************************/
void  bta_pan_co_tx_writebuf(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst, UINT16 protocol, BT_HDR *p_buf,
void  bta_pan_co_tx_writebuf(UINT16 handle, UINT8 app_id, BD_ADDR src,
                                    BD_ADDR dst, UINT16 protocol, BT_HDR *p_buf,
                                    BOOLEAN ext, BOOLEAN forward)
{

    ALOGD("bta_pan_co_tx_writebuf not used");


    BTIF_TRACE_API0("bta_pan_co_tx_writebuf not used");
}

/*******************************************************************************
@@ -295,12 +277,9 @@ void bta_pan_co_tx_writebuf(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR d
*******************************************************************************/
void bta_pan_co_rx_flow(UINT16 handle, UINT8 app_id, BOOLEAN enable)
{

    ALOGD("bta_pan_co_rx_flow, enabled:%d, not used", enable);

    BTIF_TRACE_API1("bta_pan_co_rx_flow, enabled:%d, not used", enable);
}


/*******************************************************************************
**
** Function         bta_pan_co_filt_ind
@@ -313,9 +292,9 @@ void bta_pan_co_rx_flow(UINT16 handle, UINT8 app_id, BOOLEAN enable)
void bta_pan_co_pfilt_ind(UINT16 handle, BOOLEAN indication, tBTA_PAN_STATUS result,
                                    UINT16 len, UINT8 *p_filters)
{
    ALOGD("bta_pan_co_pfilt_ind");

    BTIF_TRACE_API0("bta_pan_co_pfilt_ind");
}

/*******************************************************************************
**
** Function         bta_pan_co_mfilt_ind
@@ -328,7 +307,6 @@ void bta_pan_co_pfilt_ind(UINT16 handle, BOOLEAN indication, tBTA_PAN_STATUS res
void bta_pan_co_mfilt_ind(UINT16 handle, BOOLEAN indication, tBTA_PAN_STATUS result,
                                    UINT16 len, UINT8 *p_filters)
{

    ALOGD("bta_pan_co_mfilt_ind");
    BTIF_TRACE_API0("bta_pan_co_mfilt_ind");
}