All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification
@ 2016-09-18 10:34 Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 2/5] lib/mgmt: Add Set Appearance command definition Szymon Janc
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-18 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

From: Michał Narajowski <michal.narajowski@codecoup.pl>

---
 doc/mgmt-api.txt | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 2b8a81d..0cc747a 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -2885,6 +2885,31 @@ Read Extended Controller Information Command
 				Invalid Index
 
 
+Set Appearance Command
+======================
+
+	Command Code:		0x0042
+	Controller Index:	<controller id>
+	Command Parameters:	Appearance (2 Octets)
+	Return Parameters:
+
+	This command is used to set the appearance value of a controller.
+
+	This command can be used when the controller is not
+	powered and all settings will be programmed once powered.
+
+	The value of appearance will be remembered when switching
+	the controller off and back on again. So the appearance only
+	have to be set once when a new controller is found and will
+	stay until removed.
+
+	This command generates a Command Complete event on success
+	or a Command Status event on failure.
+
+	Possible errors:	Invalid Parameters
+				Invalid Index
+
+
 Command Complete Event
 ======================
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/5] lib/mgmt: Add Set Appearance command definition
  2016-09-18 10:34 [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification Szymon Janc
@ 2016-09-18 10:34 ` Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 3/5] tools/btmgmt: Add support for scan rsp flags in add advertising Szymon Janc
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-18 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

From: Michał Narajowski <michal.narajowski@codecoup.pl>

---
 lib/mgmt.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index 8de2616..798a05e 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -541,6 +541,11 @@ struct mgmt_rp_read_ext_info {
 	uint8_t  eir[0];
 } __packed;
 
+#define MGMT_OP_SET_APPEARANCE		0x0043
+struct mgmt_cp_set_appearance {
+	uint16_t appearance;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
@@ -827,6 +832,7 @@ static const char *mgmt_op[] = {
 	"Get Advertising Size Information",		/* 0x0040 */
 	"Start Limited Discovery",
 	"Read Extended Controller Information",
+	"Set Appearance",
 };
 
 static const char *mgmt_ev[] = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/5] tools/btmgmt: Add support for scan rsp flags in add advertising
  2016-09-18 10:34 [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 2/5] lib/mgmt: Add Set Appearance command definition Szymon Janc
@ 2016-09-18 10:34 ` Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 4/5] tools/btmgmt: Add support for Set Appearance command Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 5/5] monitor: Add support for Set Appearance mgmt command Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-18 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This allows to set local-name and appearance flags for add advertising
command.
---
 tools/btmgmt.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 38e959f..0def4e1 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4071,6 +4071,8 @@ static void add_adv_usage(void)
 		"\t -c, --connectable         \"connectable\" flag\n"
 		"\t -g, --general-discov      \"general-discoverable\" flag\n"
 		"\t -l, --limited-discov      \"limited-discoverable\" flag\n"
+		"\t -n, --scan-rsp-local-name \"local-name\" flag\n"
+		"\t -a, --scan-rsp-appearance \"appearance\" flag\n"
 		"\t -m, --managed-flags       \"managed-flags\" flag\n"
 		"\t -p, --tx-power            \"tx-power\" flag\n"
 		"e.g.:\n"
@@ -4152,7 +4154,7 @@ static void cmd_add_adv(struct mgmt *mgmt, uint16_t index,
 	bool quit = true;
 	uint32_t flags = 0;
 
-	while ((opt = getopt_long(argc, argv, "+u:d:s:t:D:cglmph",
+	while ((opt = getopt_long(argc, argv, "+u:d:s:t:D:cglmphna",
 						add_adv_options, NULL)) != -1) {
 		switch (opt) {
 		case 'u':
@@ -4231,6 +4233,12 @@ static void cmd_add_adv(struct mgmt *mgmt, uint16_t index,
 		case 'p':
 			flags |= MGMT_ADV_FLAG_TX_POWER;
 			break;
+		case 'n':
+			flags |= MGMT_ADV_FLAG_LOCAL_NAME;
+			break;
+		case 'a':
+			flags |= MGMT_ADV_FLAG_APPEARANCE;
+			break;
 		case 'h':
 			success = true;
 		default:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/5] tools/btmgmt: Add support for Set Appearance command
  2016-09-18 10:34 [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 2/5] lib/mgmt: Add Set Appearance command definition Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 3/5] tools/btmgmt: Add support for scan rsp flags in add advertising Szymon Janc
@ 2016-09-18 10:34 ` Szymon Janc
  2016-09-18 10:34 ` [PATCH v2 5/5] monitor: Add support for Set Appearance mgmt command Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-18 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

---
 tools/btmgmt.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 0def4e1..3828c2a 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4362,6 +4362,40 @@ static void cmd_clr_adv(struct mgmt *mgmt, uint16_t index, int argc, char **argv
 	cmd_rm_adv(mgmt, index, 2, rm_argv);
 }
 
+static void appearance_rsp(uint8_t status, uint16_t len, const void *param,
+							void *user_data)
+{
+	if (status != 0)
+		error("Could not set Appearance with status 0x%02x (%s)",
+						status, mgmt_errstr(status));
+	else
+		print("Appearance successfully set");
+
+	noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_appearance(struct mgmt *mgmt, uint16_t index, int argc,
+								char **argv)
+{
+	struct mgmt_cp_set_appearance cp;
+
+	if (argc < 2) {
+		print("Usage: appearance <appearance>");
+		return noninteractive_quit(EXIT_FAILURE);
+	}
+
+	if (index == MGMT_INDEX_NONE)
+		index = 0;
+
+	cp.appearance = cpu_to_le16(strtol(argv[1], NULL, 0));
+
+	if (mgmt_send(mgmt, MGMT_OP_SET_APPEARANCE, index, sizeof(cp), &cp,
+					appearance_rsp, NULL, NULL) == 0) {
+		error("Unable to send appearance cmd");
+		return noninteractive_quit(EXIT_FAILURE);
+	}
+}
+
 struct cmd_info {
 	char *cmd;
 	void (*func)(struct mgmt *mgmt, uint16_t index, int argc, char **argv);
@@ -4430,6 +4464,7 @@ static struct cmd_info all_cmd[] = {
 	{ "add-adv",	cmd_add_adv,	"Add advertising instance"	},
 	{ "rm-adv",	cmd_rm_adv,	"Remove advertising instance"	},
 	{ "clr-adv",	cmd_clr_adv,	"Clear advertising instances"	},
+	{ "appearance",	cmd_appearance,	"Set appearance"		},
 };
 
 static void cmd_quit(struct mgmt *mgmt, uint16_t index,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 5/5] monitor: Add support for Set Appearance mgmt command
  2016-09-18 10:34 [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification Szymon Janc
                   ` (2 preceding siblings ...)
  2016-09-18 10:34 ` [PATCH v2 4/5] tools/btmgmt: Add support for Set Appearance command Szymon Janc
@ 2016-09-18 10:34 ` Szymon Janc
  3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-18 10:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

@ MGMT Command: Set Appearance (0x0043) plen 2         {0x0002}
        Appearance: (0x1234)
@ MGMT Event: Command Complete (0x0001) plen 3         {0x0002}
      Set Appearance (0x0043) plen 0
        Status: Success (0x00)
---
 monitor/packet.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/monitor/packet.c b/monitor/packet.c
index f5d6f96..1b68d1b 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -10755,6 +10755,13 @@ static void mgmt_read_ext_controller_info_rsp(const void *data, uint16_t size)
 	print_eir(data + 19, size - 19, false);
 }
 
+static void mgmt_set_apperance_cmd(const void *data, uint16_t size)
+{
+	uint16_t appearance = get_le16(data);
+
+	print_field("Appearance: (0x%2.2x)", appearance);
+}
+
 struct mgmt_data {
 	uint16_t opcode;
 	const char *str;
@@ -10965,6 +10972,9 @@ static const struct mgmt_data mgmt_command_table[] = {
 	{ 0x0042, "Read Extended Controller Information",
 				mgmt_null_cmd, 0, true,
 				mgmt_read_ext_controller_info_rsp, 19, false },
+	{ 0x0043, "Set Appearance",
+				mgmt_set_apperance_cmd, 2, true,
+				mgmt_null_rsp, 0, true },
 	{ }
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-18 10:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-18 10:34 [PATCH v2 1/5] doc/mgmt-api: Add Set Appearance command specification Szymon Janc
2016-09-18 10:34 ` [PATCH v2 2/5] lib/mgmt: Add Set Appearance command definition Szymon Janc
2016-09-18 10:34 ` [PATCH v2 3/5] tools/btmgmt: Add support for scan rsp flags in add advertising Szymon Janc
2016-09-18 10:34 ` [PATCH v2 4/5] tools/btmgmt: Add support for Set Appearance command Szymon Janc
2016-09-18 10:34 ` [PATCH v2 5/5] monitor: Add support for Set Appearance mgmt command Szymon Janc

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.