[PATCH BlueZ 01/31] monitor: Add LE Enhanced Receiver Test decoding

Michał Narajowski
2017-06-06T09:40:48Z

< HCI Command: LE Enhanced Receiver Test (0x08|0x0033) plen 3
RX channel: 0x01
PHY: LE 1M (0x01)
Modulation index: Stable (0x01)
---
monitor/bt.h | 7 +++++++
monitor/packet.c | 28 +++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index c2045bb..2aed400 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2161,6 +2161,13 @@ struct bt_hci_cmd_le_set_phy {
uint16_t phy_opts;
} __attribute__((packed));

+#define BT_HCI_CMD_LE_ENHANCED_RECEIVER_TEST 0x2033
+struct bt_hci_cmd_le_enhanced_receiver_test {
+ uint8_t rx_channel;
+ uint8_t phy;
+ uint8_t modulation_index;
+} __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 7d1c5e8..e3fcd2f 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6876,6 +6876,30 @@ static void le_set_phy_cmd(const void *data, uint8_t size)
print_field("PHY options preference: %s (0x%4.4x)", str, cmd->phy_opts);
}

+static void le_enhanced_receiver_test_cmd(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_enhanced_receiver_test *cmd = data;
+ const char *str;
+
+ print_field("RX channel frequency: %d MHz (0x%2.2x)",
+ (cmd->rx_channel * 2) + 2402, cmd->rx_channel);
+ print_le_phy("PHY", cmd->phy);
+
+ switch (cmd->modulation_index) {
+ case 0x00:
+ str = "Standard";
+ break;
+ case 0x01:
+ str = "Stable";
+ break;
+ default:
+ str = "Reserved";
+ break;
+ }
+
+ print_field("Modulation index: %s (0x%2.2x)", str, cmd->modulation_index);
+}
+
struct opcode_data {
uint16_t opcode;
int bit;
@@ -7579,7 +7603,9 @@ static const struct opcode_data opcode_table[] = {
status_rsp, 1, true },
{ 0x2032, 286, "LE Set PHY",
le_set_phy_cmd, 7, true},
- { 0x2033, 287, "LE Enhanced Receiver Test" },
+ { 0x2033, 287, "LE Enhanced Receiver Test",
+ le_enhanced_receiver_test_cmd, 3, true,
+ status_rsp, 1, true },
{ 0x2034, 288, "LE Enhanced Transmitter Test" },
{ 0x2035, 289, "LE Set Advertising Set Random Address" },
{ 0x2036, 290, "LE Set Extended Advertising Parameters" },
--
2.9.3