From 571e6f0580cf29b8c0bcaf83f311f1ed599344ef Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Fri, 25 Aug 2023 20:22:03 +0800 Subject: [PATCH] feat(bt/bluedroid): Support periodic adv adi feature --- components/bt/host/bluedroid/Kconfig.in | 7 +++ .../bt/host/bluedroid/api/esp_gap_ble_api.c | 37 +++++++++----- .../api/include/api/esp_gap_ble_api.h | 50 ++++++++++++++----- .../bt/host/bluedroid/bta/dm/bta_dm_act.c | 3 +- .../bt/host/bluedroid/bta/dm/bta_dm_api.c | 5 +- .../bluedroid/bta/dm/include/bta_dm_int.h | 3 +- .../host/bluedroid/bta/include/bta/bta_api.h | 4 +- .../btc/profile/std/gap/btc_gap_ble.c | 7 +-- .../btc/profile/std/include/btc_gap_ble.h | 20 +++----- .../include/common/bluedroid_user_config.h | 6 +++ .../common/include/common/bt_target.h | 6 +++ .../host/bluedroid/stack/btm/btm_ble_5_gap.c | 15 ++++-- .../stack/include/stack/btm_ble_api.h | 4 +- .../peroidic_adv/main/periodic_adv_demo.c | 25 +++++++--- .../Periodic_adv_Example_Walkthrough.md | 21 ++++++-- 15 files changed, 150 insertions(+), 63 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 6001187513..bb9fd7e218 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1099,6 +1099,13 @@ config BT_BLE_42_FEATURES_SUPPORTED help This enables BLE 4.2 features. +config BT_BLE_FEAT_PERIODIC_ADV_ENH + bool "Enable periodic adv enhancements(adi support)" + depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && SOC_ESP_NIMBLE_CONTROLLER) + default n + help + Enable the periodic advertising enhancements + config BT_BLE_HIGH_DUTY_ADV_INTERVAL bool "Enable BLE high duty advertising interval feature" depends on BT_BLUEDROID_ENABLED diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index b076f11588..cc51844bb0 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -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-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "esp_bt_device.h" @@ -1028,8 +1020,13 @@ esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_ga } +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) +esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length, + const uint8_t *data, bool only_update_did) +#else esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length, const uint8_t *data) +#endif { btc_msg_t msg; btc_ble_5_gap_args_t arg; @@ -1043,13 +1040,22 @@ esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t le arg.periodic_adv_cfg_data.instance = instance; arg.periodic_adv_cfg_data.len = length; arg.periodic_adv_cfg_data.data = (uint8_t *)data; +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) + arg.periodic_adv_cfg_data.only_update_did = only_update_did; +#else + arg.periodic_adv_cfg_data.only_update_did = false; +#endif return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) +esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance,bool include_adi) +#else esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance) +#endif { btc_msg_t msg; btc_ble_5_gap_args_t arg; @@ -1060,6 +1066,11 @@ esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance) msg.pid = BTC_PID_GAP_BLE; msg.act = BTC_GAP_BLE_PERIODIC_ADV_START; + #if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) + arg.periodic_adv_start.include_adi = include_adi; + #else + arg.periodic_adv_start.include_adi = false; + #endif arg.periodic_adv_start.instance = instance; return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) 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 57b78d033c..6ac4b0cb5f 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 @@ -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-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __ESP_GAP_BLE_API_H__ #define __ESP_GAP_BLE_API_H__ @@ -2016,6 +2008,22 @@ esp_err_t esp_ble_gap_ext_adv_set_clear(void); */ esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_gap_periodic_adv_params_t *params); +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) +/** +* @brief This function is used to set the data used in periodic advertising PDUs. +* +* @param[in] instance : identifies the advertising set whose periodic advertising parameters are being configured. +* @param[in] length : the length of periodic data +* @param[in] data : periodic data information +* @param[in] only_update_did : If true, only the Advertising DID of the periodic advertising will be updated, and the length and data parameters will be ignored. +* +* @return - ESP_OK : success +* - other : failed +* +*/ +esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length, + const uint8_t *data, bool only_update_did); +#else /** * @brief This function is used to set the data used in periodic advertising PDUs. * @@ -2029,6 +2037,21 @@ esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_ga */ esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length, const uint8_t *data); +#endif + +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) +/** +* @brief This function is used to request the Controller to enable the periodic advertising for the advertising set specified +* +* @param[in] instance : Used to identify an advertising set +* @param[in] include_adi : If true, the ADI (Advertising Data Info) field will be included in AUX_SYNC_IND PDUs +* +* @return - ESP_OK : success +* - other : failed +* +*/ +esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance,bool include_adi); +#else /** * @brief This function is used to request the Controller to enable the periodic advertising for the advertising set specified * @@ -2039,6 +2062,7 @@ esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t le * */ esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance); +#endif /** * @brief This function is used to request the Controller to disable the periodic advertising for the advertising set specified diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 316dfc72f4..cc33129a9d 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5669,7 +5669,8 @@ void bta_dm_ble_gap_periodic_adv_cfg_data_raw(tBTA_DM_MSG *p_data) BTM_BlePeriodicAdvCfgDataRaw(p_data->ble_cfg_periodic_adv_data.instance, p_data->ble_cfg_periodic_adv_data.length, - p_data->ble_cfg_periodic_adv_data.data); + p_data->ble_cfg_periodic_adv_data.data, + p_data->ble_cfg_periodic_adv_data.only_update_did); } void bta_dm_ble_gap_periodic_adv_enable(tBTA_DM_MSG *p_data) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 99a0543ee7..f8c2fd438e 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -2883,7 +2883,7 @@ void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance, } void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, - const UINT8 *data) + const UINT8 *data,bool only_update_did) { tBTA_DM_API_CFG_PERIODIC_ADV_DATA *p_msg; APPL_TRACE_API("%s, Periodic ADV config data raw.", __func__); @@ -2895,6 +2895,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, p_msg->data = (UINT8 *)(p_msg + 1); memcpy(p_msg->data, data, length); p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL; + p_msg->only_update_did = only_update_did; //start sent the msg to the bta system control moudle bta_sys_sendmsg(p_msg); } else { @@ -2903,7 +2904,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, } -void BTA_DmBleGapPeriodicAdvEnable(BOOLEAN enable, UINT8 instance) +void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance) { tBTA_DM_API_ENABLE_PERIODIC_ADV *p_msg; APPL_TRACE_API("%s, Periodic ADV %s.", __func__, enable ? "start" : "stop"); diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 723f97e941..4083005e26 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -945,12 +945,13 @@ typedef struct { UINT8 instance; UINT16 length; UINT8 *data; + BOOLEAN only_update_did; } tBTA_DM_API_CFG_PERIODIC_ADV_DATA; typedef struct { BT_HDR hdr; UINT8 instance; - BOOLEAN enable; + UINT8 enable; } tBTA_DM_API_ENABLE_PERIODIC_ADV; typedef struct { 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 f5fae44e1b..0735c7943b 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -2947,9 +2947,9 @@ extern void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance, tBTA_DM_BLE_Periodic_Adv_Params *params); extern void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, - const UINT8 *data); + const UINT8 *data,BOOLEAN only_update_did); -extern void BTA_DmBleGapPeriodicAdvEnable(BOOLEAN enable, UINT8 instance); +extern void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance); extern void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params); 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 9780934551..0ade03f199 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1836,11 +1836,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTC_TRACE_DEBUG("BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW"); BTA_DmBleGapPeriodicAdvCfgDataRaw(arg_5->periodic_adv_cfg_data.instance, arg_5->periodic_adv_cfg_data.len, - (const UINT8 *)arg_5->periodic_adv_cfg_data.data); + (const UINT8 *)arg_5->periodic_adv_cfg_data.data, + arg_5->periodic_adv_cfg_data.only_update_did); break; case BTC_GAP_BLE_PERIODIC_ADV_START: BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_START"); - BTA_DmBleGapPeriodicAdvEnable(TRUE, arg_5->periodic_adv_start.instance); + BTA_DmBleGapPeriodicAdvEnable(((arg_5->periodic_adv_start.include_adi)<<1)|0x01, arg_5->periodic_adv_start.instance); break; case BTC_GAP_BLE_PERIODIC_ADV_STOP: BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_STOP"); diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 3721f3dccb..c19e0d758d 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.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-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef __BTC_GAP_BLE_H__ #define __BTC_GAP_BLE_H__ @@ -291,9 +283,11 @@ typedef union { uint8_t instance; uint16_t len; uint8_t *data; + bool only_update_did; } periodic_adv_cfg_data; struct periodic_adv_start_args { + bool include_adi; uint8_t instance; } periodic_adv_start; diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 4c718f175b..15b5c9bbe4 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -125,6 +125,12 @@ #define UC_BT_BLE_42_FEATURES_SUPPORTED FALSE #endif +#ifdef CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH +#define UC_BT_BLE_FEAT_PERIODIC_ADV_ENH CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH +#else +#define UC_BT_BLE_FEAT_PERIODIC_ADV_ENH FALSE +#endif + #ifdef CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL #define UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL #else 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 88586df414..c7420415cc 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -183,6 +183,12 @@ #define BLE_42_FEATURE_SUPPORT FALSE #endif +#if (UC_BT_BLE_FEAT_PERIODIC_ADV_ENH == TRUE) +#define BLE_FEAT_PERIODIC_ADV_ENH TRUE +#else +#define BLE_FEAT_PERIODIC_ADV_ENH FALSE +#endif + #if (UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL == TRUE) #define BLE_HIGH_DUTY_ADV_INTERVAL TRUE #else 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 0416ce6233..f503d51040 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 @@ -690,7 +690,7 @@ end: return status; } -tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data) +tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data,BOOLEAN only_update_did) { tBTM_STATUS status = BTM_SUCCESS; tHCI_STATUS err = HCI_SUCCESS; @@ -698,6 +698,13 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data UINT8 operation = 0; UINT16 data_offset = 0; tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + if (only_update_did) + { + len = 0; + data = NULL; + rem_len = 0; + operation = BTM_BLE_ADV_DATA_OP_UNCHANGED_DATA; + } if ((status = btm_ble_ext_adv_set_data_validate(instance, len, data)) != BTM_SUCCESS) { BTM_TRACE_ERROR("%s, invalid extend adv data.", __func__); @@ -708,7 +715,9 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data UINT8 send_data_len = (rem_len > BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX) ? BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX : rem_len; if (len <= BTM_BLE_EXT_ADV_DATA_LEN_MAX) { - operation = BTM_BLE_ADV_DATA_OP_COMPLETE; + if (!only_update_did) { + operation = BTM_BLE_ADV_DATA_OP_COMPLETE; + } } else { if (rem_len == len) { operation = BTM_BLE_ADV_DATA_OP_FIRST_FRAG; @@ -734,7 +743,7 @@ end: return status; } -tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, BOOLEAN enable) +tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, UINT8 enable) { tBTM_STATUS status = BTM_SUCCESS; tHCI_STATUS err = HCI_SUCCESS; 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 74640777ea..ee736e9520 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 @@ -2597,9 +2597,9 @@ tBTM_STATUS BTM_BleExtAdvSetClear(void); tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params); -tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data); +tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data, BOOLEAN only_update_did); -tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, BOOLEAN enable); +tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, UINT8 enable); tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params); diff --git a/examples/bluetooth/bluedroid/ble_50/peroidic_adv/main/periodic_adv_demo.c b/examples/bluetooth/bluedroid/ble_50/peroidic_adv/main/periodic_adv_demo.c index c97bfe029c..d0b79d17a6 100644 --- a/examples/bluetooth/bluedroid/ble_50/peroidic_adv/main/periodic_adv_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/peroidic_adv/main/periodic_adv_demo.c @@ -1,10 +1,8 @@ /* - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ /**************************************************************************** * @@ -193,9 +191,24 @@ void app_main(void) // start all adv FUNC_SEND_WAIT_SEM(esp_ble_gap_ext_adv_start(NUM_EXT_ADV, &ext_adv[0]), test_sem); + // set periodic adv param FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_set_params(EXT_ADV_HANDLE, &periodic_adv_params), test_sem); + +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) + // set periodic adv raw data + FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0], false), test_sem); + // start periodic adv, include the ADI field in AUX_SYNC_IND PDUs + FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_start(EXT_ADV_HANDLE, true), test_sem); + while (1) { + vTaskDelay(2000 / portTICK_PERIOD_MS); + // just update the Advertising DID of the periodic advertising, unchanged data + FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, 0, NULL, true), test_sem); + } +#else + // set periodic adv raw data FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0]), test_sem); FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_start(EXT_ADV_HANDLE), test_sem); +#endif return; } diff --git a/examples/bluetooth/bluedroid/ble_50/peroidic_adv/tutorial/Periodic_adv_Example_Walkthrough.md b/examples/bluetooth/bluedroid/ble_50/peroidic_adv/tutorial/Periodic_adv_Example_Walkthrough.md index ad843f80d1..4b5ea8a562 100644 --- a/examples/bluetooth/bluedroid/ble_50/peroidic_adv/tutorial/Periodic_adv_Example_Walkthrough.md +++ b/examples/bluetooth/bluedroid/ble_50/peroidic_adv/tutorial/Periodic_adv_Example_Walkthrough.md @@ -94,12 +94,25 @@ a_2m), &raw_ext_adv_data_2m[0]), test_sem); // start all adv FUNC_SEND_WAIT_SEM(esp_ble_gap_ext_adv_start(NUM_EXT_ADV, &ext_adv[0]), test_sem); + + // set periodic adv param + FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_set_params(EXT_ADV_HANDLE, &periodic_adv_params), test_sem); - FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_set_params(EXT_ADV_HANDLE, &periodic_adv_params), - test_sem); - FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, sizeof(periodic_a -dv_raw_data), &periodic_adv_raw_data[0]), test_sem); +#if (CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH) + // set periodic adv raw data + FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0], false), test_sem); + // start periodic adv, include the ADI field in AUX_SYNC_IND PDUs + FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_start(EXT_ADV_HANDLE, true), test_sem); + while (1) { + vTaskDelay(2000 / portTICK_PERIOD_MS); + // just update the Advertising DID of the periodic advertising, unchanged data + FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, 0, NULL, true), test_sem); + } +#else + // set periodic adv raw data + FUNC_SEND_WAIT_SEM(esp_ble_gap_config_periodic_adv_data_raw(EXT_ADV_HANDLE, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0]), test_sem); FUNC_SEND_WAIT_SEM(esp_ble_gap_periodic_adv_start(EXT_ADV_HANDLE), test_sem); +#endif return; }