Skip to content

Commit f9383ae

Browse files
ivaniushkovrlubos
authored andcommitted
samples: bluetooth: direct_test_mode: fix CTE TX bug
1. Fixed a bug where DTM sample returns COMMAND DISALLOWED error when CTE is used. The Bluetooth Core Specification mandates returning COMMAND DISALLOWED when: `CTE_Length is not zero and PHY specifies a PHY that does not allow Constant Tone Extensions` In other words, the commands should be disallowed when coded PHY is used, because Coded PHY doesn't allow CTE. 2. Fixed an invalid content of CTE PDU 3. Fixed a bug when dtm_setup_set_antenna_params() would call when CTE TX is used Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
1 parent aaa53bf commit f9383ae

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

samples/bluetooth/direct_test_mode/src/dtm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2163,23 +2163,25 @@ int dtm_setup_set_cte_mode(enum dtm_cte_type type, uint8_t time)
21632163
switch (type) {
21642164
case DTM_CTE_TYPE_AOA:
21652165
dtm_inst.cte_info.mode = DTM_CTE_MODE_AOA;
2166+
cte_info |= ((0 & CTEINFO_TYPE_MASK) << CTEINFO_TYPE_POS);
21662167
break;
21672168

21682169
case DTM_CTE_TYPE_AOD_1US:
21692170
dtm_inst.cte_info.mode = DTM_CTE_MODE_AOD;
21702171
dtm_inst.cte_info.slot = DTM_CTE_SLOT_1US;
2172+
cte_info |= ((1 & CTEINFO_TYPE_MASK) << CTEINFO_TYPE_POS);
21712173
break;
21722174

21732175
case DTM_CTE_TYPE_AOD_2US:
21742176
dtm_inst.cte_info.mode = DTM_CTE_MODE_AOD;
21752177
dtm_inst.cte_info.slot = DTM_CTE_SLOT_2US;
2178+
cte_info |= ((2 & CTEINFO_TYPE_MASK) << CTEINFO_TYPE_POS);
21762179
break;
21772180

21782181
default:
21792182
return -EINVAL;
21802183
}
21812184

2182-
cte_info |= ((dtm_inst.cte_info.mode & CTEINFO_TYPE_MASK) << CTEINFO_TYPE_POS);
21832185
dtm_inst.cte_info.info = cte_info;
21842186

21852187
return 0;

samples/bluetooth/direct_test_mode/src/transport/dtm_hci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ static int cte_set(uint8_t cte_len, uint8_t cte_type,
171171

172172
switch (cte_type) {
173173
case BT_HCI_LE_AOA_CTE:
174-
err = dtm_setup_set_cte_mode(DTM_CTE_TYPE_AOA, cte_len);
175-
break;
174+
return dtm_setup_set_cte_mode(DTM_CTE_TYPE_AOA, cte_len);
176175

177176
case BT_HCI_LE_AOD_CTE_1US:
178177
err = dtm_setup_set_cte_mode(DTM_CTE_TYPE_AOD_1US, cte_len);
@@ -624,7 +623,7 @@ static int hci_tx_test(uint16_t opcode, const uint8_t *data)
624623
}
625624

626625
if ((cte_len != 0) &&
627-
(phy != BT_HCI_LE_TX_PHY_CODED_S8) && (phy != BT_HCI_LE_TX_PHY_CODED_S2)) {
626+
((phy == BT_HCI_LE_TX_PHY_CODED_S8) || (phy == BT_HCI_LE_TX_PHY_CODED_S2))) {
628627
return base_cc_evt(opcode, BT_HCI_ERR_CMD_DISALLOWED);
629628
}
630629

0 commit comments

Comments
 (0)