From b83647f5ea1034b943fd542622dc80363130418a Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Wed, 18 Mar 2026 16:33:22 +0800 Subject: [PATCH] fix(ble/bluedroid): Align config, controller indent and init error paths - bt_target: remove/align obsolete macros with Kconfig - device/controller: fix start_up() Secure Connections indent, get_ble_resolving_list_max_size return type - controller.h: align type/interface declarations with implementation - bte_init: remove unused/redundant code - bte_main: return -1 on osi_init failure, null check in bte_main_hci_send --- .../bluedroid/common/include/common/bt_target.h | 4 ---- components/bt/host/bluedroid/device/controller.c | 14 +++++++------- .../bluedroid/device/include/device/controller.h | 2 +- components/bt/host/bluedroid/main/bte_init.c | 13 ------------- components/bt/host/bluedroid/main/bte_main.c | 10 +++++++++- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index ac08c379ca..2fb47513c9 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -681,10 +681,6 @@ #define BTA_DM_QOS_INCLUDED FALSE #endif -#ifndef BTA_PAN_INCLUDED -#define BTA_PAN_INCLUDED FALSE -#endif - #ifndef BTA_HD_INCLUDED #define BTA_HD_INCLUDED FALSE #endif diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index d471c8be9e..0aa677fc55 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -223,13 +223,13 @@ static void start_up(void) } #endif -if ((bluedroid_config_get()->get_sc_enabled())) { - controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array); - if (controller_param.secure_connections_supported) { - response = AWAIT_COMMAND(controller_param.packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED)); - controller_param.packet_parser->parse_generic_command_complete(response); + if ((bluedroid_config_get()->get_sc_enabled())) { + controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array); + if (controller_param.secure_connections_supported) { + response = AWAIT_COMMAND(controller_param.packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED)); + controller_param.packet_parser->parse_generic_command_complete(response); + } } -} #if (BLE_INCLUDED == TRUE) #if (CLASSIC_BT_INCLUDED) @@ -546,7 +546,7 @@ static uint8_t get_ble_resolving_list_max_size(void) return controller_param.ble_resolving_list_max_size; } -static void set_ble_resolving_list_max_size(int resolving_list_max_size) +static void set_ble_resolving_list_max_size(uint8_t resolving_list_max_size) { assert(controller_param.readable); assert(controller_param.ble_supported); diff --git a/components/bt/host/bluedroid/device/include/device/controller.h b/components/bt/host/bluedroid/device/include/device/controller.h index 6345d7a9c9..610c9afafc 100644 --- a/components/bt/host/bluedroid/device/include/device/controller.h +++ b/components/bt/host/bluedroid/device/include/device/controller.h @@ -78,7 +78,7 @@ typedef struct controller_t { uint8_t (*get_ble_white_list_size)(void); uint8_t (*get_ble_resolving_list_max_size)(void); - void (*set_ble_resolving_list_max_size)(int resolving_list_max_size); + void (*set_ble_resolving_list_max_size)(uint8_t resolving_list_max_size); #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE) diff --git a/components/bt/host/bluedroid/main/bte_init.c b/components/bt/host/bluedroid/main/bte_init.c index c19b50b6aa..b688d7a27d 100644 --- a/components/bt/host/bluedroid/main/bte_init.c +++ b/components/bt/host/bluedroid/main/bte_init.c @@ -152,10 +152,6 @@ #include "bta_gatts_int.h" #endif -#if BTA_PAN_INCLUDED==TRUE -#include "bta_pan_int.h" -#endif - #if BTA_PBA_CLIENT_INCLUDED == TRUE #include "bta_pba_client_int.h" #endif @@ -481,9 +477,6 @@ bt_status_t BTE_InitStack(void) } memset((void *)bta_jv_cb_ptr, 0, sizeof(tBTA_JV_CB)); #endif //JV -#if BTA_HS_INCLUDED == TRUE - memset((void *)bta_hs_cb_ptr, 0, sizeof(tBTA_HS_CB)); -#endif #if BTA_SDP_INCLUDED == TRUE if ((bta_sdp_cb_ptr = (tBTA_SDP_CB *)osi_malloc(sizeof(tBTA_SDP_CB))) == NULL) { goto error_exit; @@ -525,9 +518,6 @@ bt_status_t BTE_InitStack(void) } memset((void *)bta_hd_cb_ptr, 0, sizeof(tBTA_HD_CB)); #endif -#if BTA_HL_INCLUDED==TRUE - memset((void *)bta_hl_cb_ptr, 0, sizeof(tBTA_HL_CB)); -#endif #if GATTC_INCLUDED==TRUE if ((bta_gattc_cb_ptr = (tBTA_GATTC_CB *)osi_malloc(sizeof(tBTA_GATTC_CB))) == NULL) { goto error_exit; @@ -540,9 +530,6 @@ bt_status_t BTE_InitStack(void) } memset((void *)bta_gatts_cb_ptr, 0, sizeof(tBTA_GATTS_CB)); #endif -#if BTA_PAN_INCLUDED==TRUE - memset((void *)bta_pan_cb_ptr, 0, sizeof(tBTA_PAN_CB)); -#endif #if BTA_PBA_CLIENT_INCLUDED == TRUE if ((bta_pba_client_cb_ptr = (tBTA_PBA_CLIENT_CB *)osi_malloc(sizeof(tBTA_PBA_CLIENT_CB))) == NULL) { goto error_exit; diff --git a/components/bt/host/bluedroid/main/bte_main.c b/components/bt/host/bluedroid/main/bte_main.c index 73cbafc644..d50544ced4 100644 --- a/components/bt/host/bluedroid/main/bte_main.c +++ b/components/bt/host/bluedroid/main/bte_main.c @@ -86,7 +86,10 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb) bluedroid_init_done_cb = cb; - osi_init(); + if (osi_init() != 0) { + APPL_TRACE_ERROR("%s failed to initialize OS layer.\n", __func__); + return -1; + } //Enable HCI bte_main_enable(); @@ -235,6 +238,11 @@ void bte_main_lpm_wake_bt_device(void) ******************************************************************************/ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event) { + if (!p_msg) { + APPL_TRACE_ERROR("%s null message\n", __func__); + return; + } + UINT16 sub_event = event & BT_SUB_EVT_MASK; /* local controller ID */ p_msg->event = event;