From: Jaganath Kanakkassery <jaganath.k.os@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org,
	Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Subject: [PATCH BlueZ 2/8] btmgmt: Add BREDR PHYs in PHY Configuration commands
Date: Fri,  6 Jul 2018 16:57:59 +0530	[thread overview]
Message-ID: <1530876485-17218-3-git-send-email-jaganathx.kanakkassery@intel.com> (raw)
In-Reply-To: <1530876485-17218-1-git-send-email-jaganathx.kanakkassery@intel.com>
---
 lib/mgmt.h     | 32 +++++++++++++++++++-----------
 tools/btmgmt.c | 62 ++++++++++++++++++++++++++++------------------------------
 2 files changed, 51 insertions(+), 43 deletions(-)
diff --git a/lib/mgmt.h b/lib/mgmt.h
index ec6a380..570dec9 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
 
 #define MGMT_OP_GET_PHY_CONFIGURATION	0x0044
 struct mgmt_rp_get_phy_confguration {
-	uint16_t	supported_phys;
-	uint16_t	selected_phys;
-} __packed;
-
-#define MGMT_PHY_LE_1M_TX		0x0001
-#define MGMT_PHY_LE_1M_RX		0x0002
-#define MGMT_PHY_LE_2M_TX		0x0004
-#define MGMT_PHY_LE_2M_RX		0x0008
-#define MGMT_PHY_LE_CODED_TX		0x0010
-#define MGMT_PHY_LE_CODED_RX		0x0020
+	uint32_t	supported_phys;
+	uint32_t	configurable_phys;
+	uint32_t	selected_phys;
+} __packed;
+
+#define MGMT_PHY_BR_1M_1SLOT	0x00000001
+#define MGMT_PHY_BR_1M_3SLOT	0x00000002
+#define MGMT_PHY_BR_1M_5SLOT	0x00000004
+#define MGMT_PHY_EDR_2M_1SLOT	0x00000008
+#define MGMT_PHY_EDR_2M_3SLOT	0x00000010
+#define MGMT_PHY_EDR_2M_5SLOT	0x00000020
+#define MGMT_PHY_EDR_3M_1SLOT	0x00000040
+#define MGMT_PHY_EDR_3M_3SLOT	0x00000080
+#define MGMT_PHY_EDR_3M_5SLOT	0x00000100
+#define MGMT_PHY_LE_1M_TX		0x00000200
+#define MGMT_PHY_LE_1M_RX		0x00000400
+#define MGMT_PHY_LE_2M_TX		0x00000800
+#define MGMT_PHY_LE_2M_RX		0x00001000
+#define MGMT_PHY_LE_CODED_TX	0x00002000
+#define MGMT_PHY_LE_CODED_RX	0x00004000
 
 #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
 			     MGMT_PHY_LE_CODED_TX)
@@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
 
 #define MGMT_OP_SET_PHY_CONFIGURATION	0x0045
 struct mgmt_cp_set_phy_confguration {
-	uint16_t	default_phys;
+	uint32_t	selected_phys;
 } __packed;
 
 
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index f5bef63..9dc6712 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
 }
 
 static const char *phys_str[] = {
-	"1MTX",
-	"1MRX",
-	"2MTX",
-	"2MRX",
-	"CODEDTX",
-	"CODEDRX",
+	"BR_1M_1SLOT",
+	"BR_1M_3SLOT",
+	"BR_1M_5SLOT",
+	"EDR_2M_1SLOT",
+	"EDR_2M_3SLOT",
+	"EDR_2M_5SLOT",
+	"EDR_3M_1SLOT",
+	"EDR_3M_3SLOT",
+	"EDR_3M_5SLOT",
+	"LE_1M_TX",
+	"LE_1M_RX",
+	"LE_2M_TX",
+	"LE_2M_RX",
+	"LE_CODED_TX",
+	"LE_CODED_RX",
 };
 
-static const char *phys2str(uint16_t phys)
+static const char *phys2str(uint32_t phys)
 {
 	static char str[256];
 	unsigned int i;
@@ -4211,7 +4220,7 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
 							void *user_data)
 {
 	const struct mgmt_rp_get_phy_confguration *rp = param;
-	uint16_t supported_flags, selected_phys;
+	uint32_t supported_phys, selected_phys, configurable_phys;
 
 	if (status != 0) {
 		error("Get PHY Configuration failed with status 0x%02x (%s)",
@@ -4224,10 +4233,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
 		return bt_shell_noninteractive_quit(EXIT_FAILURE);
 	}
 
-	supported_flags = get_le16(&rp->supported_phys);
-	selected_phys = get_le16(&rp->selected_phys);
+	supported_phys = get_le32(&rp->supported_phys);
+	configurable_phys = get_le32(&rp->configurable_phys);
+	selected_phys = get_le32(&rp->selected_phys);
 
-	print("Supported phys: %s", phys2str(supported_flags));
+	print("Supported phys: %s", phys2str(supported_phys));
+	print("Configurable phys: %s", phys2str(configurable_phys));
 	print("Selected phys: %s", phys2str(selected_phys));
 
 	bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -4265,34 +4276,21 @@ static void set_phy_rsp(uint8_t status, uint16_t len, const void *param,
 static void cmd_phy(int argc, char **argv)
 {
 	struct mgmt_cp_set_phy_confguration cp;
-	int i;
-	uint16_t phys = 0;
+	int i, j;
+	uint32_t phys = 0;
 	uint16_t index;
 
 	if (argc < 2)
 		return get_phy();
 
 	for (i = 1; i < argc; i++) {
-		if (strcasecmp(argv[i], "1MTX") == 0)
-			phys |= MGMT_PHY_LE_1M_TX;
-
-		if (strcasecmp(argv[i], "1MRX") == 0)
-			phys |= MGMT_PHY_LE_1M_RX;
-
-		if (strcasecmp(argv[i], "2MTX") == 0)
-			phys |= MGMT_PHY_LE_2M_TX;
-
-		if (strcasecmp(argv[i], "2MRX") == 0)
-			phys |= MGMT_PHY_LE_2M_RX;
-
-		if (strcasecmp(argv[i], "CODEDTX") == 0)
-			phys |= MGMT_PHY_LE_CODED_TX;
-
-		if (strcasecmp(argv[i], "CODEDRX") == 0)
-			phys |= MGMT_PHY_LE_CODED_RX;
+		for (j = 0; j < NELEM(phys_str); j++) {
+			if (strcasecmp(argv[i], phys_str[j]) == 0)
+				phys |= (1 << j);
+		}
 	}
 
-	cp.default_phys = cpu_to_le16(phys);
+	cp.selected_phys = cpu_to_le32(phys);
 
 	index = mgmt_index;
 	if (index == MGMT_INDEX_NONE)
@@ -4501,7 +4499,7 @@ static const struct bt_shell_menu main_menu = {
 		cmd_clr_adv,		"Clear advertising instances"	},
 	{ "appearance",		"<appearance>",
 		cmd_appearance,		"Set appearance"		},
-	{ "phy",		"[phys]",
+	{ "phy",		"[phys ...]",
 		cmd_phy,		"Get/Set PHY Configuration"	},
 	{} },
 };
-- 
2.7.4
next prev parent reply	other threads:[~2018-07-06 11:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 11:27 [PATCH BlueZ 0/8] Add BREDR PHYs in PHY configuration commands Jaganath Kanakkassery
2018-07-06 11:27 ` [PATCH BlueZ 1/8] monitor: Fix 2-DH5 packet type print Jaganath Kanakkassery
2018-07-19  9:54   ` Jaganath K
2018-07-06 11:27 ` Jaganath Kanakkassery [this message]
2018-08-23  9:24   ` [PATCH BlueZ 2/8] btmgmt: Add BREDR PHYs in PHY Configuration commands Jaganath K
2018-07-06 11:28 ` [PATCH BlueZ 3/8] monitor: Add BREDR PHYs in PHY configuration commands Jaganath Kanakkassery
2018-07-06 11:28 ` [PATCH BlueZ 4/8] emulator: Add BREDR 2M & 3M, 3 & 5 Slot packet type support Jaganath Kanakkassery
2018-07-06 11:28 ` [PATCH BlueZ 5/8] mgmt-tester: Add extended advertising test cases Jaganath Kanakkassery
2018-07-06 11:28 ` [PATCH BlueZ 6/8] mgmt-tester: Add PHY Configuration " Jaganath Kanakkassery
2018-07-06 11:28 ` [PATCH BlueZ 7/8] mgmt-tester: Add tests for extended scanning and device found Jaganath Kanakkassery
2018-07-06 11:28 ` [PATCH BlueZ 8/8] mgmt-tester: Add support ext create connection and enh conn complete Jaganath Kanakkassery
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=1530876485-17218-3-git-send-email-jaganathx.kanakkassery@intel.com \
    --to=jaganath.k.os@gmail.com \
    --cc=jaganathx.kanakkassery@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).