From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: <kanak.gupta@stericsson.com>, Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH V2 5/7] btmgmt: Add support for setting Device ID
Date: Tue, 20 Mar 2012 17:27:25 +0100 [thread overview]
Message-ID: <1332260847-20079-5-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1332260847-20079-1-git-send-email-szymon.janc@tieto.com>
---
mgmt/main.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/mgmt/main.c b/mgmt/main.c
index 4f10e08..ec97136 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
@@ -1730,6 +1730,70 @@ static void cmd_clr_uuids(int mgmt_sk, uint16_t index, int argc, char **argv)
cmd_remove_uuid(mgmt_sk, index, 2, rm_argv);
}
+static void did_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
+ void *rsp, uint16_t len, void *user_data)
+{
+ if (status != 0) {
+ fprintf(stderr, "Set Device ID failed with status 0x%02x (%s)\n",
+ status, mgmt_errstr(status));
+ exit(EXIT_FAILURE);
+ }
+
+ printf("Device ID succesfully set\n");
+
+ exit(EXIT_SUCCESS);
+}
+
+static void did_usage(void)
+{
+ printf("Usage: btmgmt did <source>:<vendor>:<product>:<version>\n");
+ printf(" possible source values: bluetooth, usb\n");
+}
+
+static void cmd_did(int mgmt_sk, uint16_t index, int argc, char **argv)
+{
+ struct mgmt_cp_set_device_id cp;
+ uint16_t vendor, product, version , source;
+ int result;
+
+ if (argc < 2) {
+ did_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ result = sscanf(argv[1], "bluetooth:%4hx:%4hx:%4hx", &vendor, &product,
+ &version);
+ if (result != EOF && result == 3) {
+ source = 0x0001;
+ goto done;
+ }
+
+ result = sscanf(argv[1], "usb:%4hx:%4hx:%4hx", &vendor, &product,
+ &version);
+ if (result != EOF && result == 3) {
+ source = 0x0002;
+ goto done;
+ }
+
+ did_usage();
+ exit(EXIT_FAILURE);
+
+done:
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ cp.source = htobs(source);
+ cp.vendor = htobs(vendor);
+ cp.product = htobs(product);
+ cp.version = htobs(version);
+
+ if (mgmt_send_cmd(mgmt_sk, MGMT_OP_SET_DEVICE_ID, index,
+ &cp, sizeof(cp), did_rsp, NULL) < 0) {
+ fprintf(stderr, "Unable to send set_dev_class cmd\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
static struct {
char *cmd;
void (*func)(int mgmt_sk, uint16_t index, int argc, char **argv);
@@ -1760,6 +1824,7 @@ static struct {
{ "add-uuid", cmd_add_uuid, "Add UUID" },
{ "rm-uuid", cmd_add_uuid, "Remove UUID" },
{ "clr-uuids", cmd_clr_uuids, "Clear UUIDs", },
+ { "did", cmd_did, "Set Device ID", },
{ NULL, NULL, 0 }
};
--
on behalf of ST-Ericsson
next prev parent reply other threads:[~2012-03-20 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 16:27 [PATCH V2 1/7] Parse config DeviceID string on bluetoothd startup Szymon Janc
2012-03-20 16:27 ` [PATCH V2 2/7] Set DeviceID when registering adapter not when sdp server is starting Szymon Janc
2012-03-28 9:29 ` Johan Hedberg
2012-03-20 16:27 ` [PATCH V2 3/7] Add support for setting VID source in DeviceID from config file Szymon Janc
2012-03-20 16:27 ` [PATCH V2 4/7] mgmtops: Add support for setting Device ID Szymon Janc
2012-03-20 16:27 ` Szymon Janc [this message]
2012-03-26 14:45 ` [PATCH V3 5/7] btmgmt: " Szymon Janc
2012-03-20 16:27 ` [PATCH V2 6/7] Bump Device ID service version to 1.3 Szymon Janc
2012-03-20 16:27 ` [PATCH V2 7/7] Move common code to sdp to avoid duplication 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=1332260847-20079-5-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@tieto.com \
--cc=kanak.gupta@stericsson.com \
--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