From 3d5e41fc6f449504238f26d084d2d6fc38ab3da0 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 27 Feb 2019 16:35:44 +0200 Subject: [PATCH] monitor: Add decoding for HCI LE Receiver Test command [v3] This decodes LE Receiver Test command [v3] introduced in 5.1. --- monitor/bt.h | 12 ++++++++++++ monitor/packet.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/monitor/bt.h b/monitor/bt.h index af17c1f82..f25646f41 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -2436,6 +2436,18 @@ struct bt_hci_cmd_le_set_priv_mode { uint8_t priv_mode; } __attribute__ ((packed)); +#define BT_HCI_CMD_LE_RECEIVER_TEST_V3 0x204f +struct bt_hci_cmd_le_receiver_test_v3 { + uint8_t rx_chan; + uint8_t phy; + uint8_t mod_index; + uint8_t cte_len; + uint8_t cte_type; + uint8_t duration; + uint8_t num_antenna_id; + uint8_t antenna_ids[0]; +} __attribute__ ((packed)); + #define BT_HCI_EVT_INQUIRY_COMPLETE 0x01 struct bt_hci_evt_inquiry_complete { uint8_t status; diff --git a/monitor/packet.c b/monitor/packet.c index 96cacddd5..64cb1045d 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -7433,6 +7433,43 @@ static void le_set_priv_mode_cmd(const void *data, uint8_t size) print_field("Privacy Mode: %s (0x%2.2x)", str, cmd->priv_mode); } +static void le_receiver_test_cmd_v3(const void *data, uint8_t size) +{ + const struct bt_hci_cmd_le_receiver_test_v3 *cmd = data; + uint8_t i; + + print_field("RX Channel: %u MHz (0x%2.2x)", cmd->rx_chan * 2 + 2402, + cmd->rx_chan); + + switch (cmd->phy) { + case 0x01: + print_field("PHY: LE 1M (0x%2.2x)", cmd->phy); + break; + case 0x02: + print_field("PHY: LE 2M (0x%2.2x)", cmd->phy); + break; + case 0x03: + print_field("PHY: LE Coded (0x%2.2x)", cmd->phy); + break; + } + + print_field("Modulation Index: %s (0x%2.2x)", + cmd->mod_index ? "stable" : "standard", cmd->mod_index); + print_field("Expected CTE Length: %u us (0x%2.2x)", cmd->cte_len * 8, + cmd->cte_len); + print_field("Expected CTE Type: %u us slots (0x%2.2x)", cmd->cte_type, + cmd->cte_type); + print_field("Slot Duration: %u us (0x%2.2x)", cmd->duration, + cmd->duration); + print_field("Number of Antenna IDs: %u", cmd->num_antenna_id); + + if (size < sizeof(*cmd) + cmd->num_antenna_id) + return; + + for (i = 0; i < cmd->num_antenna_id; i++) + print_field(" Antenna ID: %u", cmd->antenna_ids[i]); +} + struct opcode_data { uint16_t opcode; int bit; @@ -8220,6 +8257,9 @@ static const struct opcode_data opcode_table[] = { { 0x204e, 314, "LE Set Privacy Mode", le_set_priv_mode_cmd, 8, true, status_rsp, 1, true }, + { 0x204f, 315, "LE Receiver Test command [v3]", + le_receiver_test_cmd_v3, 7, false, + status_rsp, 1, true }, { } }; -- 2.47.3