From: Szymon Janc <szymon.janc@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@codecoup.pl>
Subject: [PATCH v2 4/5] tools/btmgmt: Add support for Set Appearance command
Date: Sun, 18 Sep 2016 12:34:40 +0200 [thread overview]
Message-ID: <1474194881-10403-4-git-send-email-szymon.janc@codecoup.pl> (raw)
In-Reply-To: <1474194881-10403-1-git-send-email-szymon.janc@codecoup.pl>
---
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
next prev parent reply other threads:[~2016-09-18 10:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2016-09-18 10:34 ` [PATCH v2 5/5] monitor: Add support for Set Appearance mgmt command Szymon Janc
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=1474194881-10403-4-git-send-email-szymon.janc@codecoup.pl \
--to=szymon.janc@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 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).