From 174e4144fdf396da874591a096a4b467b61d69f3 Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Wed, 7 Jan 2026 17:24:49 +0800 Subject: [PATCH] fix(ble/bluedroid): change tGATT_BG_CONN_DEV to GATT_BG_CONN_DEV (cherry picked from commit ac7812ef8d89feaba28014587c0fb1eac3ed991a) Co-authored-by: zhiweijian --- components/bt/host/bluedroid/bta/dm/bta_dm_act.c | 2 ++ .../bt/host/bluedroid/stack/btm/btm_ble_bgconn.c | 12 ++++++------ components/bt/host/bluedroid/stack/btm/btm_ble_gap.c | 8 ++++---- .../bt/host/bluedroid/stack/btm/btm_ble_privacy.c | 8 ++++---- components/bt/host/bluedroid/stack/btm/btm_devctl.c | 4 ++-- .../host/bluedroid/stack/btm/include/btm_ble_int.h | 4 ++-- components/bt/host/bluedroid/stack/gatt/gatt_api.c | 12 ++++++------ components/bt/host/bluedroid/stack/gatt/gatt_main.c | 12 ++++++------ components/bt/host/bluedroid/stack/gatt/gatt_utils.c | 4 ++-- .../bt/host/bluedroid/stack/gatt/include/gatt_int.h | 12 ++++++------ components/bt/host/bluedroid/stack/l2cap/l2c_ble.c | 4 ++-- 11 files changed, 42 insertions(+), 40 deletions(-) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 3690d44db1..ce98b0a987 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -599,7 +599,9 @@ void bta_dm_disable (tBTA_DM_MSG *p_data) #endif #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE +#if (GATT_BG_CONN_DEV == TRUE) BTM_BleClearBgConnDev(); +#endif // (GATT_BG_CONN_DEV == TRUE) #endif if (BTM_GetNumAclLinks() == 0) { 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 23117acae3..c82179aa92 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -660,7 +660,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda) BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed"); } } -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** ** Function btm_ble_suspend_bg_conn @@ -685,7 +685,7 @@ BOOLEAN btm_ble_suspend_bg_conn(void) return FALSE; } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** @@ -721,9 +721,9 @@ static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state) *******************************************************************************/ void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state) { -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) btm_ble_resume_bg_conn(); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) if (wl_state & BTM_BLE_WL_ADV) { #if (BLE_42_ADV_EN == TRUE) btm_ble_start_adv(); @@ -750,7 +750,7 @@ static void btm_wl_update_to_controller(void) btm_execute_wl_dev_operation(); } -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** ** Function btm_ble_resume_bg_conn @@ -780,7 +780,7 @@ BOOLEAN btm_ble_resume_bg_conn(void) return ret; } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** 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 3f93a42da3..6667a9d96f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -1015,6 +1015,7 @@ BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE bg_conn_type, return started; } +#if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** ** Function BTM_BleClearBgConnDev @@ -1032,10 +1033,9 @@ void BTM_BleClearBgConnDev(void) { btm_ble_start_auto_conn(FALSE); btm_ble_clear_white_list(NULL); -#if (tGATT_BG_CONN_DEV == TRUE) gatt_reset_bgdev_list(); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) } +#endif // #if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** @@ -3955,9 +3955,9 @@ BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 st now in order */ if (btm_ble_get_conn_st() == BLE_CONN_IDLE && status != HCI_ERR_HOST_REJECT_RESOURCES && !btm_send_pending_direct_conn()) { -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) bg_con = btm_ble_resume_bg_conn(); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) } return bg_con; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c index 0c22e965d5..633d15e253 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c @@ -718,11 +718,11 @@ BOOLEAN btm_ble_suspend_resolving_list_activity(void) btm_ble_stop_scan(); p_ble_cb->suspended_rl_state |= BTM_BLE_RL_SCAN; } -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (btm_ble_suspend_bg_conn()) { p_ble_cb->suspended_rl_state |= BTM_BLE_RL_INIT; } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) return TRUE; } @@ -750,11 +750,11 @@ void btm_ble_resume_resolving_list_activity(void) btm_ble_start_scan(); } #endif // #if (BLE_42_SCAN_EN == TRUE) -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (p_ble_cb->suspended_rl_state & BTM_BLE_RL_INIT) { btm_ble_resume_bg_conn(); } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) p_ble_cb->suspended_rl_state = BTM_BLE_RL_IDLE; } diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index 9698c439ab..d32030a84e 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -176,9 +176,9 @@ static void reset_complete(void) btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE; btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE; btm_cb.ble_ctr_cb.p_select_cback = NULL; -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) gatt_reset_bgdev_list(); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) #endif 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 8580cb3c52..cb0ff2a5b1 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 @@ -464,11 +464,11 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len); void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len); void btm_ble_white_list_init(UINT8 white_list_size); -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) /* background connection function */ BOOLEAN btm_ble_suspend_bg_conn(void); BOOLEAN btm_ble_resume_bg_conn(void); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) void btm_ble_initiate_select_conn(BD_ADDR bda); BOOLEAN btm_ble_start_auto_conn(BOOLEAN start); diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_api.c b/components/bt/host/bluedroid/stack/gatt/gatt_api.c index 621ab52cbc..a245247d56 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_api.c @@ -1391,9 +1391,9 @@ void GATT_Deregister (tGATT_IF gatt_if) } } } -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) gatt_deregister_bgdev_list(gatt_if); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) memset (p_reg, 0, sizeof(tGATT_REG)); } @@ -1469,11 +1469,11 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_ if (is_direct) { status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux, is_pawr_synced, adv_handle, subevent); } else { -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (transport == BT_TRANSPORT_LE) { status = gatt_update_auto_connect_dev(gatt_if, TRUE, bd_addr, TRUE); } else -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) { GATT_TRACE_ERROR("Unsupported transport for background connection"); } @@ -1531,7 +1531,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct status = gatt_cancel_open(gatt_if, bd_addr); } } else { -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (!gatt_if) { if (gatt_get_num_apps_for_bg_dev(bd_addr)) { while (gatt_find_app_for_bg_dev(bd_addr, &temp_gatt_if)) { @@ -1544,7 +1544,7 @@ BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct } else { status = gatt_remove_bg_dev_for_app(gatt_if, bd_addr); } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) } return status; diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_main.c b/components/bt/host/bluedroid/stack/gatt/gatt_main.c index 15ea739ee6..93eb1bb194 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_main.c @@ -935,23 +935,23 @@ static void gatt_send_conn_cback(tGATT_TCB *p_tcb) { UINT8 i; tGATT_REG *p_reg; -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) tGATT_BG_CONN_DEV *p_bg_dev = NULL; -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) UINT16 conn_id; -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) p_bg_dev = gatt_find_bg_dev(p_tcb->peer_bda); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) /* notifying all applications for the connection up event */ for (i = 0, p_reg = gatt_cb.cl_rcb ; i < GATT_MAX_APPS; i++, p_reg++) { if (p_reg->in_use) { -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (p_bg_dev && gatt_is_bg_dev_for_app(p_bg_dev, p_reg->gatt_if)) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, TRUE); } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) if (p_reg->app_cb.p_conn_cb) { conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if); (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c index 1bf819bc24..e950b67932 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c @@ -2424,7 +2424,7 @@ void gatt_dbg_display_uuid(tBT_UUID bt_uuid) } -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) /******************************************************************************* ** ** Function gatt_is_bg_dev_for_app @@ -2805,7 +2805,7 @@ BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_ } return ret; } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) #if (SMP_INCLUDED == TRUE) /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h index 4fd74fba0e..b1337d5cfd 100644 --- a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h @@ -489,14 +489,14 @@ typedef struct { UINT32 service_change; } tGATT_SVC_CHG; -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) typedef struct { tGATT_IF gatt_if[GATT_MAX_APPS]; tGATT_IF listen_gif[GATT_MAX_APPS]; BD_ADDR remote_bda; BOOLEAN in_use; } tGATT_BG_CONN_DEV; -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) #define GATT_SVC_CHANGED_CONNECTING 1 /* wait for connection */ #define GATT_SVC_CHANGED_SERVICE 2 /* GATT service discovery */ @@ -565,9 +565,9 @@ typedef struct { #if (GATTS_INCLUDED == TRUE) tGATT_HDL_CFG hdl_cfg; #endif // (GATTS_INCLUDED == TRUE) -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) tGATT_BG_CONN_DEV bgconn_dev[GATT_MAX_BG_CONN_DEV]; -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) #if (GATTC_INCLUDED == TRUE) BOOLEAN auto_disc; /* internal use: true for auto discovering after connected */ #endif // (GATTC_INCLUDED == TRUE) @@ -682,7 +682,7 @@ extern BOOLEAN gatt_add_an_item_to_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_L extern BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIST_ELEM *p_remove); extern tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg); -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) /* for background connection */ extern BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_addr, BOOLEAN is_initiator); extern BOOLEAN gatt_is_bg_dev_for_app(tGATT_BG_CONN_DEV *p_dev, tGATT_IF gatt_if); @@ -692,7 +692,7 @@ extern BOOLEAN gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if); extern tGATT_BG_CONN_DEV *gatt_find_bg_dev(BD_ADDR remote_bda); extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if); extern void gatt_reset_bgdev_list(void); -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) /* server function */ extern UINT8 gatt_sr_find_i_rcb_by_handle(UINT16 handle); diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index d21ce831cc..24bae6dbbc 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -1104,11 +1104,11 @@ BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb) L2CAP_TRACE_WARNING ("L2CAP - LE - cannot start new connection at conn st: %d", conn_st); btm_ble_enqueue_direct_conn_req(p_lcb); -#if (tGATT_BG_CONN_DEV == TRUE) +#if (GATT_BG_CONN_DEV == TRUE) if (conn_st == BLE_BG_CONN) { btm_ble_suspend_bg_conn(); } -#endif // #if (tGATT_BG_CONN_DEV == TRUE) +#endif // #if (GATT_BG_CONN_DEV == TRUE) rt = TRUE; } return rt;