Skip to content

Bluetooth SDP

Peter Foot edited this page Jul 22, 2021 · 2 revisions

Bluetooth Service Discovery Protocol (SDP)

The library contains support for creating, parsing, and dumping SDP records. This will generally be used in advanced scenarios only. For instance BluetoothListener by default creates a basic record based on the Service Class Id passed in.

To retrieve and dump the records containing a given UUID on a particular device one can use code like the following.

Guid uuid = ...
BluetoothDeviceInfo device = ...
ServiceRecord[]() records = device.GetServiceRecords(uuid);
foreach(ServiceRecord curRecord in records) {
   ServiceRecordUtilities.Dump(curRecord, Console.Out);
}

For instance to see whether the device has an an Serial Port service, do a search for UUID BluetoothService.SerialPort, for OBEX Push use BluetoothService.ObexObjectPush, or too find all the services that use RFCOMM use BluetoothService.RFCommProtocol, or to find all the services, use BluetoothService.L2CapProtocol.

XML Representation

It is now possible to export a ServiceRecord into the XML format used by the BlueZ Bluetooth stack. Use the ServiceRecordXmlCreator class for this. The format is documented with this DTD and in the BlueZ source code.

Creating Records

Connect by Service Name

Manual Record Creation

Testing if a device is in range

Clone this wiki locally