From e249971122669c5211a41227bfe74693b85711e7 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 26 Feb 2024 14:29:37 +0800 Subject: [PATCH 1/8] fix(bt): Update bt lib for ESP32(2de69f3) - Fixed HCI command status event send when LLCP busy --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index e42401b2e3..7ce7597737 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit e42401b2e3535811f2076c5188813273d2fa976d +Subproject commit 7ce7597737b06f8b6221be787af92d12c387b1f8 From 4734fb00442d31d22c838d02425fdef04fbac8f1 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Wed, 28 Feb 2024 11:06:22 +0800 Subject: [PATCH 2/8] fix(bt/controller): Fixed 3 esp32 bt controller bugs update esp32 bt-lib (952debf4) 1. Increased the length of queue for coexist requestions 2. fix(bt/controller): Cleared BT SNIFF when no connections exists 3. fix(bt/controller): Corrected a typo in coex module --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index 7ce7597737..f0d70ab669 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 7ce7597737b06f8b6221be787af92d12c387b1f8 +Subproject commit f0d70ab66948f40bd5a54763493c494148564b37 From 17e3c696948c6ad5d7a50abc8bab594a068e9273 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Thu, 29 Feb 2024 17:43:14 +0800 Subject: [PATCH 3/8] fix(bt): Update bt lib for ESP32(5ea2fca) - Fixed HCI command status event sending for disconnect command - Fixed LE transmitter test command param check --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index f0d70ab669..6a59711e59 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit f0d70ab66948f40bd5a54763493c494148564b37 +Subproject commit 6a59711e5968782969accd8154b0e35023e4ee36 From 8ada7f868bb3108393f4ec898baaf45c2416c8ae Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Tue, 30 Jan 2024 15:37:41 +0800 Subject: [PATCH 4/8] fix(bt/bluedroid): Fixed crash when calculating GATTS database hash --- components/bt/host/bluedroid/stack/btu/btu_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btu/btu_init.c b/components/bt/host/bluedroid/stack/btu/btu_init.c index 615fbf8019..9ede9c2da9 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_init.c +++ b/components/bt/host/bluedroid/stack/btu/btu_init.c @@ -98,11 +98,11 @@ void btu_init_core(void) #endif #if BLE_INCLUDED == TRUE -#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true) - gatt_init(); -#endif #if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE) SMP_Init(); +#endif +#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true) + gatt_init(); #endif btm_ble_init(); #endif From 6ca03fc6005211b34d539f21bd4d130d874b49a0 Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 19 Aug 2022 13:52:02 +0800 Subject: [PATCH 5/8] fix(bt/blufi): Fixed BluFi module link error(C++ hybrid compilation) --- .../btc/profile/esp/blufi/include/blufi_int.h | 32 ++++++++++--------- .../btc/profile/esp/blufi/include/esp_blufi.h | 13 ++++++++ .../btc/profile/esp/include/btc_blufi_prf.h | 26 +++++++-------- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h b/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h index be2c72c78d..e85ad73d86 100644 --- a/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h +++ b/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h @@ -1,22 +1,19 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __BLUFI_INT_H__ #define __BLUFI_INT_H__ #include "btc/btc_task.h" #include "esp_blufi_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + #if (BLUFI_INCLUDED == TRUE) #define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion @@ -201,5 +198,10 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_blufi_cb_deep_free(btc_msg_t *msg); -#endif /* __BLUFI_INT_H__ */ -#endif ///BLUFI_INCLUDED == TRUE +#endif ///BLUFI_INCLUDED == TRUE + +#ifdef __cplusplus +} +#endif + +#endif /* __BLUFI_INT_H__ */ diff --git a/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h b/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h index 060a364d21..608b188db4 100644 --- a/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h +++ b/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h @@ -1,3 +1,9 @@ +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + #ifndef __ESP_BLUFI_H__ #define __ESP_BLUFI_H__ @@ -13,6 +19,10 @@ #include "esp_gap_ble_api.h" #endif +#ifdef __cplusplus +extern "C" { +#endif + #define BLUFI_APP_UUID 0xFFFF #define BLUFI_DEVICE_NAME "BLUFI_DEVICE" @@ -74,4 +84,7 @@ void esp_blufi_adv_start(void); void esp_blufi_send_encap(void *arg); +#ifdef __cplusplus +} +#endif #endif/* _ESP_BLUFI_ */ diff --git a/components/bt/common/btc/profile/esp/include/btc_blufi_prf.h b/components/bt/common/btc/profile/esp/include/btc_blufi_prf.h index 31bbc380d6..1174f01ee0 100644 --- a/components/bt/common/btc/profile/esp/include/btc_blufi_prf.h +++ b/components/bt/common/btc/profile/esp/include/btc_blufi_prf.h @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __BTC_BLUFI_PRF_H__ #define __BTC_BLUFI_PRF_H__ @@ -29,6 +21,11 @@ #define ESP_BLUFI_SUCCESS 0x00 #endif + +#ifdef __cplusplus +extern "C" { +#endif + #define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" #define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] @@ -108,4 +105,7 @@ void btc_blufi_call_deep_free(btc_msg_t *msg); uint16_t btc_blufi_get_version(void); +#ifdef __cplusplus +} +#endif #endif /* __BTC_BLUFI_PRF_H__ */ From c6f12bdf29cc2e610915de5fb56bda3f5680fea9 Mon Sep 17 00:00:00 2001 From: Raghu Saxena Date: Mon, 17 Apr 2023 17:18:36 +0800 Subject: [PATCH 6/8] fix(bt/example): Use correct struct type --- examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c index d1d03a80d4..918c0ccfb9 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c @@ -132,7 +132,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ break; } ESP_LOGI(GATTC_TAG, "discover service complete conn_id %d", param->dis_srvc_cmpl.conn_id); - esp_ble_gattc_search_service(gattc_if, param->cfg_mtu.conn_id, &remote_filter_service_uuid); + esp_ble_gattc_search_service(gattc_if, param->dis_srvc_cmpl.conn_id, &remote_filter_service_uuid); break; case ESP_GATTC_CFG_MTU_EVT: if (param->cfg_mtu.status != ESP_GATT_OK){ From a2cc7980e4d396a3c8d731f45485e73770f50746 Mon Sep 17 00:00:00 2001 From: thekurtovic <40248206+thekurtovic@users.noreply.github.com> Date: Sat, 6 May 2023 16:11:49 -0400 Subject: [PATCH 7/8] fix(bt/bluedroid): Fixed "reprot" typo in esp_ble_gap_ext_adv_reprot_t --- .../bt/host/bluedroid/api/include/api/esp_gap_ble_api.h | 4 ++-- .../bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 0c06c5e827..06c72514d1 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -896,7 +896,7 @@ typedef struct { esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */ uint8_t adv_data_len; /*!< extend advertising data length */ uint8_t adv_data[251]; /*!< extend advertising data */ -} esp_ble_gap_ext_adv_reprot_t; +} esp_ble_gap_ext_adv_report_t; /** * @brief periodic adv report parameters @@ -1340,7 +1340,7 @@ typedef union { * @brief ESP_GAP_BLE_EXT_ADV_REPORT_EVT */ struct ble_ext_adv_report_param { - esp_ble_gap_ext_adv_reprot_t params; /*!< extend advertising report parameters */ + esp_ble_gap_ext_adv_report_t params; /*!< extend advertising report parameters */ } ext_adv_report; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_REPORT_EVT */ /** * @brief ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 62c96480de..23e3d1fe01 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1060,7 +1060,7 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, break; case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT: msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT; - memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_reprot_t)); + memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_report_t)); if (params->ext_adv_report.adv_data) { memcpy(param.ext_adv_report.params.adv_data, params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len); From 285bffbffdcf1eeab6e525b4123f6ea5b31415f7 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Mon, 26 Feb 2024 15:57:20 +0800 Subject: [PATCH 8/8] feat(bt/bluedroid): Add ext adv and privacy status check --- .../bt/host/bluedroid/btc/core/btc_main.c | 24 ++++++++++++++--- .../host/bluedroid/btc/include/btc/btc_main.h | 4 ++- .../bt/host/bluedroid/stack/btm/btm_ble.c | 27 +++++++++++++++++++ .../host/bluedroid/stack/btm/btm_ble_5_gap.c | 18 +++++++++++++ .../bt/host/bluedroid/stack/btm/btm_main.c | 17 ------------ 5 files changed, 68 insertions(+), 22 deletions(-) diff --git a/components/bt/host/bluedroid/btc/core/btc_main.c b/components/bt/host/bluedroid/btc/core/btc_main.c index 0b9b016de2..28f70b4b6a 100644 --- a/components/bt/host/bluedroid/btc/core/btc_main.c +++ b/components/bt/host/bluedroid/btc/core/btc_main.c @@ -141,18 +141,34 @@ uint32_t btc_get_ble_status(void) } #if (SMP_INCLUDED == TRUE) + // Number of recorded devices + extern uint8_t btm_ble_sec_dev_active_count(void); + if (btm_ble_sec_dev_active_count()) { + status |= BIT(BTC_BLE_STATUS_KEYS); + } + // Number of saved bonded devices if (btc_storage_get_num_ble_bond_devices()) { status |= BIT(BTC_BLE_STATUS_BOND); } #endif + + #if (BLE_PRIVACY_SPT == TRUE) + // Privacy enabled + extern uint8_t btm_ble_privacy_is_enabled(void); + if (btm_ble_privacy_is_enabled()) { + status |= BIT(BTC_BLE_STATUS_PRIVACY); + } + #endif #endif - // Number of recorded devices - extern uint8_t btdm_sec_dev_active_count(void); - if (btdm_sec_dev_active_count()) { - status |= BIT(BTC_BLE_STATUS_DEV); + #if (BLE_50_FEATURE_SUPPORT == TRUE) + // Number of active extended advertsing + extern uint8_t btm_ble_ext_adv_active_count(void); + if (btm_ble_ext_adv_active_count()) { + status |= BIT(BTC_BLE_STATUS_EXT_ADV); } + #endif // Number of active ACL connection extern uint8_t btm_acl_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 935dc77e10..df20a63878 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_main.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_main.h @@ -31,13 +31,15 @@ typedef enum { #define BTC_BLE_STATUS_IDLE 0 typedef enum { BTC_BLE_STATUS_ADV = 0, // Advertising exist + BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist BTC_BLE_STATUS_SCAN, // Scanning exist BTC_BLE_STATUS_CONN, // Connection exist - BTC_BLE_STATUS_DEV, // Device record exist + BTC_BLE_STATUS_KEYS, // Device keys record exist BTC_BLE_STATUS_BOND, // Bond info exist BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist BTC_BLE_STATUS_GATTC_APP, // GATTC application exist BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist + BTC_BLE_STATUS_PRIVACY, // Privacy enabled } 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_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 54a7d086ec..a76ec43563 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -2931,4 +2931,31 @@ uint8_t btm_ble_scan_active_count(void) return count; } +#if (SMP_INCLUDED == TRUE) +uint8_t btm_ble_sec_dev_active_count(void) +{ + tBTM_SEC_DEV_REC *p_dev_rec = NULL; + list_node_t *p_node = NULL; + uint8_t count = 0; + + /* First look for the non-paired devices for the oldest entry */ + for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) { + p_dev_rec = list_node(p_node); + if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE) && (p_dev_rec->ble.key_type != BTM_LE_KEY_NONE)) { + count++; + } + } + + return count; +} +#endif + +#if (BLE_PRIVACY_SPT == TRUE) +uint8_t btm_ble_privacy_is_enabled(void) +{ + tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; + return (p_cb->privacy_mode != BTM_PRIVACY_NONE); +} +#endif + #endif /* BLE_INCLUDED */ diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 9cec610150..dd45e19329 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -34,6 +34,7 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len, typedef struct { uint16_t ter_con_handle; bool invalid; + bool enabled; UINT8 instance; int duration; int max_events; @@ -545,6 +546,7 @@ end: for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) { adv_record[i].invalid = false; + adv_record[i].enabled = false; adv_record[i].instance = INVALID_VALUE; adv_record[i].duration = INVALID_VALUE; adv_record[i].max_events = INVALID_VALUE; @@ -555,6 +557,7 @@ end: { uint8_t index = ext_adv[i].instance; adv_record[index].invalid = false; + adv_record[index].enabled = false; adv_record[index].instance = INVALID_VALUE; adv_record[index].duration = INVALID_VALUE; adv_record[index].max_events = INVALID_VALUE; @@ -568,6 +571,7 @@ end: { uint8_t index = ext_adv[i].instance; adv_record[index].invalid = true; + adv_record[index].enabled = true; adv_record[index].instance = ext_adv[i].instance; adv_record[index].duration = ext_adv[i].duration; adv_record[index].max_events = ext_adv[i].max_events; @@ -1183,6 +1187,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params) adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE; adv_record[params->adv_handle].invalid = false; } + adv_record[params->adv_handle].enabled = false; memcpy(&cb_params.adv_term, params, sizeof(tBTM_BLE_ADV_TERMINAT)); @@ -1298,6 +1303,19 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par } +uint8_t btm_ble_ext_adv_active_count(void) +{ + uint8_t count = 0; + + for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) { + if (adv_record[i].enabled == true) { + count++; + } + } + + return count; +} + #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index 05ef1837fa..8e49aa3e6d 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -133,20 +133,3 @@ uint8_t btm_acl_active_count(void) return count; } - -uint8_t btdm_sec_dev_active_count(void) -{ - tBTM_SEC_DEV_REC *p_dev_rec = NULL; - list_node_t *p_node = NULL; - uint8_t count = 0; - - /* First look for the non-paired devices for the oldest entry */ - for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) { - p_dev_rec = list_node(p_node); - if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE)) { - count++; - } - } - - return count; -}