From 2e8c421ddce1dae511a39b8e89415e8eb1944bfd Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Fri, 28 Oct 2016 15:23:08 -0700 Subject: [PATCH] Remove advertise whitelist functionality Advertise filtering is never used. It is not finished - adding device to whitelist can never succed. It is also making advertising API unification hard. Bug: 30622771 Test: no tests necessary Change-Id: I9df9ea18b265a580c2fcdb28a6d6ce4be43f0a24 --- bta/gatt/bta_gattc_act.cc | 48 +++---------- bta/gatt/bta_gattc_api.cc | 10 +-- bta/gatt/bta_gattc_int.h | 1 - bta/gatt/bta_gatts_act.cc | 34 --------- bta/gatt/bta_gatts_api.cc | 33 --------- bta/gatt/bta_gatts_int.h | 12 ---- bta/gatt/bta_gatts_main.cc | 5 -- bta/include/bta_gatt_api.h | 22 +----- btif/src/btif_gatt_client.cc | 2 +- stack/btm/btm_ble_gap.cc | 15 ---- stack/gatt/gatt_api.cc | 36 ++-------- stack/gatt/gatt_int.h | 5 +- stack/gatt/gatt_utils.cc | 161 ++++++++++--------------------------------- stack/include/btm_ble_api.h | 11 --- stack/include/gatt_api.h | 8 +-- 15 files changed, 61 insertions(+), 342 deletions(-) diff --git a/bta/gatt/bta_gattc_act.cc b/bta/gatt/bta_gattc_act.cc index 97c36960a..ec16fb055 100644 --- a/bta/gatt/bta_gattc_act.cc +++ b/bta/gatt/bta_gattc_act.cc @@ -1991,49 +1991,21 @@ void bta_gattc_listen(tBTA_GATTC_DATA * p_msg) } /* mark bg conn record */ if (bta_gattc_mark_bg_conn(p_msg->api_listen.client_if, - (BD_ADDR_PTR) p_msg->api_listen.remote_bda, + (BD_ADDR_PTR) NULL, p_msg->api_listen.start, true)) { - if (!GATT_Listen(p_msg->api_listen.client_if, - p_msg->api_listen.start, - p_msg->api_listen.remote_bda)) - { - APPL_TRACE_ERROR("Listen failure"); - (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - } - else - { - cb_data.status = BTA_GATT_OK; - - (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - - if (p_msg->api_listen.start) - { - /* if listen to a specific target */ - if (p_msg->api_listen.remote_bda != NULL) - { + GATT_Listen(p_msg->api_listen.start); + cb_data.status = BTA_GATT_OK; - /* if is a connected remote device */ - if (L2CA_GetBleConnRole(p_msg->api_listen.remote_bda) == HCI_ROLE_SLAVE && - bta_gattc_find_clcb_by_cif(p_msg->api_listen.client_if, - p_msg->api_listen.remote_bda, - BTA_GATT_TRANSPORT_LE) == NULL) - { + (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - bta_gattc_init_clcb_conn(p_msg->api_listen.client_if, - p_msg->api_listen.remote_bda); - } - } - /* if listen to all */ - else - { - LOG_DEBUG(LOG_TAG, "Listen For All now"); - /* go through all connected device and send - callback for all connected slave connection */ - bta_gattc_process_listen_all(p_msg->api_listen.client_if); - } - } + if (p_msg->api_listen.start) + { + LOG_DEBUG(LOG_TAG, "Listen For All now"); + /* go through all connected device and send + callback for all connected slave connection */ + bta_gattc_process_listen_all(p_msg->api_listen.client_if); } } } diff --git a/bta/gatt/bta_gattc_api.cc b/bta/gatt/bta_gattc_api.cc index 39c3b6991..68ed1e8bd 100644 --- a/bta/gatt/bta_gattc_api.cc +++ b/bta/gatt/bta_gattc_api.cc @@ -726,13 +726,11 @@ void BTA_GATTC_Refresh(const BD_ADDR remote_bda) ** ** Parameters client_if: server interface. ** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. ** ** Returns void ** *******************************************************************************/ -void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start, BD_ADDR_PTR target_bda) +void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start) { tBTA_GATTC_API_LISTEN *p_buf = (tBTA_GATTC_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN); @@ -740,12 +738,6 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start, BD_ADDR_PTR target_bd p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT; p_buf->client_if = client_if; p_buf->start = start; - if (target_bda) { - p_buf->remote_bda = (uint8_t*)(p_buf + 1); - memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN); - } else { - p_buf->remote_bda = NULL; - } bta_sys_sendmsg(p_buf); } diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h index 089b05dcc..60991bc3f 100644 --- a/bta/gatt/bta_gattc_int.h +++ b/bta/gatt/bta_gattc_int.h @@ -181,7 +181,6 @@ typedef struct typedef struct { BT_HDR hdr; - BD_ADDR_PTR remote_bda; tBTA_GATTC_IF client_if; bool start; } tBTA_GATTC_API_LISTEN; diff --git a/bta/gatt/bta_gatts_act.cc b/bta/gatt/bta_gatts_act.cc index b9394f53d..331e5e0d0 100644 --- a/bta/gatt/bta_gatts_act.cc +++ b/bta/gatt/bta_gatts_act.cc @@ -582,40 +582,6 @@ void bta_gatts_close (UNUSED_ATTR tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg) } } -/******************************************************************************* -** -** Function bta_gatts_listen -** -** Description Start or stop listening for LE connection on a GATT server -** -** Returns none. -** -*******************************************************************************/ -void bta_gatts_listen(UNUSED_ATTR tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg) -{ - tBTA_GATTS_RCB *p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_listen.server_if); - tBTA_GATTS cb_data; - - cb_data.reg_oper.status = BTA_GATT_OK; - cb_data.reg_oper.server_if = p_msg->api_listen.server_if; - - if (p_rcb == NULL) - { - APPL_TRACE_ERROR("Unknown GATTS application"); - return; - } - - if (!GATT_Listen(p_msg->api_listen.server_if, - p_msg->api_listen.start, - p_msg->api_listen.remote_bda)) - { - cb_data.status = BTA_GATT_ERROR; - APPL_TRACE_ERROR("bta_gatts_listen Listen failed"); - } - - if (p_rcb->p_cback) - (*p_rcb->p_cback)(BTA_GATTS_LISTEN_EVT, &cb_data); -} /******************************************************************************* ** diff --git a/bta/gatt/bta_gatts_api.cc b/bta/gatt/bta_gatts_api.cc index 64bb05f5e..e1b066998 100644 --- a/bta/gatt/bta_gatts_api.cc +++ b/bta/gatt/bta_gatts_api.cc @@ -353,37 +353,4 @@ void BTA_GATTS_Close(uint16_t conn_id) bta_sys_sendmsg(p_buf); } -/******************************************************************************* -** -** Function BTA_GATTS_Listen -** -** Description Start advertisement to listen for connection request for a -** GATT server -** -** Parameters server_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, bool start, BD_ADDR_PTR target_bda) -{ - tBTA_GATTS_API_LISTEN *p_buf = - (tBTA_GATTS_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN); - - p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT; - p_buf->server_if = server_if; - p_buf->start = start; - if (target_bda) { - p_buf->remote_bda = (uint8_t *)(p_buf + 1); - memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN); - } else { - p_buf->remote_bda = NULL; - } - - bta_sys_sendmsg(p_buf); -} - #endif /* BTA_GATT_INCLUDED */ diff --git a/bta/gatt/bta_gatts_int.h b/bta/gatt/bta_gatts_int.h index 3628e2f92..23f3513c2 100644 --- a/bta/gatt/bta_gatts_int.h +++ b/bta/gatt/bta_gatts_int.h @@ -47,7 +47,6 @@ enum BTA_GATTS_API_OPEN_EVT, BTA_GATTS_API_CANCEL_OPEN_EVT, BTA_GATTS_API_CLOSE_EVT, - BTA_GATTS_API_LISTEN_EVT, BTA_GATTS_API_DISABLE_EVT }; typedef uint16_t tBTA_GATTS_INT_EVT; @@ -118,14 +117,6 @@ typedef struct typedef tBTA_GATTS_API_OPEN tBTA_GATTS_API_CANCEL_OPEN; -typedef struct -{ - BT_HDR hdr; - BD_ADDR_PTR remote_bda; - tBTA_GATTS_IF server_if; - bool start; -} tBTA_GATTS_API_LISTEN; - typedef union { BT_HDR hdr; @@ -138,8 +129,6 @@ typedef union tBTA_GATTS_API_CANCEL_OPEN api_cancel_open; tBTA_GATTS_INT_START_IF int_start_if; - /* if peripheral role is supported */ - tBTA_GATTS_API_LISTEN api_listen; } tBTA_GATTS_DATA; /* application registration control block */ @@ -199,7 +188,6 @@ extern void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_ extern void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg); extern void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg); extern void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg); -extern void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg); extern bool bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src); extern tBTA_GATTS_RCB *bta_gatts_find_app_rcb_by_app_if(tBTA_GATTS_IF server_if); diff --git a/bta/gatt/bta_gatts_main.cc b/bta/gatt/bta_gatts_main.cc index 9f78caef4..ceff956cb 100644 --- a/bta/gatt/bta_gatts_main.cc +++ b/bta/gatt/bta_gatts_main.cc @@ -86,11 +86,6 @@ bool bta_gatts_hdl_event(BT_HDR *p_msg) bta_gatts_send_rsp(p_cb,(tBTA_GATTS_DATA *) p_msg); break; - case BTA_GATTS_API_LISTEN_EVT: - bta_gatts_listen(p_cb,(tBTA_GATTS_DATA *) p_msg); - break; - - case BTA_GATTS_API_DEL_SRVC_EVT: { tBTA_GATTS_SRVC_CB *p_srvc_cb = bta_gatts_find_srvc_cb_by_srvc_id(p_cb, diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h index e4f05d54f..f6a88d38a 100644 --- a/bta/include/bta_gatt_api.h +++ b/bta/include/bta_gatt_api.h @@ -932,13 +932,11 @@ extern void BTA_GATTC_Refresh(const BD_ADDR remote_bda); ** ** Parameters client_if: server interface. ** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. ** ** Returns void ** *******************************************************************************/ -extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start, BD_ADDR_PTR target_bda); +extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start); /******************************************************************************* ** @@ -1157,22 +1155,4 @@ extern void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, bo *******************************************************************************/ extern void BTA_GATTS_Close(uint16_t conn_id); -/******************************************************************************* -** -** Function BTA_GATTS_Listen -** -** Description Start advertisement to listen for connection request for a -** GATT server -** -** Parameters server_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -extern void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, bool start, - BD_ADDR_PTR target_bda); - #endif /* BTA_GATT_API_H */ diff --git a/btif/src/btif_gatt_client.cc b/btif/src/btif_gatt_client.cc index 53a3b5c04..dcf10deed 100644 --- a/btif/src/btif_gatt_client.cc +++ b/btif/src/btif_gatt_client.cc @@ -338,7 +338,7 @@ bt_status_t btif_gattc_listen(int client_if, bool start) { CHECK_BTGATT_INIT(); #if (defined(BLE_PERIPHERAL_MODE_SUPPORT) && \ (BLE_PERIPHERAL_MODE_SUPPORT == true)) - return do_in_jni_thread(Bind(&BTA_GATTC_Listen, client_if, start, nullptr)); + return do_in_jni_thread(Bind(&BTA_GATTC_Listen, client_if, start)); #else return do_in_jni_thread(Bind(&BTA_GATTC_Broadcast, client_if, start)); #endif diff --git a/stack/btm/btm_ble_gap.cc b/stack/btm/btm_ble_gap.cc index ddd3a4e8b..61433819a 100644 --- a/stack/btm/btm_ble_gap.cc +++ b/stack/btm/btm_ble_gap.cc @@ -229,21 +229,6 @@ const uint8_t btm_le_state_combo_tbl[BTM_BLE_STATE_MAX][BTM_BLE_STATE_MAX][2] = /******************************************************************************* ** -** Function BTM_BleUpdateAdvWhitelist -** -** Description Add or remove device from advertising white list -** -** Returns void -** -*******************************************************************************/ -bool BTM_BleUpdateAdvWhitelist(UNUSED_ATTR bool add_remove, - UNUSED_ATTR BD_ADDR remote_bda) -{ - return false; -} - -/******************************************************************************* -** ** Function BTM_BleUpdateAdvFilterPolicy ** ** Description This function update the filter policy of advertiser. diff --git a/stack/gatt/gatt_api.cc b/stack/gatt/gatt_api.cc index 3a6b576b2..f7d809b39 100644 --- a/stack/gatt/gatt_api.cc +++ b/stack/gatt/gatt_api.cc @@ -1165,7 +1165,7 @@ void GATT_Deregister (tGATT_IF gatt_if) gatt_deregister_bgdev_list(gatt_if); /* update the listen mode */ #if (BLE_PERIPHERAL_MODE_SUPPORT == TRUE) - GATT_Listen(gatt_if, false, NULL); + GATT_Listen(false); #endif memset (p_reg, 0, sizeof(tGATT_REG)); @@ -1246,7 +1246,7 @@ bool GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, bool is_direct, else { if (transport == BT_TRANSPORT_LE) - status = gatt_update_auto_connect_dev(gatt_if,true, bd_addr, true); + status = gatt_update_auto_connect_dev(gatt_if,true, bd_addr); else { GATT_TRACE_ERROR("Unsupported transport for background connection"); @@ -1446,37 +1446,13 @@ bool GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, uint16_t *p ** Description This function start or stop LE advertisement and listen for ** connection. ** -** Parameters gatt_if: applicaiton interface -** p_bd_addr: listen for specific address connection, or NULL for -** listen to all device connection. -** start: start or stop listening. -** -** Returns true if advertisement is started; false if adv start failure. +** Parameters start: start or stop listening. ** *******************************************************************************/ -bool GATT_Listen (tGATT_IF gatt_if, bool start, BD_ADDR_PTR bd_addr) +void GATT_Listen(bool start) { - tGATT_REG *p_reg; - - GATT_TRACE_API ("GATT_Listen gatt_if=%d", gatt_if); - - /* Make sure app is registered */ - if ((p_reg = gatt_get_regcb(gatt_if)) == NULL) - { - GATT_TRACE_ERROR("GATT_Listen - gatt_if =%d is not registered", gatt_if); - return(false); - } - - if (bd_addr != NULL) - { - gatt_update_auto_connect_dev(gatt_if,start, bd_addr, false); - } - else - { - p_reg->listening = start ? GATT_LISTEN_TO_ALL : GATT_LISTEN_TO_NONE; - } - - return gatt_update_listen_mode(); + GATT_TRACE_API("GATT_Listen start=%d", start); + gatt_update_listen_mode(start ? GATT_LISTEN_TO_ALL : GATT_LISTEN_TO_NONE); } #endif diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h index 4990d7fe5..ba1fe8fb4 100644 --- a/stack/gatt/gatt_int.h +++ b/stack/gatt/gatt_int.h @@ -411,7 +411,6 @@ typedef struct typedef struct { tGATT_IF gatt_if[GATT_MAX_APPS]; - tGATT_IF listen_gif[GATT_MAX_APPS]; BD_ADDR remote_bda; bool in_use; }tGATT_BG_CONN_DEV; @@ -543,7 +542,7 @@ extern void gatt_set_srv_chg(void); extern void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr); extern tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB *p_tcb, tGATT_VALUE *p_ind); extern void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id); -extern bool gatt_update_listen_mode(void); +extern void gatt_update_listen_mode(int listening); extern bool gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb); /* reserved handle list */ @@ -560,7 +559,7 @@ extern bool gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_ extern tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg); /* for background connection */ -extern bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_addr, bool is_initiator); +extern bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_addr); extern bool gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV *p_dev, tGATT_IF gatt_if); extern bool gatt_remove_bg_dev_for_app(tGATT_IF gatt_if, BD_ADDR bd_addr); extern uint8_t gatt_get_num_apps_for_bg_dev(BD_ADDR bd_addr); diff --git a/stack/gatt/gatt_utils.cc b/stack/gatt/gatt_utils.cc index 06b2378da..cfa86b7eb 100644 --- a/stack/gatt/gatt_utils.cc +++ b/stack/gatt/gatt_utils.cc @@ -2398,7 +2398,7 @@ tGATT_BG_CONN_DEV * gatt_alloc_bg_dev(BD_ADDR remote_bda) ** Returns true if device added to the list; false failed ** *******************************************************************************/ -bool gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, bool is_initator) +bool gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr) { tGATT_IF gatt_if = p_reg->gatt_if; tGATT_BG_CONN_DEV *p_dev = NULL; @@ -2414,44 +2414,19 @@ bool gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, bool is_init { for (i = 0; i < GATT_MAX_APPS; i ++) { - if (is_initator) + if (p_dev->gatt_if[i] == gatt_if) { - if (p_dev->gatt_if[i] == gatt_if) - { - GATT_TRACE_ERROR("device already in iniator white list"); - return true; - } - else if (p_dev->gatt_if[i] == 0) - { - p_dev->gatt_if[i] = gatt_if; - if (i == 0) - ret = BTM_BleUpdateBgConnDev(true, bd_addr); - else - ret = true; - break; - } + GATT_TRACE_ERROR("device already in iniator white list"); + return true; } - else + else if (p_dev->gatt_if[i] == 0) { - if (p_dev->listen_gif[i] == gatt_if) - { - GATT_TRACE_ERROR("device already in adv white list"); - return true; - } - else if (p_dev->listen_gif[i] == 0) - { - if (p_reg->listening == GATT_LISTEN_TO_ALL) - p_reg->listening = GATT_LISTEN_TO_NONE; - - p_reg->listening ++; - p_dev->listen_gif[i] = gatt_if; - - if (i == 0) - ret = BTM_BleUpdateAdvWhitelist(true, bd_addr); - else - ret = true; - break; - } + p_dev->gatt_if[i] = gatt_if; + if (i == 0) + ret = BTM_BleUpdateBgConnDev(true, bd_addr); + else + ret = true; + break; } } } @@ -2479,7 +2454,7 @@ bool gatt_remove_bg_dev_for_app(tGATT_IF gatt_if, BD_ADDR bd_addr) if (p_tcb) gatt_update_app_use_link_flag(gatt_if, p_tcb, false, false); - status = gatt_update_auto_connect_dev(gatt_if, false, bd_addr, true); + status = gatt_update_auto_connect_dev(gatt_if, false, bd_addr); return status; } @@ -2553,7 +2528,7 @@ bool gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if) ** Returns pointer to the device record ** *******************************************************************************/ -bool gatt_remove_bg_dev_from_list(tGATT_REG *p_reg, BD_ADDR bd_addr, bool is_initiator) +bool gatt_remove_bg_dev_from_list(tGATT_REG *p_reg, BD_ADDR bd_addr) { tGATT_IF gatt_if = p_reg->gatt_if; tGATT_BG_CONN_DEV *p_dev = NULL; @@ -2565,45 +2540,25 @@ bool gatt_remove_bg_dev_from_list(tGATT_REG *p_reg, BD_ADDR bd_addr, bool return ret; } - for (i = 0; i < GATT_MAX_APPS && (p_dev->gatt_if[i] > 0 || p_dev->listen_gif[i]); i ++) + for (i = 0; i < GATT_MAX_APPS && (p_dev->gatt_if[i] > 0); i ++) { - if (is_initiator) + if (p_dev->gatt_if[i] == gatt_if) { - if (p_dev->gatt_if[i] == gatt_if) - { - p_dev->gatt_if[i] = 0; - /* move all element behind one forward */ - for (j = i + 1; j < GATT_MAX_APPS; j ++) - p_dev->gatt_if[j - 1] = p_dev->gatt_if[j]; + p_dev->gatt_if[i] = 0; + /* move all element behind one forward */ + for (j = i + 1; j < GATT_MAX_APPS; j ++) + p_dev->gatt_if[j - 1] = p_dev->gatt_if[j]; - if (p_dev->gatt_if[0] == 0) - ret = BTM_BleUpdateBgConnDev(false, p_dev->remote_bda); - else - ret = true; + if (p_dev->gatt_if[0] == 0) + ret = BTM_BleUpdateBgConnDev(false, p_dev->remote_bda); + else + ret = true; - break; - } - } - else - { - if (p_dev->listen_gif[i] == gatt_if) - { - p_dev->listen_gif[i] = 0; - p_reg->listening --; - /* move all element behind one forward */ - for (j = i + 1; j < GATT_MAX_APPS; j ++) - p_dev->listen_gif[j - 1] = p_dev->listen_gif[j]; - - if (p_dev->listen_gif[0] == 0) - ret = BTM_BleUpdateAdvWhitelist(false, p_dev->remote_bda); - else - ret = true; - break; - } + break; } } - if (i != GATT_MAX_APPS && p_dev->gatt_if[0] == 0 && p_dev->listen_gif[0] == 0) + if (i != GATT_MAX_APPS && p_dev->gatt_if[0] == 0) { memset(p_dev, 0, sizeof(tGATT_BG_CONN_DEV)); } @@ -2623,7 +2578,6 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if) { tGATT_BG_CONN_DEV *p_dev_list = &gatt_cb.bgconn_dev[0]; uint8_t i , j, k; - tGATT_REG *p_reg = gatt_get_regcb(gatt_if); /* update the BG conn device list */ for (i = 0 ; i gatt_if[j] == 0 && p_dev_list->listen_gif[j] == 0) + if (p_dev_list->gatt_if[j] == 0) break; if (p_dev_list->gatt_if[j] == gatt_if) @@ -2643,21 +2597,6 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if) if (p_dev_list->gatt_if[0] == 0) BTM_BleUpdateBgConnDev(false, p_dev_list->remote_bda); } - - if (p_dev_list->listen_gif[j] == gatt_if) - { - p_dev_list->listen_gif[j] = 0; - - if (p_reg != NULL && p_reg->listening > 0) - p_reg->listening --; - - /* move all element behind one forward */ - for (k = j + 1; k < GATT_MAX_APPS; k ++) - p_dev_list->listen_gif[k - 1] = p_dev_list->listen_gif[k]; - - if (p_dev_list->listen_gif[0] == 0) - BTM_BleUpdateAdvWhitelist(false, p_dev_list->remote_bda); - } } } } @@ -2692,7 +2631,7 @@ void gatt_reset_bgdev_list(void) ** Returns true if connection started; false if connection start failure. ** *******************************************************************************/ -bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_addr, bool is_initator) +bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_addr) { bool ret = false; tGATT_REG *p_reg; @@ -2708,7 +2647,7 @@ bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_ if (add) { - ret = gatt_add_bg_dev_list(p_reg, bd_addr, is_initator); + ret = gatt_add_bg_dev_list(p_reg, bd_addr); if (ret && p_tcb != NULL) { @@ -2718,7 +2657,7 @@ bool gatt_update_auto_connect_dev (tGATT_IF gatt_if, bool add, BD_ADDR bd_ } else { - ret = gatt_remove_bg_dev_from_list(p_reg, bd_addr, is_initator); + ret = gatt_remove_bg_dev_from_list(p_reg, bd_addr); } return ret; } @@ -2756,47 +2695,23 @@ tGATT_PENDING_ENC_CLCB* gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGAT ** Returns Pointer to the new service start buffer, NULL no buffer available ** *******************************************************************************/ -bool gatt_update_listen_mode(void) +void gatt_update_listen_mode(int listening) { - uint8_t ii = 0; - tGATT_REG *p_reg = &gatt_cb.cl_rcb[0]; - uint8_t listening = 0; uint16_t connectability, window, interval; - bool rt = true; - for (; ii < GATT_MAX_APPS; ii ++, p_reg ++) + connectability = BTM_ReadConnectability(&window, &interval); + + if (listening != GATT_LISTEN_TO_NONE) { - if ( p_reg->in_use && p_reg->listening > listening) - { - listening = p_reg->listening; - } + connectability |= BTM_BLE_CONNECTABLE; } - - if (listening == GATT_LISTEN_TO_ALL || - listening == GATT_LISTEN_TO_NONE) - BTM_BleUpdateAdvFilterPolicy (AP_SCAN_CONN_ALL); else - BTM_BleUpdateAdvFilterPolicy (AP_SCAN_CONN_WL); - - if (rt) { - connectability = BTM_ReadConnectability (&window, &interval); - - if (listening != GATT_LISTEN_TO_NONE) - { - connectability |= BTM_BLE_CONNECTABLE; - } - else - { - if ((connectability & BTM_BLE_CONNECTABLE) == 0) - connectability &= ~BTM_BLE_CONNECTABLE; - } - /* turning on the adv now */ - btm_ble_set_connectability(connectability); + if ((connectability & BTM_BLE_CONNECTABLE) == 0) + connectability &= ~BTM_BLE_CONNECTABLE; } - - return rt; - + /* turning on the adv now */ + btm_ble_set_connectability(connectability); } #endif diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h index af9349ff4..5400b1c4b 100644 --- a/stack/include/btm_ble_api.h +++ b/stack/include/btm_ble_api.h @@ -746,17 +746,6 @@ extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, /******************************************************************************* ** -** Function BTM_BleUpdateAdvWhitelist -** -** Description Add or remove device from advertising white list -** -** Returns void -** -*******************************************************************************/ -extern bool BTM_BleUpdateAdvWhitelist(bool add_remove, BD_ADDR emote_bda); - -/******************************************************************************* -** ** Function BTM_BleUpdateAdvFilterPolicy ** ** Description This function update the filter policy of advertiser. diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h index 4ec8bf6de..d8d159ccd 100644 --- a/stack/include/gatt_api.h +++ b/stack/include/gatt_api.h @@ -1080,15 +1080,11 @@ extern bool GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, ** Description This function start or stop LE advertisement and listen for ** connection. ** -** Parameters gatt_if: applicaiton interface -** p_bd_addr: listen for specific address connection, or NULL for -** listen to all device connection. -** start: is a direct conenection or a background auto connection +** Parameters start: is a direct conenection or a background auto connection ** -** Returns true if advertisement is started; false if adv start failure. ** *******************************************************************************/ -extern bool GATT_Listen (tGATT_IF gatt_if, bool start, BD_ADDR_PTR bd_addr); +extern void GATT_Listen(bool start); /******************************************************************************* ** -- 2.11.0