summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-02-28 10:47:49 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-03-07 09:37:14 +0200
commit1c5b832c0fe686da559449ef64c336678d964725 (patch)
tree2c87b25717cad3775c6e8ae4331be9b05bb3f85f
parent3d5e41fc6f449504238f26d084d2d6fc38ab3da0 (diff)
downloadbluez-1c5b832c0fe686da559449ef64c336678d964725.tar.gz
monitor: Add decoding for HCI LE Transmitter Test command [v3]
This decodes LE Transmitter Test command [v3] introduced in 5.1.
-rw-r--r--monitor/bt.h13
-rw-r--r--monitor/packet.c68
2 files changed, 81 insertions, 0 deletions
diff --git a/monitor/bt.h b/monitor/bt.h
index f25646f41..d32d3a153 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2448,6 +2448,19 @@ struct bt_hci_cmd_le_receiver_test_v3 {
uint8_t antenna_ids[0];
} __attribute__ ((packed));
+#define BT_HCI_CMD_LE_TX_TEST_V3 0x2050
+struct bt_hci_cmd_le_tx_test_v3 {
+ uint8_t chan;
+ uint8_t data_len;
+ uint8_t payload;
+ uint8_t phy;
+ 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 64cb1045d..fa0ea36b0 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -7470,6 +7470,71 @@ static void le_receiver_test_cmd_v3(const void *data, uint8_t size)
print_field(" Antenna ID: %u", cmd->antenna_ids[i]);
}
+static const char *parse_tx_test_payload(uint8_t payload)
+{
+ switch (payload) {
+ case 0x00:
+ return "PRBS9 sequence 11111111100000111101...";
+ case 0x01:
+ return "Repeated 11110000";
+ case 0x02:
+ return "Repeated 10101010";
+ case 0x03:
+ return "PRBS15";
+ case 0x04:
+ return "Repeated 11111111";
+ case 0x05:
+ return "Repeated 00000000";
+ case 0x06:
+ return "Repeated 00001111";
+ case 0x07:
+ return "Repeated 01010101";
+ default:
+ return "Reserved";
+ }
+}
+
+static void le_tx_test_cmd_v3(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_tx_test_v3 *cmd = data;
+ uint8_t i;
+
+ print_field("TX Channel: %u MHz (0x%2.2x)", cmd->chan * 2 + 2402,
+ cmd->chan);
+ print_field("Length of Test Data: %u", cmd->data_len);
+ print_field("Packet Payload: %s (0x%2.2x)",
+ parse_tx_test_payload(cmd->payload), cmd->payload);
+
+ 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 with S=8 (0x%2.2x)", cmd->phy);
+ break;
+ case 0x04:
+ print_field("PHY: LE Coded with S=2 (0x%2.2x)", cmd->phy);
+ break;
+ }
+
+ 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;
@@ -8260,6 +8325,9 @@ static const struct opcode_data opcode_table[] = {
{ 0x204f, 315, "LE Receiver Test command [v3]",
le_receiver_test_cmd_v3, 7, false,
status_rsp, 1, true },
+ { 0x2050, 316, "LE Transmitter Test command [v3]",
+ le_tx_test_cmd_v3, 9, false,
+ status_rsp, 1, true },
{ }
};