bluez_peripheral.gatt.service module

class bluez_peripheral.gatt.service.Service(uuid: Union[BTUUID, str], primary: bool = True, includes: Collection[Service] = [])

Create a bluetooth service with the specified uuid.

Parameters
  • uuid (Union[UUID, str]) – The UUID of this service. A full list of recognised values is provided by the Bluetooth SIG

  • primary (bool, optional) – True if this service is a primary service (instead of a secondary service). False otherwise. Defaults to True.

  • includes (Collection[Service], optional) – Any services to include in this service. Services must be registered at the time Includes is read to be included.

add_characteristic(char: characteristic)

Add the specified characteristic to this service declaration.

Parameters

char (characteristic) – The characteristic to add.

Raises

ValueError – Raised when the service is registered with the bluez service manager and thus cannot be modified.

is_registered() bool

Check if this service is registered with the bluez service manager.

Returns

True if the service is registered. False otherwise.

Return type

bool

async register(bus: MessageBus, path: str = '/com/spacecheese/bluez_peripheral', adapter: Optional[Adapter] = None)

Register this service as a standalone service. Using this multiple times will cause path conflicts.

Parameters
  • bus (MessageBus) – The bus to use when providing this service.

  • path (str, optional) – The base dbus path to export this service to.

  • adapter (Adapter, optional) – The adapter that will provide this service or None to select the first adapter.

remove_characteristic(char: characteristic)

Remove the specified characteristic from this service declaration.

Parameters

char (characteristic) – The characteristic to remove.

Raises

ValueError – Raised if the service is registered with the bluez service manager and thus cannot be modified.

async unregister()

Unregister this service. You may only use this if the service was registered using Service.register()

class bluez_peripheral.gatt.service.ServiceCollection(services: Collection[Service] = [])

A collection of services that are registered with the bluez GATT manager as a group.

add_service(service: Service)

Add the specified service to this service collection.

Parameters

service (Service) – The service to add.

is_registered() bool

Check if this service collection is registered with the bluez service manager.

Returns

True if the service is registered. False otherwise.

Return type

bool

async register(bus: MessageBus, path: str = '/com/spacecheese/bluez_peripheral', adapter: Optional[Adapter] = None)

Register this collection of services with the bluez service manager. Services and service collections that are registered may not be modified until they are unregistered.

Parameters
  • bus (MessageBus) – The bus to use for registration and management of this service.

  • path (str, optional) – The base dbus path to use when registering the collection. Each service will be an automatically numbered child of this base.

  • adapter (ProxyObject, optional) – The adapter that should be used to deliver the collection of services.

remove_service(service: Service)

Remove the specified service from this collection.

Parameters

service (Service) – The service to remove.

async unregister()

Unregister this service using the bluez service manager.