add doc and fix types

This commit is contained in:
Gilles Boccon-Gibod
2023-09-06 16:48:08 -07:00
parent 1ea12b1bf7
commit 8be9f4cb0e
2 changed files with 8 additions and 3 deletions

View File

@@ -129,8 +129,12 @@ RFCOMM_DYNAMIC_CHANNEL_NUMBER_END = 30
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
def make_service_sdp_records( 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]: ) -> 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 = [ records = [
ServiceAttribute( ServiceAttribute(
SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID, SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID,
@@ -160,7 +164,7 @@ def make_service_sdp_records(
records.append( records.append(
ServiceAttribute( ServiceAttribute(
SDP_SERVICE_CLASS_ID_LIST_ATTRIBUTE_ID, SDP_SERVICE_CLASS_ID_LIST_ATTRIBUTE_ID,
DataElement.sequence([DataElement.uuid(UUID(uuid))]), DataElement.sequence([DataElement.uuid(uuid)]),
) )
) )

View File

@@ -20,6 +20,7 @@ import sys
import os import os
import logging import logging
from bumble.core import UUID
from bumble.device import Device from bumble.device import Device
from bumble.transport import open_transport_or_link from bumble.transport import open_transport_or_link
from bumble.rfcomm import Server from bumble.rfcomm import Server
@@ -32,7 +33,7 @@ def sdp_records(channel, uuid):
service_record_handle = 0x00010001 service_record_handle = 0x00010001
return { return {
service_record_handle: make_service_sdp_records( service_record_handle: make_service_sdp_records(
service_record_handle, channel, uuid service_record_handle, channel, UUID(uuid)
) )
} }