From d6a0fa813d3c11fc6faffe9c3d8e7fe63d976a7b Mon Sep 17 00:00:00 2001 From: Zhang Hai Peng Date: Wed, 25 Sep 2024 12:13:13 +0800 Subject: [PATCH 1/5] feat(ble/bluedroid): Support resolve BLE address for interval usage (cherry picked from commit b88b511362e4fa8da70d59df04bbc172a52c9e59) Co-authored-by: zhanghaipeng --- components/bt/host/bluedroid/btc/core/btc_main.c | 6 ++++++ components/bt/host/bluedroid/btc/include/btc/btc_main.h | 1 + components/bt/host/bluedroid/stack/btm/btm_main.c | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/btc/core/btc_main.c b/components/bt/host/bluedroid/btc/core/btc_main.c index c1c694b8a2..b170315b46 100644 --- a/components/bt/host/bluedroid/btc/core/btc_main.c +++ b/components/bt/host/bluedroid/btc/core/btc_main.c @@ -141,6 +141,12 @@ uint32_t btc_get_ble_status(void) status |= BIT(BTC_BLE_STATUS_CONN); } + // Address resolve status + extern uint8_t btm_get_ble_addr_resolve_status(void); + if (btm_get_ble_addr_resolve_status()) { + status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE); + } + #if (SMP_INCLUDED == TRUE) // Number of recorded devices extern uint8_t btm_ble_sec_dev_active_count(void); diff --git a/components/bt/host/bluedroid/btc/include/btc/btc_main.h b/components/bt/host/bluedroid/btc/include/btc/btc_main.h index df20a63878..66495a090c 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_main.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_main.h @@ -40,6 +40,7 @@ typedef enum { BTC_BLE_STATUS_GATTC_APP, // GATTC application exist BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist BTC_BLE_STATUS_PRIVACY, // Privacy enabled + BTC_BLE_STATUS_ADDR_RESOLVE,// Address resolution status } tBTC_BLE_STATUS; future_t **btc_main_get_future_p(btc_main_future_type_t type); diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index c7b5b8b6c0..ba7f041d99 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -134,10 +134,15 @@ uint8_t btm_acl_active_count(void) return count; } +#if (BLE_INCLUDED == TRUE) +// address resolution status +uint8_t btm_get_ble_addr_resolve_status(void) +{ + return (uint8_t) btm_cb.addr_res_en; +} void btm_ble_addr_resolve_enable(bool enable) { -#if (BLE_INCLUDED == TRUE) btm_cb.addr_res_en = enable; -#endif } +#endif /*BLE_INCLUDED*/ From ab0d3831db31b9744074a2fe883d3a8335c30bf1 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Thu, 26 Sep 2024 19:49:40 +0800 Subject: [PATCH 2/5] feat(ble/bluedroid): Optimize address resolution status for interval use --- components/bt/host/bluedroid/btc/core/btc_main.c | 6 +++--- components/bt/host/bluedroid/btc/include/btc/btc_main.h | 2 +- components/bt/host/bluedroid/stack/btm/btm_main.c | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/bt/host/bluedroid/btc/core/btc_main.c b/components/bt/host/bluedroid/btc/core/btc_main.c index b170315b46..de90708e6b 100644 --- a/components/bt/host/bluedroid/btc/core/btc_main.c +++ b/components/bt/host/bluedroid/btc/core/btc_main.c @@ -142,9 +142,9 @@ uint32_t btc_get_ble_status(void) } // Address resolve status - extern uint8_t btm_get_ble_addr_resolve_status(void); - if (btm_get_ble_addr_resolve_status()) { - status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE); + extern uint8_t btm_get_ble_addr_resolve_disable_status(void); + if (btm_get_ble_addr_resolve_disable_status()) { + status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE); } #if (SMP_INCLUDED == TRUE) diff --git a/components/bt/host/bluedroid/btc/include/btc/btc_main.h b/components/bt/host/bluedroid/btc/include/btc/btc_main.h index 66495a090c..e9b6f5ba2a 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_main.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_main.h @@ -40,7 +40,7 @@ typedef enum { BTC_BLE_STATUS_GATTC_APP, // GATTC application exist BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist BTC_BLE_STATUS_PRIVACY, // Privacy enabled - BTC_BLE_STATUS_ADDR_RESOLVE,// Address resolution status + BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE,// Address resolution disable status } tBTC_BLE_STATUS; future_t **btc_main_get_future_p(btc_main_future_type_t type); diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index ba7f041d99..e9e443380c 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -135,10 +135,11 @@ uint8_t btm_acl_active_count(void) return count; } #if (BLE_INCLUDED == TRUE) -// address resolution status -uint8_t btm_get_ble_addr_resolve_status(void) +// Address resolution status +uint8_t btm_get_ble_addr_resolve_disable_status(void) { - return (uint8_t) btm_cb.addr_res_en; + // Returns false if address resolution is enabled, true if disabled + return (btm_cb.addr_res_en) ? 0 : 1; } void btm_ble_addr_resolve_enable(bool enable) From 7207816a3fa3865ce7c255608235f42b205184c3 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Tue, 7 May 2024 10:59:42 +0800 Subject: [PATCH 3/5] feat(ble/controller): Display BLE controller init status for ESP32 and ESP32C3/S3 --- components/bt/controller/esp32/bt.c | 5 ++++- components/bt/controller/esp32c3/bt.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 44afa56648..caff2bcff9 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -1690,7 +1690,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_cfg_mask = btdm_config_mask_load(); - if (btdm_controller_init(btdm_cfg_mask, cfg) != 0) { + err = btdm_controller_init(btdm_cfg_mask, cfg); + + if (err != 0) { + ESP_LOGE(BTDM_LOG_TAG, "%s %d\n",__func__,err); err = ESP_ERR_NO_MEM; goto error; } diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index ece11c2a28..030c95ebc6 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -1463,7 +1463,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) periph_module_enable(PERIPH_BT_MODULE); periph_module_reset(PERIPH_BT_MODULE); - if (btdm_controller_init(cfg) != 0) { + err = btdm_controller_init(cfg); + + if (err != 0) { + ESP_LOGE(BT_LOG_TAG, "%s %d\n",__func__,err); err = ESP_ERR_NO_MEM; goto error; } From da545604fc8ddbea4054d24d2e37350223f66e3b Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Tue, 7 May 2024 15:32:11 +0800 Subject: [PATCH 4/5] feat(ble/bluedroid): Add BLE memory allocation failure message --- components/bt/host/bluedroid/hci/packet_fragmenter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/bt/host/bluedroid/hci/packet_fragmenter.c b/components/bt/host/bluedroid/hci/packet_fragmenter.c index 78b6151e51..d8f2ff918f 100644 --- a/components/bt/host/bluedroid/hci/packet_fragmenter.c +++ b/components/bt/host/bluedroid/hci/packet_fragmenter.c @@ -171,6 +171,12 @@ static void reassemble_and_dispatch(BT_HDR *packet) return; } partial_packet = (BT_HDR *)osi_calloc(full_length + sizeof(BT_HDR)); + + if (partial_packet == NULL) { + HCI_TRACE_WARNING("%s full_length %d no memory.\n", __func__, full_length); + assert(0); + } + partial_packet->event = packet->event; partial_packet->len = full_length; partial_packet->offset = packet->len; From 74cc3eb3ba67c12729b3f0f485f6040b8b4b2767 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Tue, 7 May 2024 16:24:27 +0800 Subject: [PATCH 5/5] fix(ble/bluedroid): Fixed BLE spelling error in word --- components/bt/host/bluedroid/Kconfig.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 316c4862c4..a3457825aa 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -59,7 +59,7 @@ config BT_A2DP_ENABLE depends on BT_CLASSIC_ENABLED default n help - Advanced Audio Distrubution Profile + Advanced Audio Distribution Profile config BT_SPP_ENABLED bool "SPP" @@ -114,7 +114,7 @@ config BT_HFP_WBS_ENABLE default y help This enables Wide Band Speech. Should disable it when SCO data path is PCM. - Otherwise there will be no data transmited via GPIOs. + Otherwise there will be no data transmitted via GPIOs. menuconfig BT_HID_ENABLED @@ -1065,7 +1065,7 @@ config BT_ACL_CONNECTIONS is used. config BT_MULTI_CONNECTION_ENBALE - bool "Enable BLE multi-conections" + bool "Enable BLE multi-connections" depends on BT_BLE_ENABLED default y help