2017-04-12 12:13:32

by Łukasz Rymanowski

[permalink] [raw]
Subject: [PATCH BlueZ 1/5] monitor: Add description for filter in scan parameters

< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
Type: Active (0x01)
Interval: 30.000 msec (0x0030)
Window: 30.000 msec (0x0030)
Own address type: Public (0x00)
Filter policy: Accept all advertisement, inc. directed unresolved RPA (0x02)
---
monitor/packet.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index 5d927f5..219542e 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6309,6 +6309,12 @@ static void le_set_scan_parameters_cmd(const void *data, uint8_t size)
case 0x01:
str = "Ignore not in white list";
break;
+ case 0x02:
+ str = "Accept all advertisement, inc. directed unresolved RPA";
+ break;
+ case 0x03:
+ str = "Ignore not in white list, exc. directed unresolved RPA";
+ break;
default:
str = "Reserved";
break;
--
2.9.3



2017-04-12 12:13:36

by Łukasz Rymanowski

[permalink] [raw]
Subject: [PATCH BlueZ 5/5] monitor: Add LE PHY update complete event decoding

---
monitor/bt.h | 8 ++++++++
monitor/packet.c | 13 ++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index d9701a6..7b14649 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2763,6 +2763,14 @@ struct bt_hci_evt_le_direct_adv_report {
int8_t rssi;
} __attribute__ ((packed));

+#define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE 0x0c
+struct bt_hci_evt_le_phy_update_complete {
+ uint8_t status;
+ uint16_t handle;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+} __attribute__ ((packed));
+
#define BT_HCI_EVT_LE_CHAN_SELECT_ALG 0x14
struct bt_hci_evt_le_chan_select_alg {
uint16_t handle;
diff --git a/monitor/packet.c b/monitor/packet.c
index b3ca7c4..5a1ea10 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -8695,6 +8695,16 @@ static void le_direct_adv_report_evt(const void *data, uint8_t size)
packet_hexdump(data + sizeof(*evt), size - sizeof(*evt));
}

+static void le_phy_update_complete_evt(const void *data, uint8_t size)
+{
+ const struct bt_hci_evt_le_phy_update_complete *evt = data;
+
+ print_status(evt->status);
+ print_handle(evt->handle);
+ print_le_phy("TX PHY", evt->tx_phy);
+ print_le_phy("RX PHY", evt->rx_phy);
+}
+
static void le_chan_select_alg_evt(const void *data, uint8_t size)
{
const struct bt_hci_evt_le_chan_select_alg *evt = data;
@@ -8769,7 +8779,8 @@ static const struct subevent_data le_meta_event_table[] = {
le_enhanced_conn_complete_evt, 30, true },
{ 0x0b, "LE Direct Advertising Report",
le_direct_adv_report_evt, 1, false },
- { 0x0c, "LE PHY Update Complete" },
+ { 0x0c, "LE PHY Update Complete",
+ le_phy_update_complete_evt, 5, true},
{ 0x0d, "LE Extended Advertising Report" },
{ 0x0e, "LE Periodic Advertising Sync Established" },
{ 0x0f, "LE Periodic Advertising Report" },
--
2.9.3


2017-04-12 12:13:35

by Łukasz Rymanowski

[permalink] [raw]
Subject: [PATCH BlueZ 4/5] monitor: Add LE Set PHY decoding

< HCI Command: LE Set PHY (0x08|0x0032) plen 7
Handle: 1
All PHYs preference: 0x00
TX PHYs preference: 0x07
LE 1M
LE 2M
LE Coded
RX PHYs preference: 0x07
LE 1M
LE 2M
LE Coded
PHY options preference: S8 coding (0x02)
---
monitor/bt.h | 9 +++++++++
monitor/packet.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index 9dd726e..d9701a6 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2152,6 +2152,15 @@ struct bt_hci_cmd_le_set_default_phy {
uint8_t rx_phys;
} __attribute__((packed));

+#define BT_HCI_CMD_LE_SET_PHY 0x2032
+struct bt_hci_cmd_le_set_phy {
+ uint16_t handle;
+ uint8_t all_phys;
+ uint8_t tx_phys;
+ uint8_t rx_phys;
+ uint8_t phy_opts;
+} __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 f8b42ac..b3ca7c4 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6795,16 +6795,16 @@ static const struct {
{ }
};

-static void le_set_default_phy_cmd(const void *data, uint8_t size)
+static void print_le_phys_preference(uint8_t all_phys, uint8_t tx_phys,
+ uint8_t rx_phys)
{
- const struct bt_hci_cmd_le_set_default_phy *cmd = data;
int i;
- uint8_t mask = cmd->all_phys;
+ uint8_t mask = all_phys;

- print_field("All PHYs preference: 0x%2.2x", cmd->all_phys);
+ print_field("All PHYs preference: 0x%2.2x", all_phys);

for (i = 0; le_phy_preference[i].str; i++) {
- if (cmd->all_phys & (((uint8_t) 1) << le_phy_preference[i].bit)) {
+ if (all_phys & (((uint8_t) 1) << le_phy_preference[i].bit)) {
print_field(" %s", le_phy_preference[i].str);
mask &= ~(((uint64_t) 1) << le_phy_preference[i].bit);
}
@@ -6814,11 +6814,11 @@ static void le_set_default_phy_cmd(const void *data, uint8_t size)
print_text(COLOR_UNKNOWN_OPTIONS_BIT, " Reserved"
" (0x%2.2x)", mask);

- print_field("TX PHYs preference: 0x%2.2x", cmd->tx_phys);
- mask = cmd->tx_phys;
+ print_field("TX PHYs preference: 0x%2.2x", tx_phys);
+ mask = tx_phys;

for (i = 0; le_phys[i].str; i++) {
- if (cmd->tx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
+ if (tx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
print_field(" %s", le_phys[i].str);
mask &= ~(((uint64_t) 1) << le_phys[i].bit);
}
@@ -6828,11 +6828,11 @@ static void le_set_default_phy_cmd(const void *data, uint8_t size)
print_text(COLOR_UNKNOWN_OPTIONS_BIT, " Reserved"
" (0x%2.2x)", mask);

- print_field("RX PHYs preference: 0x%2.2x", cmd->rx_phys);
- mask = cmd->rx_phys;
+ print_field("RX PHYs preference: 0x%2.2x", rx_phys);
+ mask = rx_phys;

for (i = 0; le_phys[i].str; i++) {
- if (cmd->rx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
+ if (rx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
print_field(" %s", le_phys[i].str);
mask &= ~(((uint64_t) 1) << le_phys[i].bit);
}
@@ -6843,6 +6843,35 @@ static void le_set_default_phy_cmd(const void *data, uint8_t size)
" (0x%2.2x)", mask);
}

+static void le_set_default_phy_cmd(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_set_default_phy *cmd = data;
+
+ print_le_phys_preference(cmd->all_phys, cmd->tx_phys, cmd->rx_phys);
+}
+
+static void le_set_phy_cmd(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_set_phy *cmd = data;
+ const char *str;
+
+ print_handle(cmd->handle);
+ print_le_phys_preference(cmd->all_phys, cmd->tx_phys, cmd->rx_phys);
+ switch (cmd->phy_opts) {
+ case 0x01:
+ str = "S2 coding";
+ break;
+ case 0x02:
+ str = "S8 coding";
+ break;
+ default:
+ str = "Reserved";
+ break;
+ }
+
+ print_field("PHY options preference: %s (0x%2.2x)", str, cmd->phy_opts);
+}
+
struct opcode_data {
uint16_t opcode;
int bit;
@@ -7543,7 +7572,8 @@ static const struct opcode_data opcode_table[] = {
le_read_phy_rsp, 5, true},
{ 0x2031, 285, "LE Set Default PHY",
le_set_default_phy_cmd, 3, true},
- { 0x2032, 286, "LE Set PHY" },
+ { 0x2032, 286, "LE Set PHY",
+ le_set_phy_cmd, 7, true},
{ 0x2033, 287, "LE Enhanced Receiver Test" },
{ 0x2034, 288, "LE Enhanced Transmitter Test" },
{ 0x2035, 289, "LE Set Advertising Set Random Address" },
--
2.9.3


2017-04-12 12:13:34

by Łukasz Rymanowski

[permalink] [raw]
Subject: [PATCH BlueZ 3/5] monitor: Add LE Set default PHY decoding

< HCI Command: LE Set Default PHY (0x08|0x0031) plen 3
All PHYs preference: 0x00
TX PHYs preference: 0x07
LE 1M
LE 2M
LE Coded
RX PHYs preference: 0x0e
LE 2M
LE Coded
Reserved (0x08)

< HCI Command: LE Set Default PHY (0x08|0x0031) plen 3
All PHYs preference: 0x03
No TX PHY preference
No RX PHY preference
TX PHYs preference: 0x00
RX PHYs preference: 0x00
---
monitor/bt.h | 7 ++++++
monitor/packet.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index a6c12a3..9dd726e 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2145,6 +2145,13 @@ struct bt_hci_rsp_le_read_phy {
uint8_t rx_phy;
} __attribute__((packed));

+#define BT_HCI_CMD_LE_SET_DEFAULT_PHY 0x2031
+struct bt_hci_cmd_le_set_default_phy {
+ uint8_t all_phys;
+ uint8_t tx_phys;
+ uint8_t rx_phys;
+} __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 673b571..f8b42ac 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6776,6 +6776,73 @@ static void le_read_phy_rsp(const void *data, uint8_t size)
print_le_phy("RX PHY", rsp->rx_phy);
}

+static const struct {
+ uint8_t bit;
+ const char *str;
+} le_phys[] = {
+ { 0, "LE 1M" },
+ { 1, "LE 2M" },
+ { 2, "LE Coded"},
+ { }
+};
+
+static const struct {
+ uint8_t bit;
+ const char *str;
+} le_phy_preference[] = {
+ { 0, "No TX PHY preference" },
+ { 1, "No RX PHY preference" },
+ { }
+};
+
+static void le_set_default_phy_cmd(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_set_default_phy *cmd = data;
+ int i;
+ uint8_t mask = cmd->all_phys;
+
+ print_field("All PHYs preference: 0x%2.2x", cmd->all_phys);
+
+ for (i = 0; le_phy_preference[i].str; i++) {
+ if (cmd->all_phys & (((uint8_t) 1) << le_phy_preference[i].bit)) {
+ print_field(" %s", le_phy_preference[i].str);
+ mask &= ~(((uint64_t) 1) << le_phy_preference[i].bit);
+ }
+ }
+
+ if (mask)
+ print_text(COLOR_UNKNOWN_OPTIONS_BIT, " Reserved"
+ " (0x%2.2x)", mask);
+
+ print_field("TX PHYs preference: 0x%2.2x", cmd->tx_phys);
+ mask = cmd->tx_phys;
+
+ for (i = 0; le_phys[i].str; i++) {
+ if (cmd->tx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
+ print_field(" %s", le_phys[i].str);
+ mask &= ~(((uint64_t) 1) << le_phys[i].bit);
+ }
+ }
+
+ if (mask)
+ print_text(COLOR_UNKNOWN_OPTIONS_BIT, " Reserved"
+ " (0x%2.2x)", mask);
+
+ print_field("RX PHYs preference: 0x%2.2x", cmd->rx_phys);
+ mask = cmd->rx_phys;
+
+ for (i = 0; le_phys[i].str; i++) {
+ if (cmd->rx_phys & (((uint8_t) 1) << le_phys[i].bit)) {
+ print_field(" %s", le_phys[i].str);
+ mask &= ~(((uint64_t) 1) << le_phys[i].bit);
+ }
+ }
+
+ if (mask)
+ print_text(COLOR_UNKNOWN_OPTIONS_BIT, " Reserved"
+ " (0x%2.2x)", mask);
+}
+
struct opcode_data {
uint16_t opcode;
int bit;
@@ -7474,7 +7541,8 @@ static const struct opcode_data opcode_table[] = {
{ 0x2030, 284, "LE Read PHY",
le_read_phy_cmd, 2, true,
le_read_phy_rsp, 5, true},
- { 0x2031, 285, "LE Set Default PHY" },
+ { 0x2031, 285, "LE Set Default PHY",
+ le_set_default_phy_cmd, 3, true},
{ 0x2032, 286, "LE Set PHY" },
{ 0x2033, 287, "LE Enhanced Receiver Test" },
{ 0x2034, 288, "LE Enhanced Transmitter Test" },
--
2.9.3


2017-04-12 12:13:33

by Łukasz Rymanowski

[permalink] [raw]
Subject: [PATCH BlueZ 2/5] monitor: Add LE Read PHY decoding

---
monitor/bt.h | 11 +++++++++++
monitor/packet.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index 0b77a10..a6c12a3 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -2134,6 +2134,17 @@ struct bt_hci_rsp_le_read_max_data_length {
uint16_t max_rx_time;
} __attribute__ ((packed));

+#define BT_HCI_CMD_LE_READ_PHY 0x2030
+struct bt_hci_cmd_le_read_phy {
+ uint16_t handle;
+} __attribute__((packed));
+struct bt_hci_rsp_le_read_phy {
+ uint8_t status;
+ uint16_t handle;
+ uint8_t tx_phy;
+ uint8_t rx_phy;
+} __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 219542e..673b571 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6737,6 +6737,45 @@ static void le_read_max_data_length_rsp(const void *data, uint8_t size)
print_field("Max RX time: %d", le16_to_cpu(rsp->max_rx_time));
}

+static void le_read_phy_cmd(const void *data, uint8_t size)
+{
+ const struct bt_hci_cmd_le_read_phy *cmd = data;
+
+ print_handle(cmd->handle);
+}
+
+static void print_le_phy(const char *prefix, uint8_t phy)
+{
+ const char *str;
+
+ switch (phy) {
+ case 0x01:
+ str = "LE 1M";
+ break;
+ case 0x02:
+ str = "LE 2M";
+ break;
+ case 0x03:
+ str = "LE Coded";
+ break;
+ default:
+ str = "Reserved";
+ break;
+ }
+
+ print_field("%s: %s (0x%2.2x)", prefix, str, phy);
+}
+
+static void le_read_phy_rsp(const void *data, uint8_t size)
+{
+ const struct bt_hci_rsp_le_read_phy *rsp = data;
+
+ print_status(rsp->status);
+ print_handle(rsp->handle);
+ print_le_phy("TX PHY", rsp->tx_phy);
+ print_le_phy("RX PHY", rsp->rx_phy);
+}
+
struct opcode_data {
uint16_t opcode;
int bit;
@@ -7432,7 +7471,9 @@ static const struct opcode_data opcode_table[] = {
{ 0x202f, 283, "LE Read Maximum Data Length",
null_cmd, 0, true,
le_read_max_data_length_rsp, 9, true },
- { 0x2030, 284, "LE Read PHY" },
+ { 0x2030, 284, "LE Read PHY",
+ le_read_phy_cmd, 2, true,
+ le_read_phy_rsp, 5, true},
{ 0x2031, 285, "LE Set Default PHY" },
{ 0x2032, 286, "LE Set PHY" },
{ 0x2033, 287, "LE Enhanced Receiver Test" },
--
2.9.3