From ca387cf2d1749347cce1ca2e3432e08d26dbfc40 Mon Sep 17 00:00:00 2001 From: Piotr Pryga Date: Thu, 26 Aug 2021 12:55:24 +0200 Subject: [PATCH] samples: Bluetooth: df: Enable TX of mutliple CTEs in a per adv event Since periodic advertising chains are available there is a possibility to send multiple PDUs including CTE in a periodic advertising event. This commit enables such functionality in direction finding transmitter sample. It includes a partial fix of zephyrproject-rtos/zephyr#41407. Signed-off-by: Piotr Pryga (cherry picked from commit 50a2cdd75adab154c9007d2744c453dd56fd696d) Signed-off-by: Ryan Chu --- .../boards/nrf52833dk_nrf52820.conf | 5 +++++ .../boards/nrf52833dk_nrf52833.conf | 5 +++++ .../child_image/hci_rpmsg.conf | 5 +++++ .../prj.conf | 1 + .../src/main.c | 22 +++++++++---------- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52820.conf b/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52820.conf index 8c8bccbb4887..0ad2b92a3612 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52820.conf +++ b/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52820.conf @@ -16,3 +16,8 @@ CONFIG_BT_CTLR_DF=y # Disable Direction Finding RX mode CONFIG_BT_CTLR_DF_ANT_SWITCH_RX=n CONFIG_BT_CTLR_DF_SCAN_CTE_RX=n + +# Enable chaining of multiple CTEs in periodic advertising +CONFIG_BT_CTLR_ADVANCED_FEATURES=y +CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y +CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX=16 diff --git a/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52833.conf b/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52833.conf index 5125b5e0a356..37341ecaee5a 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52833.conf +++ b/samples/bluetooth/direction_finding_connectionless_tx/boards/nrf52833dk_nrf52833.conf @@ -16,3 +16,8 @@ CONFIG_BT_CTLR_DF=y # Disable Direction Finding RX mode CONFIG_BT_CTLR_DF_SCAN_CTE_RX=n CONFIG_BT_CTLR_DF_ANT_SWITCH_RX=n + +# Enable chaining of multiple CTEs in periodic advertising +CONFIG_BT_CTLR_ADVANCED_FEATURES=y +CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y +CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX=16 diff --git a/samples/bluetooth/direction_finding_connectionless_tx/child_image/hci_rpmsg.conf b/samples/bluetooth/direction_finding_connectionless_tx/child_image/hci_rpmsg.conf index 799213ca0e66..8bf2eb3c77a4 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/child_image/hci_rpmsg.conf +++ b/samples/bluetooth/direction_finding_connectionless_tx/child_image/hci_rpmsg.conf @@ -23,3 +23,8 @@ CONFIG_BT_CTLR_DF_CTE_RX=n # Limit number of possible connection to decrease memory usage CONFIG_BT_MAX_CONN=1 + +# Enable chaining of multiple CTEs in periodic advertising +CONFIG_BT_CTLR_ADVANCED_FEATURES=y +CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y +CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX=16 diff --git a/samples/bluetooth/direction_finding_connectionless_tx/prj.conf b/samples/bluetooth/direction_finding_connectionless_tx/prj.conf index 289576ed8a7d..a5d4db7a9143 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/prj.conf +++ b/samples/bluetooth/direction_finding_connectionless_tx/prj.conf @@ -9,6 +9,7 @@ CONFIG_BT_DEVICE_NAME="DF Connectionless Beacon App" CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y +CONFIG_BT_BROADCASTER=y # Enable Direction Finding Feature including AoA and AoD CONFIG_BT_DF=y diff --git a/samples/bluetooth/direction_finding_connectionless_tx/src/main.c b/samples/bluetooth/direction_finding_connectionless_tx/src/main.c index de058985c8b4..907f9a8cad10 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/src/main.c +++ b/samples/bluetooth/direction_finding_connectionless_tx/src/main.c @@ -11,13 +11,14 @@ #include #include -#include #include #include #include /* Length of CTE in unit of 8[us] */ #define CTE_LEN (0x14U) +/* Number of CTE send in single periodic advertising train */ +#define PER_ADV_EVENT_CTE_COUNT 5 static void adv_sent_cb(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_sent_info *info); @@ -54,19 +55,18 @@ static uint8_t ant_patterns[] = {0x2, 0x0, 0x5, 0x6, 0x1, 0x4, 0xC, 0x9, 0xE, 0xD, 0x8, 0xA}; #endif /* CONFIG_BT_DF_CTE_TX_AOD */ -const struct bt_df_adv_cte_tx_param cte_params = { - .cte_len = CTE_LEN, - .cte_count = 1, +struct bt_df_adv_cte_tx_param cte_params = { .cte_len = CTE_LEN, + .cte_count = PER_ADV_EVENT_CTE_COUNT, #if defined(CONFIG_BT_DF_CTE_TX_AOD) - .cte_type = BT_DF_CTE_TYPE_AOD_2US, - .num_ant_ids = ARRAY_SIZE(ant_patterns), - .ant_ids = ant_patterns + .cte_type = BT_DF_CTE_TYPE_AOD_2US, + .num_ant_ids = ARRAY_SIZE(ant_patterns), + .ant_ids = ant_patterns #else - .cte_type = BT_DF_CTE_TYPE_AOA, - .num_ant_ids = 0, - .ant_ids = NULL + .cte_type = BT_DF_CTE_TYPE_AOA, + .num_ant_ids = 0, + .ant_ids = NULL #endif /* CONFIG_BT_DF_CTE_TX_AOD */ - }; +}; static void adv_sent_cb(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_sent_info *info)