diff --git a/bumble/rfcomm.py b/bumble/rfcomm.py index 5920eb0..02c18fa 100644 --- a/bumble/rfcomm.py +++ b/bumble/rfcomm.py @@ -129,8 +129,12 @@ RFCOMM_DYNAMIC_CHANNEL_NUMBER_END = 30 # ----------------------------------------------------------------------------- def make_service_sdp_records( - service_record_handle: int, channel: int, uuid: UUID = None + service_record_handle: int, channel: int, uuid: Optional[UUID] = None ) -> List[ServiceAttribute]: + """ + Create SDP records for an RFComm service given a channel number and an + optional UUID. A Service Class Attribute is included only if the UUID is not None. + """ records = [ ServiceAttribute( SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID, @@ -160,7 +164,7 @@ def make_service_sdp_records( records.append( ServiceAttribute( SDP_SERVICE_CLASS_ID_LIST_ATTRIBUTE_ID, - DataElement.sequence([DataElement.uuid(UUID(uuid))]), + DataElement.sequence([DataElement.uuid(uuid)]), ) ) diff --git a/examples/run_rfcomm_server.py b/examples/run_rfcomm_server.py index 0e7e72e..41915a4 100644 --- a/examples/run_rfcomm_server.py +++ b/examples/run_rfcomm_server.py @@ -20,6 +20,7 @@ import sys import os import logging +from bumble.core import UUID from bumble.device import Device from bumble.transport import open_transport_or_link from bumble.rfcomm import Server @@ -32,7 +33,7 @@ def sdp_records(channel, uuid): service_record_handle = 0x00010001 return { service_record_handle: make_service_sdp_records( - service_record_handle, channel, uuid + service_record_handle, channel, UUID(uuid) ) }