Skip to content

Commit 5db0302

Browse files
Kamil Gaworcarlescufi
authored andcommitted
bluetooth: controller: Add support for all DTM commands
This adds support for the following Direct Test mode commands: - HCI LE Receiver Test [v3] - HCI LE Transmitter Test [v3] - HCI LE Transmitter Test [v4] Those commands set add a possibility to test an CTE reception and transmission. The HCI LE Transmitter Test [v4] commands allows also setting a transmit power. Signed-off-by: Kamil Gawor <[email protected]>
1 parent a536456 commit 5db0302

File tree

12 files changed

+802
-104
lines changed

12 files changed

+802
-104
lines changed

include/bluetooth/hci.h

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,15 @@ struct bt_hci_cp_le_rx_test {
10451045
uint8_t rx_ch;
10461046
} __packed;
10471047

1048+
#define BT_HCI_TEST_PKT_PAYLOAD_PRBS9 0x00
1049+
#define BT_HCI_TEST_PKT_PAYLOAD_11110000 0x01
1050+
#define BT_HCI_TEST_PKT_PAYLOAD_10101010 0x02
1051+
#define BT_HCI_TEST_PKT_PAYLOAD_PRBS15 0x03
1052+
#define BT_HCI_TEST_PKT_PAYLOAD_11111111 0x04
1053+
#define BT_HCI_TEST_PKT_PAYLOAD_00000000 0x05
1054+
#define BT_HCI_TEST_PKT_PAYLOAD_00001111 0x06
1055+
#define BT_HCI_TEST_PKT_PAYLOAD_01010101 0x07
1056+
10481057
#define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e)
10491058
struct bt_hci_cp_le_tx_test {
10501059
uint8_t tx_ch;
@@ -1231,14 +1240,19 @@ struct bt_hci_cp_le_set_phy {
12311240
#define BT_HCI_LE_MOD_INDEX_STANDARD 0x00
12321241
#define BT_HCI_LE_MOD_INDEX_STABLE 0x01
12331242

1243+
#define BT_HCI_LE_RX_PHY_1M 0x01
1244+
#define BT_HCI_LE_RX_PHY_2M 0x02
1245+
#define BT_HCI_LE_RX_PHY_CODED 0x03
1246+
12341247
#define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033)
12351248
struct bt_hci_cp_le_enh_rx_test {
12361249
uint8_t rx_ch;
12371250
uint8_t phy;
12381251
uint8_t mod_index;
12391252
} __packed;
12401253

1241-
/* Extends BT_HCI_LE_PHY */
1254+
#define BT_HCI_LE_TX_PHY_1M 0x01
1255+
#define BT_HCI_LE_TX_PHY_2M 0x02
12421256
#define BT_HCI_LE_TX_PHY_CODED_S8 0x03
12431257
#define BT_HCI_LE_TX_PHY_CODED_S2 0x04
12441258

@@ -1518,6 +1532,36 @@ struct bt_hci_cp_le_set_privacy_mode {
15181532
uint8_t mode;
15191533
} __packed;
15201534

1535+
#define BT_HCI_LE_TEST_CTE_DISABLED 0x00
1536+
#define BT_HCI_LE_TEST_CTE_TYPE_ANY 0x00
1537+
#define BT_HCI_LE_TEST_SLOT_DURATION_ANY 0x00
1538+
#define BT_HCI_LE_TEST_SWITCH_PATTERN_LEN_ANY 0x00
1539+
1540+
#define BT_HCI_OP_LE_RX_TEST_V3 BT_OP(BT_OGF_LE, 0x004f)
1541+
struct bt_hci_cp_le_rx_test_v3 {
1542+
uint8_t rx_ch;
1543+
uint8_t phy;
1544+
uint8_t mod_index;
1545+
uint8_t expected_cte_len;
1546+
uint8_t expected_cte_type;
1547+
uint8_t slot_durations;
1548+
uint8_t switch_pattern_len;
1549+
uint8_t ant_ids[0];
1550+
} __packed;
1551+
1552+
#define BT_HCI_OP_LE_TX_TEST_V3 BT_OP(BT_OGF_LE, 0x0050)
1553+
1554+
struct bt_hci_cp_le_tx_test_v3 {
1555+
uint8_t tx_ch;
1556+
uint8_t test_data_len;
1557+
uint8_t pkt_payload;
1558+
uint8_t phy;
1559+
uint8_t cte_len;
1560+
uint8_t cte_type;
1561+
uint8_t switch_pattern_len;
1562+
uint8_t ant_ids[0];
1563+
} __packed;
1564+
15211565
/* Min and max Constant Tone Extension length in 8us units */
15221566
#define BT_HCI_LE_CTE_LEN_MIN 0x2
15231567
#define BT_HCI_LE_CTE_LEN_MAX 0x14
@@ -2019,6 +2063,33 @@ struct bt_hci_rp_le_read_iso_link_quality {
20192063
uint32_t duplicate_packets;
20202064
} __packed;
20212065

2066+
#define BT_HCI_OP_LE_TX_TEST_V4 BT_OP(BT_OGF_LE, 0x007B)
2067+
2068+
struct bt_hci_cp_le_tx_test_v4 {
2069+
uint8_t tx_ch;
2070+
uint8_t test_data_len;
2071+
uint8_t pkt_payload;
2072+
uint8_t phy;
2073+
uint8_t cte_len;
2074+
uint8_t cte_type;
2075+
uint8_t switch_pattern_len;
2076+
uint8_t ant_ids[0];
2077+
} __packed;
2078+
2079+
#define BT_HCI_TX_TEST_POWER_MIN -0x7F
2080+
#define BT_HCI_TX_TEST_POWER_MAX 0x14
2081+
2082+
#define BT_HCI_TX_TEST_POWER_MIN_SET 0x7E
2083+
#define BT_HCI_TX_TEST_POWER_MAX_SET 0x7F
2084+
2085+
/* Helper structure for Tx power parameter in the HCI Tx Test v4 command.
2086+
* Previous parameter of this command is variable size so having separated structure
2087+
* for this parameter helps in command parameters unpacking.
2088+
*/
2089+
struct bt_hci_cp_le_tx_test_v4_tx_power {
2090+
int8_t tx_power;
2091+
} __packed;
2092+
20222093
/* Event definitions */
20232094

20242095
#define BT_HCI_EVT_UNKNOWN 0x00

subsys/bluetooth/controller/Kconfig

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ config BT_CTLR_CHAN_SEL_2_SUPPORT
6767
config BT_CTLR_MIN_USED_CHAN_SUPPORT
6868
bool
6969

70-
config BT_CTLR_DTM_HCI_SUPPORT
71-
bool
72-
7370
config BT_CTLR_SMI_SUPPORT
7471
bool
7572

@@ -747,18 +744,6 @@ config BT_CTLR_READ_ISO_LINK_QUALITY
747744
help
748745
Enable support for LE Read ISO Link Quality command.
749746

750-
config BT_CTLR_DTM
751-
bool
752-
help
753-
Enable support for Direct Test Mode in the Controller.
754-
755-
config BT_CTLR_DTM_HCI
756-
bool "Direct Test Mode over HCI"
757-
depends on BT_CTLR_DTM_HCI_SUPPORT
758-
select BT_CTLR_DTM
759-
help
760-
Enable support for Direct Test Mode over the HCI transport.
761-
762747
config BT_CTLR_SMI_RX
763748
bool "Stable modulation index - Receiver"
764749
depends on BT_CTLR_SMI_SUPPORT
@@ -785,6 +770,7 @@ config BT_CTLR_HCI_CODEC_AND_DELAY_INFO
785770

786771
rsource "Kconfig.df"
787772
rsource "Kconfig.ll_sw_split"
773+
rsource "Kconfig.dtm"
788774

789775
config BT_CTLR_ASSERT_HANDLER
790776
bool "Application Defined Assertion Handler"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Zephyr Bluetooth Controller configuration options
2+
3+
# Copyright (c) 2022 Nordic Semiconductor ASA
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config BT_CTLR_DTM_HCI_SUPPORT
7+
bool
8+
9+
config BT_CTLR_DTM
10+
bool
11+
help
12+
Enable support for Direct Test Mode in the Controller.
13+
14+
menuconfig BT_CTLR_DTM_HCI
15+
bool "Direct Test Mode over HCI"
16+
depends on BT_CTLR_DTM_HCI_SUPPORT
17+
select BT_CTLR_DTM
18+
help
19+
Enable support for Direct Test Mode over the HCI transport.
20+
21+
if BT_CTLR_DTM_HCI
22+
23+
config BT_CTLR_DTM_HCI_RX_V3
24+
bool "HCI LE Receiver Test v3"
25+
default y
26+
help
27+
Enable support for the DTM Receiver test command v3.
28+
29+
config BT_CTLR_DTM_HCI_TX_V3
30+
bool "HCI LE Transmitter Test v3"
31+
default y
32+
help
33+
Enable support for the DTM Transmitter test command v3.
34+
35+
config BT_CTLR_DTM_HCI_TX_V4
36+
bool "HCI LE Transmitter Test v4"
37+
default y
38+
help
39+
Enable support for the DTM Transmitter test command v4.
40+
41+
menuconfig BT_CTLR_DTM_HCI_DF_IQ_REPORT
42+
bool "Connectionless IQ report HCI event [EXPERIMENTAL]"
43+
depends on BT_CTLR_DF_CTE_RX && BT_CTLR_DTM_HCI_RX_V3
44+
select EXPERIMENTAL
45+
help
46+
Enable generation of the HCI LE Connectionless IQ Report event
47+
after the Constant Tone Extension reception.
48+
49+
if BT_CTLR_DTM_HCI_DF_IQ_REPORT
50+
51+
config BT_CTLR_DTM_HCI_DF_IQ_REPORT_NUM_MAX
52+
int "IQ Report pool size"
53+
default 32
54+
help
55+
Maximum number of the DTM IQ Reports in pool. It depends on the upper tester
56+
test packets transmission interval.
57+
58+
59+
endif # BT_CTLR_DTM_HCI_DF_IQ_REPORT
60+
61+
endif # BT_CTLR_DTM_HCI

0 commit comments

Comments
 (0)