RSS

Monthly Archives: August 2011

BlueZ sdptool usage notes

I’ve been doing work on Bluetooth support on BlueZ on Linux.  For instance I’ve added support for that platform to the 32feet.NET library, see http://32feet.codeplex.com/wikipage?title=BlueZ on Linux  I’ve also been reading Hacking Exposed: Wireless by Cache et al (Amazon UK Kindle edition) which discusses the use of the sdptool utility.  Finally I was also also playing with BlueZ’s XML format for SDP records.

In using sdptool it was not clear to me what the various commands did; what is “search” versus “browse” for instance.  The man page for the tool is fairly basic and says itself: “Documentation needs improving.”

So here’s my notes on usage:

Commands:

  • search
    • Usage: search [–bdaddr <bdaddr>] { –tree | –raw | –xml } <service_class_id>
    • “Queries for records with the specified Service Class.  Either on one specified device, or on all devices in range if no device address is specified.”
    • “The Service Class Id can be specified by name, or as a number (UUID16/32 e.g. 0x1101 for SPP).  See below [in the manpage] for the known names.”
  • browse
    • Usage: browse {–tree | –raw | –xml } { –uuid <service_class_id_number> |-l2cap} [<bdaddr>]
    • “Queries for records that are member of the Public Browse Group, or by specified service class id.”
    • “A device address can be specified as the last parameter, otherwise the query is done on all devices in range,”
    •  “Or, with ‘–l2cap’ queries all records containing the L2CAP Service Class Id.  Connectable services all generally use the L2CAP protocol so will be returned by this query.”
    • “Or, with ‘–uuid <service_class_id_number>’ queries all records containing the specified UUID16, which may be in hex or decimal format, e.g. 0x0100 for L2CAP, 0x1101 for SPP, or 3 for RFCOMM.”
    •  “(This command is largely equivalent to calling “search” with the specified UUID in the three cases being respectively: PUBLIC_BROWSE_GROUP (0x1002), <NUM>, L2CAP (0x0100).  And passing the optional address as the –bdaddr parameter there).
  • records
    • Usage: records { –tree | –raw | –xml } <bdaddr>
    • “Tries to find all record by querying by Service Record Handle number.”
    • “Various ranges of handle numbers are searched to match the ranges used by known device types.”
    • “The device address is not optional.”
  • get
    • Usage: get [–bdaddr <bdaddr>] { –tree | –raw | –xml } <record_handle>
    • Queries for the service with the specified Service Record Handle number.
    • Either on the local device, or on all devices in range if no device address is specified.
  • del
    • Usage: del <record_handle>
    • Deletes the service on the local device with the specified Service Record Handle number.
    • BTW the handle for each record is displayed in each output e.g. “Service RecHandle: 0x1000b”.

There are also three more commands for adding a new record or elements to an existing local record (add, setattr, setseq).  I have not used those commands.  Maybe at a later date…

Bluetooth device address format: XX:XX:XX:XX:XX:XX.  So that’s six hexadecimal digit-pairs colon separated (i.e. length 17).  If a different format is entered odd things happen.  Something for further investigation…

Record output format: Four types ‘normal’, tree, raw and xml.  Normal displays only the known attributes and in a simple format, tree displays all the attributes with names given to known sub-elements, raw also displays the whole tree but with all element types given, and xml encodes the tree as XML.

Examples:

========================================
> sdptool browse --uuid 0x1112 02:22:33:ff:ee:dd

Browsing 00:0A:3A:68:65:BB ...
Service Name: Audio Gateway
Service RecHandle: 0x1000b
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 9
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Headset Audio Gateway" (0x1112)
    Version: 0x0100

========================================
> sdptool browse --tree --uuid 0x1112 02:22:33:ff:ee:dd

Browsing 00:0A:3A:68:65:BB ...
Attribute Identifier : 0x0 - ServiceRecordHandle
  Integer : 0x1000b
Attribute Identifier : 0x1 - ServiceClassIDList
  Data Sequence
    UUID16 : 0x1112 - HeadsetAudioGateway
    UUID16 : 0x1203 - GenericAudio
Attribute Identifier : 0x4 - ProtocolDescriptorList
  Data Sequence
    Data Sequence
      UUID16 : 0x0100 - L2CAP
    Data Sequence
      UUID16 : 0x0003 - RFCOMM
      Channel/Port (Integer) : 0x9
Attribute Identifier : 0x5 - BrowseGroupList
  Data Sequence
    UUID16 : 0x1002 - PublicBrowseGroup
Attribute Identifier : 0x6 - LanguageBaseAttributeIDList
  Data Sequence
    Code ISO639 (Integer) : 0x656e
    Encoding (Integer) : 0x6a
    Base Offset (Integer) : 0x100
Attribute Identifier : 0x8 - ServiceAvailability
  Integer : 0xff
Attribute Identifier : 0x9 - BluetoothProfileDescriptorList
  Data Sequence
    Data Sequence
      UUID16 : 0x1112 - HeadsetAudioGateway
      Version (Integer) : 0x100
Attribute Identifier : 0x100
  Data : 41 75 64 69 6f 20 47 61 74 65 77 61 79 00 00

========================================
> sdptool browse --xml --uuid 0x1112 02:22:33:ff:ee:dd

Browsing 00:0A:3A:68:65:BB ...
<?xml version="1.0" encoding="UTF-8" ?>

<record>
	<attribute id="0x0000">
		<uint32 value="0x0001000b" />
	</attribute>
	<attribute id="0x0001">
		<sequence>
			<uuid value="0x1112" />
			<uuid value="0x1203" />
		</sequence>
	</attribute>
	<attribute id="0x0004">
		<sequence>
			<sequence>
				<uuid value="0x0100" />
			</sequence>
			<sequence>
				<uuid value="0x0003" />
				<uint8 value="0x09" />
			</sequence>
		</sequence>
	</attribute>
	<attribute id="0x0005">
		<sequence>
			<uuid value="0x1002" />
		</sequence>
	</attribute>
	<attribute id="0x0006">
		<sequence>
			<uint16 value="0x656e" />
			<uint16 value="0x006a" />
			<uint16 value="0x0100" />
		</sequence>
	</attribute>
	<attribute id="0x0008">
		<uint8 value="0xff" />
	</attribute>
	<attribute id="0x0009">
		<sequence>
			<sequence>
				<uuid value="0x1112" />
				<uint16 value="0x0100" />
			</sequence>
		</sequence>
	</attribute>
	<attribute id="0x0100">
		<text value="Audio Gateway " />
	</attribute>
</record>

========================================
> sdptool browse --raw --uuid 0x1112 02:22:33:ff:ee:dd

Sequence
	Attribute 0x0000 - ServiceRecordHandle
		UINT32 0x0001000b
	Attribute 0x0001 - ServiceClassIDList
		Sequence
			UUID16 0x1112 - HeadsetAudioGateway
			UUID16 0x1203 - GenericAudio
	Attribute 0x0004 - ProtocolDescriptorList
		Sequence
			Sequence
				UUID16 0x0100 - L2CAP
			Sequence
				UUID16 0x0003 - RFCOMM
				UINT8 0x09
	Attribute 0x0005 - BrowseGroupList
		Sequence
			UUID16 0x1002 - PublicBrowseGroup
	Attribute 0x0006 - LanguageBaseAttributeIDList
		Sequence
			UINT16 0x656e
			UINT16 0x006a
			UINT16 0x0100
	Attribute 0x0008 - ServiceAvailability
		UINT8 0xff
	Attribute 0x0009 - BluetoothProfileDescriptorList
		Sequence
			Sequence
				UUID16 0x1112 - HeadsetAudioGateway
				UINT16 0x0100
	Attribute 0x0100
		Data 41 75 64 69 6f 20 47 61 74 65 77 61 79 00 00

========================================

I am happy for this documentation to be added to the man page etc.  Just add attribution please (“Alan J. McFarlane alanjmcf@yahoo.com“).

Advertisements
 
Leave a comment

Posted by on August 9, 2011 in BlueZ