Linux bluetooth development
 help / color / mirror / Atom feed
From: Dimitry Andric <dimitry@andric.com>
To: Marcel Holtmann <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [PATCH] Add sdptool option for browsing with L2CAP_UUID
Date: Thu, 7 Apr 2005 21:19:22 +0200	[thread overview]
Message-ID: <1598723318.20050407211922@andric.com> (raw)
In-Reply-To: <1112881490.9047.73.camel@pegasus>

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

On 2005-04-07 at 15:44:50 Marcel Holtmann wrote:

> Maybe we should add somekind of short name to UUID translation function,
> because the numeric values are hard to remember.

Here's an easy hack: I reused the existing uuid16_names array for
looking up (partial) matches.  You can also get a list of recognized
names.  If you think it would be nicer to add a separate name list
(i.e. made from the names in sdp.h), let me know.

[-- Attachment #2: bluez-utils-2.15-sdpbrowse-uuid2.patch --]
[-- Type: text/plain, Size: 2385 bytes --]

# bluez-utils-2.15-sdpbrowse-uuid2.patch
#
# Extend the --uuid option of sdptool browse, to additionally recognize uuid's
# by name instead of number.  The existing uuid16_names array is used for this
# purpose.  You don't have to specify the full name, as long as it matches
# unambiguously.  Also, by specifying "--uuid list", you can get a full list of
# available uuid names.
#
# Dimitry Andric <dimitry@andric.com>, 2005-04-07 21:05:35

Index: tools/sdptool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/sdptool.c,v
retrieving revision 1.21
diff -u -d -r1.21 sdptool.c
--- tools/sdptool.c	7 Apr 2005 13:43:23 -0000	1.21
+++ tools/sdptool.c	7 Apr 2005 19:03:34 -0000
@@ -2103,7 +2103,8 @@
 
 static char *browse_help = 
 	"Usage:\n"
-	"\tbrowse [--tree] [--uuid uuid] [--l2cap] [bdaddr]\n";
+	"\tbrowse [--tree] [--uuid uuid] [--l2cap] [bdaddr]\n"
+	"Use --uuid list to get a list of possible UUIDs\n";
 
 /*
  * Browse the full SDP database (i.e. list all services starting from the
@@ -2112,7 +2113,7 @@
 static int cmd_browse(int argc, char **argv)
 {
 	struct search_context context;
-	int opt, num;
+	int opt, i;
 
 	/* Initialise context */
 	memset(&context, '\0', sizeof(struct search_context));
@@ -2125,11 +2126,34 @@
 			context.tree = 1;
 			break;
 		case 'u':
-			if (sscanf(optarg, "%i", &num) != 1 || num < 0 || num > 0xffff) {
-				printf("Invalid uuid %s\n", optarg);
+			if (!strcasecmp(optarg, "list")) {
+				for (i = 0; i < uuid16_max; ++i)
+					printf("0x%04x: %s\n", uuid16_names[i].num, uuid16_names[i].name);
 				return -1;
+			} else if (sscanf(optarg, "%i", &i) == 1) {
+				if (i < 0 || i > 0xffff) {
+					printf("Invalid uuid %s\n", optarg);
+					return -1;
+				}
+				sdp_uuid16_create(&context.group, i);
+			} else {
+				int len = strlen(optarg);
+				int match = -1;
+				for (i = 0; i < uuid16_max; ++i) {
+					if (!strncasecmp(optarg, uuid16_names[i].name, len)) {
+						if (match >= 0) {
+							printf("Ambiguous uuid %s\n", optarg);
+							return -1;
+						}
+						match = i;
+					}
+				}
+				if (match < 0) {
+					printf("Invalid uuid %s\n", optarg);
+					return -1;
+				}
+				sdp_uuid16_create(&context.group, uuid16_names[match].num);
 			}
-			sdp_uuid16_create(&context.group, num);
 			break;
 		case 'l':
 			sdp_uuid16_create(&context.group, L2CAP_UUID);

  reply	other threads:[~2005-04-07 19:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-04 15:16 [Bluez-devel] [PATCH] Add sdptool option for browsing with L2CAP_UUID Dimitry Andric
2005-04-05  8:20 ` Johan Hedberg
2005-04-05  8:40   ` Peter Wippich
2005-04-05 15:27 ` Marcel Holtmann
2005-04-07 12:08   ` Dimitry Andric
2005-04-07 13:44     ` Marcel Holtmann
2005-04-07 19:19       ` Dimitry Andric [this message]
2005-04-11 16:22         ` Marcel Holtmann

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=1598723318.20050407211922@andric.com \
    --to=dimitry@andric.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /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