diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 04a95edfa2..8a6538bf0b 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -1647,6 +1647,8 @@ extern void BTA_DmBleAdvStop (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_s #endif // #if (BLE_42_ADV_EN == TRUE) #endif + +#if (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** ** Function BTA_DmBleSetBgConnType @@ -1677,6 +1679,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_ } #endif } +#endif// (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 9f031fe522..6d86d41be3 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -137,7 +137,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */ bta_dm_security_grant, /* BTA_DM_API_BLE_SEC_GRANT_EVT */ #endif ///SMP_INCLUDED == TRUE - bta_dm_ble_set_bg_conn_type, +#if (BLE_GATT_BGCONN == TRUE) + bta_dm_ble_set_bg_conn_type, /* BTA_DM_API_BLE_SET_BG_CONN_TYPE */ +#endif // (BLE_GATT_BGCONN == TRUE) bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */ #if (BLE_42_SCAN_EN == TRUE) bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */ diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 639e758802..d03825a5d6 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -123,7 +123,9 @@ enum { BTA_DM_API_BLE_CONFIRM_REPLY_EVT, BTA_DM_API_BLE_SEC_GRANT_EVT, #endif ///SMP_INCLUDED == TRUE +#if (BLE_GATT_BGCONN == TRUE) BTA_DM_API_BLE_SET_BG_CONN_TYPE, +#endif // (BLE_GATT_BGCONN == TRUE) BTA_DM_API_BLE_CONN_PARAM_EVT, /*******This event added by Yulong at 2016/10/25 to support the scan filter setting for the APP******/ diff --git a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c index ae150a3c94..9bb7801a41 100644 --- a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c @@ -2605,8 +2605,9 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond) BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 0, NULL, NULL); p_cb->in_bg_conn = TRUE; - +#if (BLE_GATT_BGCONN == TRUE) BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL); +#endif // (BLE_GATT_BGCONN == TRUE) } return; } diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index c82179aa92..18cb93c125 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -39,10 +39,11 @@ #endif #if (BLE_INCLUDED == TRUE) - static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state); static void btm_wl_update_to_controller(void); +#if (BLE_GATT_BGCONN == TRUE) + // Unfortunately (for now?) we have to maintain a copy of the device whitelist // on the host to determine if a device is pending to be connected or not. This // controls whether the host should keep trying to scan for whitelisted @@ -118,6 +119,7 @@ static bool background_connections_pending(void) } return pending_connections; } +#endif // (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** @@ -335,6 +337,7 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_ return FALSE; } +#if (BLE_GATT_BGCONN == TRUE) if (to_add) { /* added the bd_addr to the connection hash map queue */ if(!background_connection_add((bt_bdaddr_t *)bd_addr)) { @@ -354,6 +357,7 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_ return TRUE; } } +#endif // (BLE_GATT_BGCONN == TRUE) if (update_wl_cb){ //save add whitelist complete callback @@ -381,7 +385,10 @@ void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb) BTM_TRACE_EVENT ("btm_ble_clear_white_list"); btsnd_hcic_ble_clear_white_list(); + +#if (BLE_GATT_BGCONN == TRUE) background_connections_clear(); +#endif // (BLE_GATT_BGCONN == TRUE) if (update_wl_cb) { p_cb->update_wl_cb = update_wl_cb; @@ -488,6 +495,7 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len) } } +#if (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** ** Function btm_ble_start_auto_conn @@ -660,6 +668,8 @@ void btm_ble_initiate_select_conn(BD_ADDR bda) BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed"); } } +#endif // (BLE_GATT_BGCONN == TRUE) + #if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** @@ -698,12 +708,15 @@ BOOLEAN btm_ble_suspend_bg_conn(void) *******************************************************************************/ static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state) { +#if (BLE_GATT_BGCONN == TRUE) if (wl_state & BTM_BLE_WL_INIT) { btm_ble_start_auto_conn(FALSE); } if (wl_state & BTM_BLE_WL_SCAN) { btm_ble_start_select_conn(FALSE, NULL); } +#endif // (BLE_GATT_BGCONN == TRUE) + #if (BLE_42_ADV_EN == TRUE) if (wl_state & BTM_BLE_WL_ADV) { btm_ble_stop_adv(); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 6667a9d96f..f8699d6b0a 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -956,6 +956,7 @@ BOOLEAN BTM_BleLocalPrivacyEnabled(void) #endif } +#if (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** ** Function BTM_BleSetBgConnType @@ -1014,6 +1015,7 @@ BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE bg_conn_type, } return started; } +#endif // (BLE_GATT_BGCONN == TRUE) #if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* @@ -2987,6 +2989,7 @@ void btm_clear_all_pending_le_entry(void) } } +#if (BLE_GATT_BGCONN == TRUE) /******************************************************************************* ** ** Function btm_send_sel_conn_callback @@ -3030,6 +3033,7 @@ void btm_send_sel_conn_callback(BD_ADDR remote_bda, UINT8 evt_type, UINT8 *p_dat btm_ble_initiate_select_conn(remote_bda); } } +#endif // #if (BLE_GATT_BGCONN == TRUE) #if (BLE_42_SCAN_EN == TRUE) static void btm_adv_pkt_handler(void *arg) @@ -3187,10 +3191,13 @@ static void btm_ble_process_last_adv_pkt(void) __func__); return; } +#if (BLE_GATT_BGCONN == TRUE) /* background connection in selective connection mode */ if (btm_cb.ble_ctr_cb.bg_conn_type == BTM_BLE_CONN_SELECTIVE) { //do nothing - } else { + } else +#endif // (BLE_GATT_BGCONN == TRUE) + { if (p_scan_results_cb && (result & BTM_BLE_DISCO_RESULT)) { (p_scan_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache); p_le_inq_cb->adv_len = 0; @@ -3298,6 +3305,7 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); } } +#if (BLE_GATT_BGCONN == TRUE) /* background connection in selective connection mode */ if (btm_cb.ble_ctr_cb.bg_conn_type == BTM_BLE_CONN_SELECTIVE) { if (result & BTM_BLE_SEL_CONN_RESULT) { @@ -3305,7 +3313,9 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt } else { BTM_TRACE_DEBUG("None LE device, can not initiate selective connection\n"); } - } else { + } else +#endif // (BLE_GATT_BGCONN == TRUE) + { if (p_scan_results_cb && (result & BTM_BLE_DISCO_RESULT)) { (p_scan_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache); p_le_inq_cb->adv_len = 0; diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index d32030a84e..54459b4d6b 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -174,8 +174,10 @@ static void reset_complete(void) #if (BLE_INCLUDED == TRUE) btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE; +#if (BLE_GATT_BGCONN == TRUE) btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE; btm_cb.ble_ctr_cb.p_select_cback = NULL; +#endif // (BLE_GATT_BGCONN == TRUE) #if (GATT_BG_CONN_DEV == TRUE) gatt_reset_bgdev_list(); #endif // #if (GATT_BG_CONN_DEV == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index cb0ff2a5b1..9be480869c 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -343,11 +343,15 @@ typedef struct { struct pkt_queue *adv_rpt_queue; struct osi_event *adv_rpt_ready; #endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_GATT_BGCONN == TRUE) /* background connection procedure cb value */ tBTM_BLE_CONN_TYPE bg_conn_type; +#endif // (BLE_GATT_BGCONN == TRUE) UINT32 scan_int; UINT32 scan_win; +#if (BLE_GATT_BGCONN == TRUE) tBTM_BLE_SEL_CBACK *p_select_cback; +#endif // (BLE_GATT_BGCONN == TRUE) /* white list information */ UINT8 white_list_avail_size; #if (BLE_50_EXTEND_SYNC_EN == TRUE)