bluez_peripheral.gatt.service module¶
- class bluez_peripheral.gatt.service.Service(uuid, primary=True, includes=None)[source]¶
Bases:
HierarchicalServiceInterfaceCreate a bluetooth service with the specified uuid. Represents an org.bluez.GattService1 instance.
- Parameters:
uuid (str | bytes | UUID | UUID16 | int) – The UUID of this service. A full list of recognized values is provided by the Bluetooth SIG Assigned Numbers
primary (bool) – True if this service is a primary service (instead of a secondary service). False otherwise. Defaults to True.
includes (Collection[Service] | None) – Any services to include in this service. Services must be registered at the time Includes is read to be included.
- add_characteristic(char)[source]¶
Associated a characteristic with this service.
- Parameters:
char (characteristic)
- Return type:
None
- add_child(child)[source]¶
Adds a child service interface.
- Parameters:
child (HierarchicalServiceInterface)
- Return type:
None
- async register(bus, *, path=None, adapter=None)[source]¶
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 | None) – The base dbus path to export this service to.
adapter (Adapter | None) – The adapter that will provide this service or None to select the first adapter.
- Return type:
None
- async unregister()[source]¶
Unregister this service. You may only use this if the service was registered using
Service.register()- Return type:
None
- class bluez_peripheral.gatt.service.ServiceCollection(services=None)[source]¶
Bases:
UniquePathMixin,HierarchicalServiceInterfaceA collection of services that are registered with the bluez GATT manager as a group.
- async register(bus, *, path=None, adapter=None)[source]¶
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 | None) – The base dbus path to use when registering the collection. Each service will be an automatically numbered child of this base.
adapter (Adapter | None) – The adapter that should be used to deliver the collection of services.
- Return type:
None