Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: controller: Extend DTM commands #42300

Merged
merged 5 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion include/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,15 @@ struct bt_hci_cp_le_rx_test {
uint8_t rx_ch;
} __packed;

#define BT_HCI_TEST_PKT_PAYLOAD_PRBS9 0x00
#define BT_HCI_TEST_PKT_PAYLOAD_11110000 0x01
#define BT_HCI_TEST_PKT_PAYLOAD_10101010 0x02
#define BT_HCI_TEST_PKT_PAYLOAD_PRBS15 0x03
#define BT_HCI_TEST_PKT_PAYLOAD_11111111 0x04
#define BT_HCI_TEST_PKT_PAYLOAD_00000000 0x05
#define BT_HCI_TEST_PKT_PAYLOAD_00001111 0x06
#define BT_HCI_TEST_PKT_PAYLOAD_01010101 0x07

#define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e)
struct bt_hci_cp_le_tx_test {
uint8_t tx_ch;
Expand Down Expand Up @@ -1231,14 +1240,19 @@ struct bt_hci_cp_le_set_phy {
#define BT_HCI_LE_MOD_INDEX_STANDARD 0x00
#define BT_HCI_LE_MOD_INDEX_STABLE 0x01

#define BT_HCI_LE_RX_PHY_1M 0x01
#define BT_HCI_LE_RX_PHY_2M 0x02
#define BT_HCI_LE_RX_PHY_CODED 0x03

#define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033)
struct bt_hci_cp_le_enh_rx_test {
uint8_t rx_ch;
uint8_t phy;
uint8_t mod_index;
} __packed;

/* Extends BT_HCI_LE_PHY */
#define BT_HCI_LE_TX_PHY_1M 0x01
#define BT_HCI_LE_TX_PHY_2M 0x02
#define BT_HCI_LE_TX_PHY_CODED_S8 0x03
#define BT_HCI_LE_TX_PHY_CODED_S2 0x04

Expand Down Expand Up @@ -1518,6 +1532,36 @@ struct bt_hci_cp_le_set_privacy_mode {
uint8_t mode;
} __packed;

#define BT_HCI_LE_TEST_CTE_DISABLED 0x00
#define BT_HCI_LE_TEST_CTE_TYPE_ANY 0x00
#define BT_HCI_LE_TEST_SLOT_DURATION_ANY 0x00
#define BT_HCI_LE_TEST_SWITCH_PATTERN_LEN_ANY 0x00

#define BT_HCI_OP_LE_RX_TEST_V3 BT_OP(BT_OGF_LE, 0x004f)
struct bt_hci_cp_le_rx_test_v3 {
uint8_t rx_ch;
uint8_t phy;
uint8_t mod_index;
uint8_t expected_cte_len;
uint8_t expected_cte_type;
uint8_t slot_durations;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;

#define BT_HCI_OP_LE_TX_TEST_V3 BT_OP(BT_OGF_LE, 0x0050)

struct bt_hci_cp_le_tx_test_v3 {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
uint8_t phy;
uint8_t cte_len;
uint8_t cte_type;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;

/* Min and max Constant Tone Extension length in 8us units */
#define BT_HCI_LE_CTE_LEN_MIN 0x2
#define BT_HCI_LE_CTE_LEN_MAX 0x14
Expand Down Expand Up @@ -2019,6 +2063,33 @@ struct bt_hci_rp_le_read_iso_link_quality {
uint32_t duplicate_packets;
} __packed;

#define BT_HCI_OP_LE_TX_TEST_V4 BT_OP(BT_OGF_LE, 0x007B)

struct bt_hci_cp_le_tx_test_v4 {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
uint8_t phy;
uint8_t cte_len;
uint8_t cte_type;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;

#define BT_HCI_TX_TEST_POWER_MIN -0x7F
#define BT_HCI_TX_TEST_POWER_MAX 0x14

#define BT_HCI_TX_TEST_POWER_MIN_SET 0x7E
#define BT_HCI_TX_TEST_POWER_MAX_SET 0x7F

/* Helper structure for Tx power parameter in the HCI Tx Test v4 command.
* Previous parameter of this command is variable size so having separated structure
* for this parameter helps in command parameters unpacking.
*/
struct bt_hci_cp_le_tx_test_v4_tx_power {
ppryga-nordic marked this conversation as resolved.
Show resolved Hide resolved
int8_t tx_power;
} __packed;

/* Event definitions */

#define BT_HCI_EVT_UNKNOWN 0x00
Expand Down
18 changes: 18 additions & 0 deletions samples/bluetooth/hci_uart/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,21 @@ application. To enable debug over RTT the debug configuration file can be used.
west build samples/bluetooth/hci_uart -- -DOVERLAY_CONFIG='debug.conf'

Then attach RTT as described here: :ref:`Using Segger J-Link <Using Segger J-Link>`

Support for the Direction Finding
ppryga-nordic marked this conversation as resolved.
Show resolved Hide resolved
=================================

The sample can be built with the support for the BLE Direction Finding.
To enable this feature build this sample for specific board variants that provide
required hardware configuration for the Radio.

.. code-block:: console

west build samples/bluetooth/hci_uart -b nrf52833dk_nrf52833@df -- -DCONFIG_BT_CTLR_DF=y

You can use following targets:

* ``nrf5340dk_nrf5340_cpunet@df``
* ``nrf52833dk_nrf52833@df``

Check the :ref:`bluetooth_direction_finding_connectionless_rx` and the :ref:`bluetooth_direction_finding_connectionless_tx` for more details.
12 changes: 12 additions & 0 deletions samples/bluetooth/hci_uart/boards/nrf52833dk_nrf52833.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
ppryga-nordic marked this conversation as resolved.
Show resolved Hide resolved
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <1000000>;
status = "okay";
hw-flow-control;
};
33 changes: 33 additions & 0 deletions samples/bluetooth/hci_uart/boards/nrf52833dk_nrf52833_df.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <1000000>;
status = "okay";
hw-flow-control;
};

&radio {
status = "okay";
/* This is an example number of antennas that may be available
* on antenna matrix board.
*/
dfe-antenna-num = <10>;
/* This is an example switch pattern that will be used to set an
* antenna for Tx PDU (period before start of Tx CTE).
*/
dfe-pdu-antenna = <0x0>;

/* These are example GPIO pin numbers that are provided to
* Radio peripheral. The pins will be acquired by Radio to
* drive antenna switching when AoD is enabled.
*/
dfegpio0-gpios = <&gpio0 3 0>;
dfegpio1-gpios = <&gpio0 4 0>;
dfegpio2-gpios = <&gpio0 28 0>;
dfegpio3-gpios = <&gpio0 29 0>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <1000000>;
status = "okay";
hw-flow-control;
};

&radio {
status = "okay";
/* This is an example number of antennas that may be available
* on antenna matrix board.
*/
dfe-antenna-num = <10>;
/* This is an example switch pattern that will be used to set an
* antenna for Tx PDU (period before start of Tx CTE).
*/
dfe-pdu-antenna = <0x0>;

/* These are example GPIO pin numbers that are provided to
* Radio peripheral. The pins will be acquired by Radio to
* drive antenna switching when AoD is enabled.
*/
dfegpio0-gpios = <&gpio0 4 0>;
dfegpio1-gpios = <&gpio0 5 0>;
dfegpio2-gpios = <&gpio0 6 0>;
dfegpio3-gpios = <&gpio0 7 0>;
};
30 changes: 30 additions & 0 deletions samples/bluetooth/hci_uart/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,33 @@ tests:
platform_allow: 96b_nitrogen nrf51dk_nrf51422
nrf52dk_nrf52832
tags: uart bluetooth
sample.bluetooth.hci_uart.nrf52833.df:
harness: bluetooth
platform_allow: nrf52833dk_nrf52833
extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay
extra_configs:
- CONFIG_BT_CTLR_DF=y
tags: uart bluetooth
sample.bluetooth.hci_uart.nrf5340_netcore.df:
harness: bluetooth
platform_allow: nrf5340dk_nrf5340_cpunet
extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay
extra_configs:
- CONFIG_BT_CTLR_DF=y
tags: uart bluetooth
sample.bluetooth.hci_uart.nrf52833.df.iq_report:
harness: bluetooth
platform_allow: nrf52833dk_nrf52833
extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay
extra_configs:
- CONFIG_BT_CTLR_DF=y
- CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y
tags: uart bluetooth
sample.bluetooth.hci_uart.nrf5340_netcore.df.iq_report:
harness: bluetooth
platform_allow: nrf5340dk_nrf5340_cpunet
extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay
extra_configs:
- CONFIG_BT_CTLR_DF=y
- CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y
tags: uart bluetooth
16 changes: 1 addition & 15 deletions subsys/bluetooth/controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ config BT_CTLR_CHAN_SEL_2_SUPPORT
config BT_CTLR_MIN_USED_CHAN_SUPPORT
bool

config BT_CTLR_DTM_HCI_SUPPORT
bool

config BT_CTLR_SMI_SUPPORT
bool

Expand Down Expand Up @@ -747,18 +744,6 @@ config BT_CTLR_READ_ISO_LINK_QUALITY
help
Enable support for LE Read ISO Link Quality command.

config BT_CTLR_DTM
bool
help
Enable support for Direct Test Mode in the Controller.

config BT_CTLR_DTM_HCI
bool "Direct Test Mode over HCI"
depends on BT_CTLR_DTM_HCI_SUPPORT
select BT_CTLR_DTM
help
Enable support for Direct Test Mode over the HCI transport.

config BT_CTLR_SMI_RX
bool "Stable modulation index - Receiver"
depends on BT_CTLR_SMI_SUPPORT
Expand All @@ -785,6 +770,7 @@ config BT_CTLR_HCI_CODEC_AND_DELAY_INFO

rsource "Kconfig.df"
rsource "Kconfig.ll_sw_split"
rsource "Kconfig.dtm"

config BT_CTLR_ASSERT_HANDLER
bool "Application Defined Assertion Handler"
Expand Down
61 changes: 61 additions & 0 deletions subsys/bluetooth/controller/Kconfig.dtm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Zephyr Bluetooth Controller configuration options

# Copyright (c) 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config BT_CTLR_DTM_HCI_SUPPORT
bool

config BT_CTLR_DTM
bool
help
Enable support for Direct Test Mode in the Controller.

menuconfig BT_CTLR_DTM_HCI
bool "Direct Test Mode over HCI"
depends on BT_CTLR_DTM_HCI_SUPPORT
select BT_CTLR_DTM
help
Enable support for Direct Test Mode over the HCI transport.

if BT_CTLR_DTM_HCI

config BT_CTLR_DTM_HCI_RX_V3
cvinayak marked this conversation as resolved.
Show resolved Hide resolved
bool "HCI LE Receiver Test v3"
default y
help
Enable support for the DTM Receiver test command v3.

config BT_CTLR_DTM_HCI_TX_V3
bool "HCI LE Transmitter Test v3"
default y
help
Enable support for the DTM Transmitter test command v3.

config BT_CTLR_DTM_HCI_TX_V4
bool "HCI LE Transmitter Test v4"
default y
help
Enable support for the DTM Transmitter test command v4.

menuconfig BT_CTLR_DTM_HCI_DF_IQ_REPORT
bool "Connectionless IQ report HCI event [EXPERIMENTAL]"
depends on BT_CTLR_DF_CTE_RX && BT_CTLR_DTM_HCI_RX_V3
select EXPERIMENTAL
help
Enable generation of the HCI LE Connectionless IQ Report event
after the Constant Tone Extension reception.

if BT_CTLR_DTM_HCI_DF_IQ_REPORT

config BT_CTLR_DTM_HCI_DF_IQ_REPORT_NUM_MAX
int "IQ Report pool size"
default 32
help
Maximum number of the DTM IQ Reports in pool. It depends on the upper tester
test packets transmission interval.


endif # BT_CTLR_DTM_HCI_DF_IQ_REPORT

endif # BT_CTLR_DTM_HCI
Loading