|
27 | 27 | #include "ll.h"
|
28 | 28 | #include "hci_internal.h"
|
29 | 29 |
|
| 30 | +#if defined(CONFIG_BT_CTLR_DTM_HCI) |
| 31 | +#include "ll_sw/ll_test.h" |
| 32 | +#endif /* CONFIG_BT_CTLR_DTM_HCI */ |
| 33 | + |
30 | 34 | #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
|
31 | 35 | #include "common/log.h"
|
32 | 36 | #include "hal/debug.h"
|
@@ -503,6 +507,14 @@ static void read_supported_commands(struct net_buf *buf, struct net_buf **evt)
|
503 | 507 | rp->commands[28] |= BIT(1) | BIT(2);
|
504 | 508 | #endif /* CONFIG_BT_CTLR_LE_ENC */
|
505 | 509 | #endif
|
| 510 | +#if defined(CONFIG_BT_CTLR_DTM_HCI) |
| 511 | + /* LE RX Test, LE TX Test, LE Test End */ |
| 512 | + rp->commands[28] |= BIT(4) | BIT(5) | BIT(6); |
| 513 | + /* LE Enhanced RX Test. */ |
| 514 | + rp->commands[35] |= BIT(7); |
| 515 | + /* LE Enhanced TX Test. */ |
| 516 | + rp->commands[36] |= BIT(0); |
| 517 | +#endif /* CONFIG_BT_CTLR_DTM_HCI */ |
506 | 518 | #if defined(CONFIG_BT_CONN)
|
507 | 519 | /* Disconnect. */
|
508 | 520 | rp->commands[0] |= BIT(5);
|
@@ -1343,6 +1355,70 @@ static void le_read_tx_power(struct net_buf *buf, struct net_buf **evt)
|
1343 | 1355 | ll_tx_power_get(&rp->min_tx_power, &rp->max_tx_power);
|
1344 | 1356 | }
|
1345 | 1357 |
|
| 1358 | +#if defined(CONFIG_BT_CTLR_DTM_HCI) |
| 1359 | +static void le_rx_test(struct net_buf *buf, struct net_buf **evt) |
| 1360 | +{ |
| 1361 | + struct bt_hci_cp_le_rx_test *cmd = (void *)buf->data; |
| 1362 | + struct bt_hci_evt_cc_status *ccst; |
| 1363 | + u32_t status; |
| 1364 | + |
| 1365 | + status = ll_test_rx(cmd->rx_ch, 0x01, 0); |
| 1366 | + |
| 1367 | + ccst = cmd_complete(evt, sizeof(*ccst)); |
| 1368 | + ccst->status = status; |
| 1369 | +} |
| 1370 | + |
| 1371 | +static void le_tx_test(struct net_buf *buf, struct net_buf **evt) |
| 1372 | +{ |
| 1373 | + struct bt_hci_cp_le_tx_test *cmd = (void *)buf->data; |
| 1374 | + struct bt_hci_evt_cc_status *ccst; |
| 1375 | + u32_t status; |
| 1376 | + |
| 1377 | + status = ll_test_tx(cmd->tx_ch, cmd->test_data_len, cmd->pkt_payload, |
| 1378 | + 0x01); |
| 1379 | + |
| 1380 | + ccst = cmd_complete(evt, sizeof(*ccst)); |
| 1381 | + ccst->status = status; |
| 1382 | +} |
| 1383 | + |
| 1384 | +static void le_test_end(struct net_buf *buf, struct net_buf **evt) |
| 1385 | +{ |
| 1386 | + struct bt_hci_rp_le_test_end *rp; |
| 1387 | + u16_t rx_pkt_count; |
| 1388 | + |
| 1389 | + ll_test_end(&rx_pkt_count); |
| 1390 | + |
| 1391 | + rp = cmd_complete(evt, sizeof(*rp)); |
| 1392 | + rp->status = 0x00; |
| 1393 | + rp->rx_pkt_count = sys_cpu_to_le16(rx_pkt_count); |
| 1394 | +} |
| 1395 | + |
| 1396 | +static void le_enh_rx_test(struct net_buf *buf, struct net_buf **evt) |
| 1397 | +{ |
| 1398 | + struct bt_hci_cp_le_enh_rx_test *cmd = (void *)buf->data; |
| 1399 | + struct bt_hci_evt_cc_status *ccst; |
| 1400 | + u32_t status; |
| 1401 | + |
| 1402 | + status = ll_test_rx(cmd->rx_ch, cmd->phy, cmd->mod_index); |
| 1403 | + |
| 1404 | + ccst = cmd_complete(evt, sizeof(*ccst)); |
| 1405 | + ccst->status = status; |
| 1406 | +} |
| 1407 | + |
| 1408 | +static void le_enh_tx_test(struct net_buf *buf, struct net_buf **evt) |
| 1409 | +{ |
| 1410 | + struct bt_hci_cp_le_enh_tx_test *cmd = (void *)buf->data; |
| 1411 | + struct bt_hci_evt_cc_status *ccst; |
| 1412 | + u32_t status; |
| 1413 | + |
| 1414 | + status = ll_test_tx(cmd->tx_ch, cmd->test_data_len, cmd->pkt_payload, |
| 1415 | + cmd->phy); |
| 1416 | + |
| 1417 | + ccst = cmd_complete(evt, sizeof(*ccst)); |
| 1418 | + ccst->status = status; |
| 1419 | +} |
| 1420 | +#endif /* CONFIG_BT_CTLR_DTM_HCI */ |
| 1421 | + |
1346 | 1422 | static int controller_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
1347 | 1423 | struct net_buf **evt)
|
1348 | 1424 | {
|
@@ -1543,6 +1619,24 @@ static int controller_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
1543 | 1619 | le_read_tx_power(cmd, evt);
|
1544 | 1620 | break;
|
1545 | 1621 |
|
| 1622 | +#if defined(CONFIG_BT_CTLR_DTM_HCI) |
| 1623 | + case BT_OCF(BT_HCI_OP_LE_RX_TEST): |
| 1624 | + le_rx_test(cmd, evt); |
| 1625 | + break; |
| 1626 | + case BT_OCF(BT_HCI_OP_LE_TX_TEST): |
| 1627 | + le_tx_test(cmd, evt); |
| 1628 | + break; |
| 1629 | + case BT_OCF(BT_HCI_OP_LE_TEST_END): |
| 1630 | + le_test_end(cmd, evt); |
| 1631 | + break; |
| 1632 | + case BT_OCF(BT_HCI_OP_LE_ENH_RX_TEST): |
| 1633 | + le_enh_rx_test(cmd, evt); |
| 1634 | + break; |
| 1635 | + case BT_OCF(BT_HCI_OP_LE_ENH_TX_TEST): |
| 1636 | + le_enh_tx_test(cmd, evt); |
| 1637 | + break; |
| 1638 | +#endif /* CONFIG_BT_CTLR_DTM_HCI */ |
| 1639 | + |
1546 | 1640 | default:
|
1547 | 1641 | return -EINVAL;
|
1548 | 1642 | }
|
|
0 commit comments