Skip to contentSkip to conversation

Add sdptool option for browsing with L2CAP_UUID

PATCH In review Dimitry Andric 4 participants 8 messages Apr 4, 2005 – Apr 11, 2005 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add sdptool option for browsing with L2CAP_UUID

Some phones (e.g. Samsung D500, Motorola MPx220, and possibly some other Windows Mobile models) don't return any services if you ask them for the public browse group. You notice this, when "sdptool browse xx:xx:xx:xx:xx:xx" returns immediately, without any output.

It turns out that the Windows XP Bluetooth browser asks for L2CAP_UUID, which *does* work for all the phones I've tested.

So I've made this simple patch, that adds a -l' or --l2cap' command line option to sdptool, to use the L2CAP_UUID for browsing, instead of PUBLIC_BROWSE_GROUP.

# bluez-utils-2.15-sdpbrowse-l2cap.patch
#
# Some phones don't return any services if you ask them for the public
# browse group.  It turns out that the Windows XP Bluetooth browser
# asks for L2CAP_UUID, which seems to work for all phones.
#
# This patch adds a `-l' or `--l2cap' command line option to sdptool,
# to use the L2CAP_UUID for browsing, instead of PUBLIC_BROWSE_GROUP.
#
# Dimitry Andric <[email protected]>, 2005-04-04 16:39:33
utils/tools/sdptool.c +9 -1
diff -urNd a/utils/tools/sdptool.c b/utils/tools/sdptool.c
@@ -2016,12 +2033,13 @@
 static struct option browse_options[] = {
 	{ "help",    0,0, 'h' },
 	{ "tree",    0,0, 't' },
+	{ "l2cap",   0,0, 'l' },
 	{ 0, 0, 0, 0 }
 };
 
 static char *browse_help = 
 	"Usage:\n"
-	"\tbrowse [--tree] [bdaddr]\n";
+	"\tbrowse [--tree] [--l2cap] [bdaddr]\n";
 
 /*
  * Browse the full SDP database (i.e. list all services starting from the
@@ -2042,6 +2060,13 @@
 		case 't':
 			context.tree = 1;
 			break;
+		case 'l':
+			/* Some phones don't return any services if you ask them for the
+			 * public browse group.  It turns out that the Windows XP Bluetooth
+			 * browser asks for L2CAP_UUID, which seems to work for all phones.
+			 */
+			sdp_uuid16_create(&(context.group), L2CAP_UUID);
+			break;
 		default:
 			printf(browse_help);
 			return -1;
#1 lore raw
Quoted 7 lines · Dimitry Andric

Some phones (e.g. Samsung D500, Motorola MPx220, and possibly some other Windows Mobile models) don't return any services if you ask them for the public browse group. You notice this, when "sdptool browse xx:xx:xx:xx:xx:xx" returns immediately, without any output.

It turns out that the Windows XP Bluetooth browser asks for L2CAP_UUID, which *does* work for all the phones I've tested.

I can confirm this behaviour also on a Motorola A760. However, it is also the only phone I have encountered this.

Johan

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Hi,

I'm aware of many devices which do not have a public browse group tag in their SDP records. Searching for all services with L2CAP is one solution. Another is to do a search for a range of well known service UUIDs. And another solution (as imlemented by Widcom) is to do a search for the whole range of service UUIDs (0..0xffff).
However, the last method wil crash some embedded devices with a dump local data base search implementation. Actually they will not realy crash but you may get a connection timeout.....

Ciao,

Peter

Quoted 15 lines · Johan Hedberg
Quoted 7 lines · Dimitry Andric

Some phones (e.g. Samsung D500, Motorola MPx220, and possibly some other Windows Mobile models) don't return any services if you ask them for the public browse group. You notice this, when "sdptool browse xx:xx:xx:xx:xx:xx" returns immediately, without any output.

It turns out that the Windows XP Bluetooth browser asks for L2CAP_UUID, which *does* work for all the phones I've tested.

I can confirm this behaviour also on a Motorola A760. However, it is also the only phone I have encountered this.

Johan

Quoted 10 lines

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

|	Peter Wippich 			Voice: +49 30 46776411		|
|	G&W Instruments GmbH		fax:   +49 30 46776419		|
|	Gustav-Meyer-Allee 25, Geb. 12	Email: [email protected]	|
|	D-13355 Berlin  / Germany					|

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw
In reply to Dimitry Andric

Hi Dimitry,

Quoted 11 lines

Some phones (e.g. Samsung D500, Motorola MPx220, and possibly some other Windows Mobile models) don't return any services if you ask them for the public browse group. You notice this, when "sdptool browse xx:xx:xx:xx:xx:xx" returns immediately, without any output.

It turns out that the Windows XP Bluetooth browser asks for L2CAP_UUID, which *does* work for all the phones I've tested.

So I've made this simple patch, that adds a -l' or --l2cap' command line option to sdptool, to use the L2CAP_UUID for browsing, instead of PUBLIC_BROWSE_GROUP.

the patch is applied to the CVS. Maybe we should add another one to browse any UUID in general. Something like "--uuid 0x0003" for example.

A small nitpick about the coding style. The braces around context.group are not needed and normally we don't use them.

	sdp_uuid16_create(&(context.group), L2CAP_UUID);

I also realized that you only followed the example above that creates the public browse group context (which I fixed now). So please keep that in mind the next time.

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw
Quoted 2 lines · On 2005-04-05 at 17:27:17 Marcel Holtmann wrote:

the patch is applied to the CVS. Maybe we should add another one to browse any UUID in general. Something like "--uuid 0x0003" for example.

Here is a patch that adds such an option. It will be interesting to see what browse info is returned with various weird uuid's. :)

# bluez-utils-2.15-sdpbrowse-uuid.patch
#
# This patch adds a `--uuid' command line option to sdptool, to specify the
# uuid of an arbitrary protocol for browsing, instead of PUBLIC_BROWSE_GROUP.
# The uuid can be specified in decimal, hex (using a '0x' prefix) or octal
# (using a '0' prefix).
#
# Dimitry Andric <[email protected]>, 2005-04-07 13:59:21

Index: tools/sdptool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/sdptool.c,v
retrieving revision 1.20

sdptool.c +10 -1
diff -u -d -r1.20 sdptool.c
@@ -2097,12 +2097,13 @@
 	{ "help",    0,0, 'h' },
 	{ "tree",    0,0, 't' },
 	{ "l2cap",   0,0, 'l' },
+	{ "uuid",    1,0, 'u' },
 	{ 0, 0, 0, 0 }
 };
 
 static char *browse_help = 
 	"Usage:\n"
-	"\tbrowse [--tree] [--l2cap] [bdaddr]\n";
+	"\tbrowse [--tree] [--l2cap] [--uuid uuid] [bdaddr]\n";
 
 /*
  * Browse the full SDP database (i.e. list all services starting from the
@@ -2112,6 +2113,7 @@
 {
 	struct search_context context;
 	int opt;
+	int num;
 
 	/* Initialise context */
 	memset(&context, '\0', sizeof(struct search_context));
@@ -2126,6 +2128,13 @@
 		case 'l':
 			sdp_uuid16_create(&context.group, L2CAP_UUID);
 			break;
+		case 'u':
+			if (sscanf(optarg, "%i", &num) != 1 || num < 0 || num > 0xffff) {
+				printf("Invalid uuid %s\n", optarg);
+				return -1;
+			}
+			sdp_uuid16_create(&context.group, num);
+			break;
 		default:
 			printf(browse_help);
 			return -1;
maintainer
#5 lore raw

Hi Dimitry,

Quoted 5 lines
Quoted 2 lines

the patch is applied to the CVS. Maybe we should add another one to browse any UUID in general. Something like "--uuid 0x0003" for example.

Here is a patch that adds such an option. It will be interesting to see what browse info is returned with various weird uuid's. :)

patch is applied.

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

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#6 lore raw
Quoted 2 lines · 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.

# 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 <[email protected]>, 2005-04-07 21:05:35

Index: tools/sdptool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/sdptool.c,v
retrieving revision 1.21

sdptool.c +29 -5
diff -u -d -r1.21 sdptool.c
@@ -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);
maintainer
#7 lore raw

Hi Dimitry,

Quoted 7 lines
Quoted 2 lines

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.

this is really a hack ;)

I think that we need a special table for this, where we add short names (and I mean short) for some UUIDs. Maybe it is enough to look up the core protocol names like L2CAP, RFCOMM and OBEX. This would then also make the --l2cap option obsolete. You can use "--uuid l2cap" for it.

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel