All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Łukasz Rymanowski" <lukasz.rymanowski@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Cc: "Łukasz Rymanowski" <lukasz.rymanowski@codecoup.pl>
Subject: [PATCH BlueZ 4/5] monitor: Add LE Set PHY decoding
Date: Wed, 12 Apr 2017 14:13:35 +0200	[thread overview]
Message-ID: <20170412121336.783-4-lukasz.rymanowski@codecoup.pl> (raw)
In-Reply-To: <20170412121336.783-1-lukasz.rymanowski@codecoup.pl>

< 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


  parent reply	other threads:[~2017-04-12 12:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 12:13 [PATCH BlueZ 1/5] monitor: Add description for filter in scan parameters Łukasz Rymanowski
2017-04-12 12:13 ` [PATCH BlueZ 2/5] monitor: Add LE Read PHY decoding Łukasz Rymanowski
2017-04-12 12:13 ` [PATCH BlueZ 3/5] monitor: Add LE Set default " Łukasz Rymanowski
2017-04-12 12:13 ` Łukasz Rymanowski [this message]
2017-04-12 12:13 ` [PATCH BlueZ 5/5] monitor: Add LE PHY update complete event decoding Łukasz Rymanowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170412121336.783-4-lukasz.rymanowski@codecoup.pl \
    --to=lukasz.rymanowski@codecoup.pl \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.