linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command
@ 2014-04-02 10:29 Szymon Janc
  2014-04-02 10:29 ` [PATCH 2/2] tools/btmgmt: Fix bogus comment in eir_get_flags function Szymon Janc
  2014-04-02 10:43 ` [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Szymon Janc @ 2014-04-02 10:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This is needed to disconnect LE devices.
---
 tools/btmgmt.c | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 50c00b5..aee6841 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -1186,21 +1186,53 @@ done:
 	mainloop_quit();
 }
 
+static void disconnect_usage(void)
+{
+	printf("Usage: btmgmt disconnect [-t type] <remote address>\n");
+}
+
+static struct option disconnect_options[] = {
+	{ "help",	0, 0, 'h' },
+	{ "type",	1, 0, 't' },
+	{ 0, 0, 0, 0 }
+};
+
 static void cmd_disconnect(struct mgmt *mgmt, uint16_t index, int argc,
 								char **argv)
 {
 	struct mgmt_cp_disconnect cp;
+	uint8_t type = BDADDR_BREDR;
+	int opt;
 
-	if (argc < 2) {
-		printf("Usage: btmgmt %s <address>\n", argv[0]);
-		exit(EXIT_FAILURE);
+	while ((opt = getopt_long(argc, argv, "+t:h", disconnect_options,
+								NULL)) != -1) {
+		switch (opt) {
+		case 't':
+			type = strtol(optarg, NULL, 0);
+			break;
+		case 'h':
+		default:
+			disconnect_usage();
+			exit(EXIT_SUCCESS);
+		}
 	}
 
-	str2ba(argv[1], &cp.addr.bdaddr);
+	argc -= optind;
+	argv += optind;
+	optind = 0;
+
+	if (argc < 1) {
+		disconnect_usage();
+		exit(EXIT_FAILURE);
+	}
 
 	if (index == MGMT_INDEX_NONE)
 		index = 0;
 
+	memset(&cp, 0, sizeof(cp));
+	str2ba(argv[0], &cp.addr.bdaddr);
+	cp.addr.type = type;
+
 	if (mgmt_send(mgmt, MGMT_OP_DISCONNECT, index, sizeof(cp), &cp,
 					disconnect_rsp, NULL, NULL) == 0) {
 		fprintf(stderr, "Unable to send disconnect cmd\n");
-- 
1.9.1


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

* [PATCH 2/2] tools/btmgmt: Fix bogus comment in eir_get_flags function
  2014-04-02 10:29 [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Szymon Janc
@ 2014-04-02 10:29 ` Szymon Janc
  2014-04-02 10:43 ` [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-04-02 10:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This was due to copy-and-paste.
---
 tools/btmgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index aee6841..48d42a3 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -360,7 +360,7 @@ static unsigned int eir_get_flags(const uint8_t *eir, uint16_t eir_len)
 		if (parsed > eir_len)
 			break;
 
-		/* Check for short of complete name */
+		/* Check for flags */
 		if (eir[1] == 0x01)
 			return eir[2];
 
-- 
1.9.1


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

* Re: [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command
  2014-04-02 10:29 [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Szymon Janc
  2014-04-02 10:29 ` [PATCH 2/2] tools/btmgmt: Fix bogus comment in eir_get_flags function Szymon Janc
@ 2014-04-02 10:43 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2014-04-02 10:43 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On Wed, Apr 02, 2014, Szymon Janc wrote:
> This is needed to disconnect LE devices.
> ---
>  tools/btmgmt.c | 40 ++++++++++++++++++++++++++++++++++++----
>  1 file changed, 36 insertions(+), 4 deletions(-)

Both patches have been applied. Thanks.

Johan

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

end of thread, other threads:[~2014-04-02 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 10:29 [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Szymon Janc
2014-04-02 10:29 ` [PATCH 2/2] tools/btmgmt: Fix bogus comment in eir_get_flags function Szymon Janc
2014-04-02 10:43 ` [PATCH 1/2] tools/btmgmt: Add option to pass adress type to disconnect command Johan Hedberg

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).