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

Commit 3a054638 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Matthew Xie
Browse files

LE: Integrate power table for GATT

No power table exists for GATT, causing the device to never enter sniff
mode while using GATT over BR/EDR.

Change-Id: I0db539c1814a61af620f3dba560da64481291beb
parent 137f926c
Loading
Loading
Loading
Loading
+63 −2
Original line number Diff line number Diff line
@@ -105,8 +105,11 @@ tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *)&bta_dm_cfg;

tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;


#if BLE_INCLUDED == TRUE
#define BTA_DM_NUM_PM_ENTRY         (17+BTA_DM_NUM_JV_ID)  /* number of entries in bta_dm_pm_cfg except the first */
#else
#define BTA_DM_NUM_PM_ENTRY         (15+BTA_DM_NUM_JV_ID)  /* number of entries in bta_dm_pm_cfg except the first */
#endif

tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[] =
{
@@ -128,14 +131,26 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[] =
  {BTA_ID_JV,  BTA_JV_PM_ID_1,      6},  /* app BTA_JV_PM_ID_1, reuse ftc spec table */
  {BTA_ID_JV,  BTA_ALL_APP_ID,      7},  /* reuse fts spec table */
  {BTA_ID_HL,  BTA_ALL_APP_ID,      8}   /* reuse fts spec table */
#if BLE_INCLUDED == TRUE
  ,{BTA_ID_GATTC,  BTA_ALL_APP_ID,   9}   /* gattc spec table */
  ,{BTA_ID_GATTS,  BTA_ALL_APP_ID,   10}  /* gatts spec table */
#endif
};


#if BLE_INCLUDED == TRUE /* add GATT PM entry for GATT over BR/EDR  */
#ifdef BTE_SIM_APP      /* For Insight builds only, see the detail below */
#define BTA_DM_NUM_PM_SPEC      (11 + 2)  /* additional two */
#else
#define BTA_DM_NUM_PM_SPEC      11 /* additional JV*/
#endif
#else
#ifdef BTE_SIM_APP      /* For Insight builds only, see the detail below */
#define BTA_DM_NUM_PM_SPEC      (9 + 2)  /* additional two */
#else
#define BTA_DM_NUM_PM_SPEC      9  /* additional JV*/
#endif
#endif


tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] =
{
@@ -310,6 +325,52 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] =
  }
 }

#if BLE_INCLUDED == TRUE
    /* GATTC */
 ,{
  (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
#if (BTM_SSR_INCLUDED == TRUE)
  (BTA_DM_PM_SSR2),                                              /* the SSR entry */
#endif
  {
      {{BTA_DM_PM_SNIFF,  10000},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
      {{BTA_DM_PM_NO_PREF,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
      {{BTA_DM_PM_ACTIVE,     0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
      {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
      {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
      {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
      {{BTA_DM_PM_SNIFF,  10000},   {BTA_DM_PM_NO_ACTION, 0}},    /* idle */
      {{BTA_DM_PM_ACTIVE,     0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
#if (AMP_INCLUDED == TRUE)
      {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},   /* amp */
#endif
      {{BTA_DM_PM_RETRY,   5000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
  }
 }
    /* GATTS */
 ,{
  (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
#if (BTM_SSR_INCLUDED == TRUE)
  (BTA_DM_PM_SSR2),                                              /* the SSR entry */
#endif
  {
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* idle */
      {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
#if (AMP_INCLUDED == TRUE)
      {{BTA_DM_PM_NO_PREF, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* amp */
#endif
      {{BTA_DM_PM_RETRY,  5000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
  }
 }

#endif

#ifdef BTE_SIM_APP      /* For Insight builds only */
 /* Entries at the end of the pm_spec table are user-defined (runtime configurable),
    for power consumption experiments.
+29 −2
Original line number Diff line number Diff line
@@ -166,7 +166,10 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
    tBTA_GATTC_INT_START_IF  *p_buf;
    tBTA_GATT_STATUS         status = BTA_GATT_NO_RESOURCES;


    APPL_TRACE_DEBUG1("bta_gattc_register state %d",p_cb->state);
    memset(&cb_data, 0, sizeof(cb_data));
    cb_data.reg_oper.status = BTA_GATT_NO_RESOURCES;

     /* check if  GATTC module is already enabled . Else enable */
     if (p_cb->state == BTA_GATTC_STATE_DISABLED)
@@ -656,6 +659,9 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)

        if (p_clcb->p_rcb)
        {
            /* there is no RM for GATT */
            if (!BTM_IsBleLink(p_clcb->bda))
                bta_sys_conn_open(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
            bta_gattc_send_open_cback(p_clcb->p_rcb,
                                      BTA_GATT_OK,
                                      p_clcb->bda,
@@ -712,7 +718,13 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
    cb_data.close.status    = p_clcb->status;
    bdcpy(cb_data.close.remote_bda, p_clcb->bda);

    if (!BTM_IsBleLink(p_clcb->bda))
        bta_sys_conn_close( BTA_ID_GATTC ,BTA_ALL_APP_ID, p_clcb->bda);

    if (p_clcb->status == BTA_GATT_OK)
    {
        bta_gattc_clcb_dealloc(p_clcb);
    }

    if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT)
        cb_data.close.status = GATT_Disconnect(p_data->hdr.layer_specific);
@@ -1143,6 +1155,13 @@ void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
        {
            APPL_TRACE_ERROR1("bta_gattc_confirm to handle [0x%04x] failed", handle);
        }
        /* if over BR_EDR, inform PM for mode change */
        else if (!BTM_IsBleLink(p_clcb->bda))
        {
            bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
            bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
        }

    }
}
/*******************************************************************************
@@ -1916,6 +1935,14 @@ static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
        return;
    }


/* if over BR_EDR, inform PM for mode change */
    if (!BTM_IsBleLink(p_clcb->bda))
    {
        bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
        bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
    }

    if ((p_buf = (tBTA_GATTC_OP_CMPL *) GKI_getbuf(len)) != NULL)
    {
        memset(p_buf, 0, len);
+0 −2
Original line number Diff line number Diff line
@@ -427,7 +427,6 @@ void bta_gattc_get_disc_range(tBTA_GATTC_SERV *p_srvc_cb, UINT16 *p_s_hdl, UINT1
*******************************************************************************/
tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type)
{
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
    tBT_DEVICE_TYPE dev_type;
    tBLE_ADDR_TYPE  addr_type;

@@ -436,7 +435,6 @@ tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV
        return bta_gattc_discover_procedure(conn_id, p_server_cb, disc_type);
    else
        return bta_gattc_sdp_service_disc(conn_id, p_server_cb);
#endif
    return BTA_GATT_ERROR;

}
+51 −18
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
#include "bta_sys.h"
#include "bta_gatts_int.h"
#include "bta_gatts_co.h"

#include "btm_ble_api.h"
#include <string.h>

static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
@@ -589,9 +589,9 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_m
}
/*******************************************************************************
**
** Function         bta_gatts_send_rsp
** Function         bta_gatts_indicate_handle
**
** Description      GATTS send response.
** Description      GATTS send handle value indication or notification.
**
** Returns          none.
**
@@ -610,9 +610,9 @@ void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
}
/*******************************************************************************
**
** Function         bta_gatts_send_rsp
** Function         bta_gatts_indicate_handle
**
** Description      GATTS send response.
** Description      GATTS indicate handel value
**
** Returns          none.
**
@@ -620,12 +620,16 @@ void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
{
    tBTA_GATTS_SRVC_CB  *p_srvc_cb;
    tBTA_GATT_STATUS    status;
    tBTA_GATT_STATUS    status = BTA_GATT_ILLEGAL_PARAMETER;
    tGATT_IF            gatt_if;
    BD_ADDR             remote_bda;


    p_srvc_cb = bta_gatts_find_srvc_cb_by_attr_id (p_cb, p_msg->api_indicate.attr_id);

    if (p_srvc_cb )
    {
        if (GATT_GetConnectionInfor(p_msg->api_indicate.hdr.layer_specific, &gatt_if, remote_bda))
        {
            if (p_msg->api_indicate.need_confirm)

@@ -639,8 +643,20 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
                                                        p_msg->api_indicate.len,
                                                        p_msg->api_indicate.value);

        if (status != GATT_SUCCESS &&
            p_msg->api_indicate.need_confirm &&
            /* if over BR_EDR, inform PM for mode change */
            if (!BTM_IsBleLink(remote_bda))
            {
                bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
                bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
            }
        }
        else
        {
            APPL_TRACE_ERROR1("Unknown connection ID: %d fail sending notification",
                              p_msg->api_indicate.hdr.layer_specific);
        }

        if (status != GATT_SUCCESS && p_msg->api_indicate.need_confirm &&
            p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)
        {
            (*p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)(BTA_GATTS_CONF_EVT, (tBTA_GATTS *)&status);
@@ -648,7 +664,8 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
    }
    else
    {
        APPL_TRACE_ERROR1("Not an registered servce attribute ID: 0x%04x", p_msg->api_indicate.attr_id);
        APPL_TRACE_ERROR1("Not an registered servce attribute ID: 0x%04x",
                          p_msg->api_indicate.attr_id);
    }
}

@@ -747,8 +764,13 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
        p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);

        if (p_rcb && p_rcb->p_cback)
        {
            if (!BTM_IsBleLink(remote_bda))
                bta_sys_conn_close( BTA_ID_GATTS ,BTA_ALL_APP_ID, remote_bda);

            (*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT,  (tBTA_GATTS *)&status);
        }
    }
    else
    {
        APPL_TRACE_ERROR1("Unknown connection ID: %d", p_msg->hdr.layer_specific);
@@ -783,6 +805,13 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,

        if (p_rcb && p_rcb->p_cback)
        {
            /* if over BR_EDR, inform PM for mode change */
            if (!BTM_IsBleLink(cb_data.req_data.remote_bda))
            {
                bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
                bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
            }

            cb_data.req_data.conn_id    = conn_id;
            cb_data.req_data.trans_id   = trans_id;
            cb_data.req_data.p_data     = (tBTA_GATTS_REQ_DATA *)p_data;
@@ -825,6 +854,10 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,

    if (p_reg && p_reg->p_cback)
    {
        /* there is no RM for GATT */
        if (!BTM_IsBleLink(bda))
            bta_sys_conn_open(BTA_ID_GATTS, BTA_ALL_APP_ID, bda);

        cb_data.conn.conn_id = conn_id;
        cb_data.conn.server_if = gatt_if;
        cb_data.conn.reason = reason;
+1 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ typedef UINT8 tBTA_SEC;

#define BTA_DM_IGNORE           0xFF

#define BTA_ALL_APP_ID          0xFF

/* Discoverable Modes */
#define BTA_DM_NON_DISC         BTM_NON_DISCOVERABLE        /* Device is not discoverable. */
Loading