You can set service class uuid with the sdptool
:
sdptool setseq 0x10011 0x0001 u0x1124
but it has limited capabilities.
I have found another way to advertise service using dbus-python library:
import dbus
def advertise_service(sdp_record_xml):
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")
adapter_path = manager.FindAdapter(self.device_id)
service = dbus.Interface(bus.get_object("org.bluez", adapter_path),
"org.bluez.Service")
service.AddRecord(sdp_record_xml)
And here is an example of the XML SDP record:
<?xml version="1.0" encoding="utf-8" ?>
<record>
<attribute id="0x0001">
<!-- ServiceClassIDList -->
<sequence>
<uuid value="00000000-0000-1000-8000-00805F9B34FB" />
</sequence>
</attribute>
<attribute id="0x0003">
<!-- ServiceID -->
<uuid value="00000000-0000-1000-8000-00805F9B34FB" />
</attribute>
<attribute id="0x0004">
<!-- ProtocolDescriptorList -->
<sequence>
<sequence>
<uuid value="0x0100" />
</sequence>
<sequence>
<uuid value="0x0003" />
<uint8 value="0x3" /> <!-- RFCOMM channel -->
</sequence>
</sequence>
</attribute>
<attribute id="0x0005">
<!-- BrowseGroupList -->
<sequence>
<uuid value="0x1002" />
</sequence>
</attribute>
<attribute id="0x0100">
<!-- Service name -->
<text value="My Service" />
</attribute>
</record>