From 30c6810ae57bf890d684d80e71fb1f1aaeb56116 Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Mon, 21 Apr 2025 17:03:19 +0800 Subject: [PATCH] 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 a0ef1d6e53..87d106fe05 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 @@ -994,6 +994,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 3b56aa32ac..f0d74d5ec8 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1592,6 +1592,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 471669dd8e..6a1dd0d9d1 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 @@ -2467,6 +2467,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 a5d92536cc..75072df0b9 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -1030,7 +1030,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);