From 31d8a68a0bb7f893a9e30a0cfa6c26dd5dbf485b Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Mon, 21 Apr 2025 17:03:25 +0800 Subject: [PATCH 1/2] fix(ble/bluedroid): Fixed BLE_FEAT_CREATE_SYNC_ENH define error in bluedroid host (cherry picked from commit cf6135c990d8e810497729f81aa2b5161fbb8ba2) Co-authored-by: zhiweijian --- .../bt/host/bluedroid/api/include/api/esp_gap_ble_api.h | 4 ++-- components/bt/host/bluedroid/bta/include/bta/bta_api.h | 4 ++-- .../bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 4 ++-- components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c | 8 ++++---- .../bt/host/bluedroid/stack/include/stack/btm_ble_api.h | 4 ++-- .../tutorial/Periodic_Sync_Example_Walkthrough.md | 4 ++-- 6 files changed, 14 insertions(+), 14 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 d29deda3dd..36bd8f8cf7 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 @@ -982,14 +982,14 @@ typedef struct { esp_ble_gap_sync_t filter_policy; /*!< Configures the filter policy for periodic advertising sync: 0: Use Advertising SID, Advertiser Address Type, and Advertiser Address parameters to determine the advertiser to listen to. 1: Use the Periodic Advertiser List to determine the advertiser to listen to. */ - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) esp_ble_gap_sync_t reports_disabled; /*!< Supported only by esp32c2, esp32c6, and esp32h2; can be set by menuconfig: 0: Reporting initially enabled. 1: Reporting initially disabled. */ esp_ble_gap_sync_t filter_duplicates; /*!< Supported only by esp32c2, esp32c6, and esp32h2; can be set by menuconfig: 0: Duplicate filtering initially disabled. 1: Duplicate filtering initially enabled. */ - #endif +#endif // (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) uint8_t sid; /*!< SID of the periodic advertising */ esp_ble_addr_type_t addr_type; /*!< Address type of the periodic advertising */ esp_bd_addr_t addr; /*!< Address of the periodic advertising */ diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index b66fb2295f..8a2591d72b 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1589,10 +1589,10 @@ typedef struct { typedef struct { UINT8 filter_policy; - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) UINT8 reports_disabled; UINT8 filter_duplicates; - #endif +#endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) UINT8 sid; tBLE_ADDR_TYPE addr_type; BD_ADDR addr; 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 9ba79b46ed..3e971b12ab 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 @@ -2486,10 +2486,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) params.addr_type = arg_5->periodic_adv_create_sync.params.addr_type; params.skip = arg_5->periodic_adv_create_sync.params.skip; params.sync_timeout = arg_5->periodic_adv_create_sync.params.sync_timeout; - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) params.reports_disabled = arg_5->periodic_adv_create_sync.params.reports_disabled; params.filter_duplicates = arg_5->periodic_adv_create_sync.params.filter_duplicates; - #endif +#endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) memcpy(params.addr, arg_5->periodic_adv_create_sync.params.addr, sizeof(BD_ADDR)); BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC"); 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 f2dcad5de6..28f810c1b3 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 @@ -830,10 +830,10 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params) if ((params->sync_timeout < 0x0a || params->sync_timeout > 0x4000) || (params->filter_policy > 0x01) - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) || (params->reports_disabled > 0x01) || (params->filter_duplicates > 0x01) - #endif +#endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) /*If the Periodic Advertiser List is not used, the Advertising_SID, Advertiser Address_Type, and Advertiser Address parameters specify the periodic advertising device to listen to; otherwise they @@ -850,14 +850,14 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params) SET_BIT(option, 0); } - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) if (params->reports_disabled) { SET_BIT(option, 1); } if (params->filter_duplicates) { SET_BIT(option, 2); } - #endif +#endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) if (!btsnd_hcic_ble_periodic_adv_create_sync(option, params->sid, params->addr_type, params->addr, params->sync_timeout, 0)) { diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index fbad343cfb..b0b59f430c 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -813,10 +813,10 @@ typedef struct { typedef struct { UINT8 filter_policy; - #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) +#if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) UINT8 reports_disabled; UINT8 filter_duplicates; - #endif +#endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) UINT8 sid; tBLE_ADDR_TYPE addr_type; BD_ADDR addr; diff --git a/examples/bluetooth/bluedroid/ble_50/periodic_sync/tutorial/Periodic_Sync_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble_50/periodic_sync/tutorial/Periodic_Sync_Example_Walkthrough.md index 5ef065d57e..aa6b35ea90 100644 --- a/examples/bluetooth/bluedroid/ble_50/periodic_sync/tutorial/Periodic_Sync_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble_50/periodic_sync/tutorial/Periodic_Sync_Example_Walkthrough.md @@ -243,14 +243,14 @@ typedef struct { esp_ble_gap_sync_t filter_policy; /*!< Configures the filter policy for periodic advertising sync: 0: Use Advertising SID, Advertiser Address Type, and Advertiser Address parameters to determine the advertiser to listen to. 1: Use the Periodic Advertiser List to determine the advertiser to listen to. */ - #if (BLE_FEAT_CREATE_SYNC_ENH) + #if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) esp_ble_gap_sync_t reports_disabled; /*!< Supported only by esp32c2, esp32c6, and esp32h2; can be set by menuconfig: 0: Reporting initially enabled. 1: Reporting initially disabled. */ esp_ble_gap_sync_t filter_duplicates; /*!< Supported only by esp32c2, esp32c6, and esp32h2; can be set by menuconfig: 0: Duplicate filtering initially disabled. 1: Duplicate filtering initially enabled. */ - #endif + #endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) uint8_t sid; /*!< SID of the periodic advertising */ esp_ble_addr_type_t addr_type; /*!< Address type of the periodic advertising */ esp_bd_addr_t addr; /*!< Address of the periodic advertising */ From 77f5da2cb4250cf3c0da5485b854148fec5c2fd5 Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Mon, 21 Apr 2025 17:03:27 +0800 Subject: [PATCH 2/2] feat(ble/bluedroid): Add sync_cte_type in creat_periodic_adv_sync function (cherry picked from commit eb647d10c6c0db332f56bf50ab19de94181e7878) Co-authored-by: zhiweijian --- .../bt/host/bluedroid/api/include/api/esp_gap_ble_api.h | 8 ++++++++ components/bt/host/bluedroid/bta/include/bta/bta_api.h | 1 + .../bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 3 +++ components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c | 2 +- components/bt/host/bluedroid/stack/hcic/hciblecmds.c | 8 ++++---- .../bt/host/bluedroid/stack/include/stack/btm_ble_api.h | 1 + .../bt/host/bluedroid/stack/include/stack/hcimsgs.h | 2 +- 7 files changed, 19 insertions(+), 6 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 36bd8f8cf7..dbdb6cc0af 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 @@ -995,6 +995,14 @@ typedef struct { esp_bd_addr_t addr; /*!< Address of the periodic advertising */ uint16_t skip; /*!< Maximum number of periodic advertising events that can be skipped */ uint16_t sync_timeout; /*!< Synchronization timeout */ +#if (CONFIG_BT_BLE_FEAT_CTE_EN) + uint8_t sync_cte_type; /*!< Whether to only synchronize to periodic advertising with certain types of CTE (Constant Tone Extension) + bit 0: Do not sync to packets with an AoA CTE + bit 1: Do not sync to packets with an AoD CTE with 1 μs slots + bit 2: Do not sync to packets with an AoD CTE with 2 μs slots + bit 3: Do not sync to packets with a type 3 CTE (currently reserved for future use) + bit 4: Do not sync to packets without a CTE */ +#endif // BT_BLE_FEAT_CTE_EN } esp_ble_gap_periodic_adv_sync_params_t; /** diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 8a2591d72b..d087e552ae 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1598,6 +1598,7 @@ typedef struct { BD_ADDR addr; UINT16 skip; UINT16 sync_timeout; + UINT8 sync_cte_type; } tBTA_DM_BLE_Periodic_Sync_Params; typedef struct { 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 3e971b12ab..c90c6166f8 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 @@ -2486,6 +2486,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) params.addr_type = arg_5->periodic_adv_create_sync.params.addr_type; params.skip = arg_5->periodic_adv_create_sync.params.skip; params.sync_timeout = arg_5->periodic_adv_create_sync.params.sync_timeout; +#if (BLE_FEAT_CTE_EN == TRUE) + params.sync_cte_type = arg_5->periodic_adv_create_sync.params.sync_cte_type; +#endif // #if (BLE_FEAT_CTE_EN == TRUE) #if (BLE_FEAT_CREATE_SYNC_ENH == TRUE) params.reports_disabled = arg_5->periodic_adv_create_sync.params.reports_disabled; params.filter_duplicates = arg_5->periodic_adv_create_sync.params.filter_duplicates; 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 28f810c1b3..47941808b6 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 @@ -860,7 +860,7 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params) #endif // (BLE_FEAT_CREATE_SYNC_ENH == TRUE) if (!btsnd_hcic_ble_periodic_adv_create_sync(option, params->sid, params->addr_type, - params->addr, params->sync_timeout, 0)) { + params->addr, params->sync_timeout, params->sync_cte_type)) { BTM_TRACE_ERROR("LE PA CreateSync cmd failed"); status = BTM_ILLEGAL_VALUE; } diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 242ddd1868..5b4822dad9 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -1642,12 +1642,12 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) #if (BLE_50_EXTEND_SYNC_EN == TRUE) BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, - UINT16 sync_timeout, UINT8 unused) + UINT16 sync_timeout, UINT8 sync_cte_type) { BT_HDR *p; UINT8 *pp; - HCI_TRACE_EVENT("%s, option = %d, adv_sid = %d, adv_addr_type = %d, sync_timeout = %d, unused = %d", - __func__, option, adv_sid, adv_addr_type, sync_timeout, unused); + HCI_TRACE_EVENT("%s, option = %d, adv_sid = %d, adv_addr_type = %d, sync_timeout = %d, sync_cte_type = %d", + __func__, option, adv_sid, adv_addr_type, sync_timeout, sync_cte_type); HCI_TRACE_EVENT("addr %02x %02x %02x %02x %02x %02x", adv_addr[0], adv_addr[1], adv_addr[2], adv_addr[3], adv_addr[4], adv_addr[5]); uint16_t skip = 0; @@ -1661,7 +1661,7 @@ BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid, BDADDR_TO_STREAM(pp, adv_addr); UINT16_TO_STREAM(pp, skip); UINT16_TO_STREAM(pp, sync_timeout); - UINT8_TO_STREAM(pp, unused); + UINT8_TO_STREAM(pp, sync_cte_type); btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); return TRUE; diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index b0b59f430c..7ec384ef1b 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -822,6 +822,7 @@ typedef struct { BD_ADDR addr; UINT16 skip; UINT16 sync_timeout; + UINT8 sync_cte_type; } tBTM_BLE_Periodic_Sync_Params; typedef struct { diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index 6b7b45c439..4ee07b4d40 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -1034,7 +1034,7 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn); BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, - UINT16 sync_timeout, UINT8 unused); + UINT16 sync_timeout, UINT8 sync_cte_type); UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void);