nimble/ll: Disallow HCI commands if DTM test is enabled

If DTM is enabled we should not allow for other activities. To keep
things simple just disallow all commands except LE Test End and Reset.
This commit is contained in:
Szymon Janc
2022-11-02 15:24:00 +01:00
parent 5a9b202a0d
commit ae414aa597
3 changed files with 24 additions and 1 deletions
+6
View File
@@ -705,6 +705,12 @@ ble_ll_dtm_reset(void)
ble_ll_dtm_ctx_free(&g_ble_ll_dtm_ctx);
}
int
ble_ll_dtm_enabled(void)
{
return g_ble_ll_dtm_ctx.active;
}
void
ble_ll_dtm_init(void)
{
+1
View File
@@ -37,4 +37,5 @@ int ble_ll_dtm_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr);
void ble_ll_dtm_rx_pkt_in(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr);
void ble_ll_dtm_wfr_timer_exp(void);
void ble_ll_dtm_reset(void);
int ble_ll_dtm_enabled(void);
#endif
+17 -1
View File
@@ -1756,6 +1756,22 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
/* Assume response length is zero */
rsplen = 0;
#if MYNEWT_VAL(BLE_LL_DTM)
/* if DTM test is enabled disallow any command other than LE Test End or
* HCI Reset
*/
if (ble_ll_dtm_enabled()) {
switch (opcode) {
case BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_TEST_END):
case BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET):
break;
default:
rc = BLE_ERR_CMD_DISALLOWED;
goto send_cc_cs;
}
}
#endif
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE)
rc = ble_ll_hci_cmd_fake_dual_mode(opcode, cmd->data, cmd->length,
rspbuf, &rsplen);
@@ -1798,7 +1814,7 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
rc += (BLE_ERR_MAX + 1);
}
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE)
#if MYNEWT_VAL(BLE_LL_HBD_FAKE_DUAL_MODE) || MYNEWT_VAL(BLE_LL_DTM)
send_cc_cs:
#endif
/* If no response is generated, we free the buffers */