bluez_peripheral.advert module

class bluez_peripheral.advert.Advertisement(localName: str, serviceUUIDs: Collection[Union[BTUUID, str]], appearance: Union[int, bytes], timeout: int, discoverable: bool = True, packet_type: PacketType = PacketType.PERIPHERAL, manufacturerData: Dict[int, bytes] = {}, solicitUUIDs: Collection[BTUUID] = [], serviceData: Dict[str, bytes] = {}, includes: AdvertisingIncludes = AdvertisingIncludes.NONE, duration: int = 2)

An advertisment for a particular service or collection of services that can be registered and broadcast to nearby devices.

Parameters
  • localName (str) – The device name to advertise.

  • serviceUUIDs (Collection[Union[BTUUID, str]]) – A list of service UUIDs advertise.

  • appearance (Union[int, bytes]) – The appearance value to advertise. See the Bluetooth SIG recognised values.

  • timeout (int) – The time from registration until this advert is removed.

  • discoverable (bool, optional) – Whether or not the device this advert should be general discoverable.

  • packet_type (PacketType, optional) – The type of advertising packet requested.

  • manufacturerData (Dict[int, bytes], optional) – Any manufacturer specific data to include in the advert.

  • solicitUUIDs (Collection[BTUUID], optional) – Array of service UUIDs to attempt to solicit (not widely used).

  • serviceData (Dict[str, bytes], optional) – Any service data elements to include.

  • includes (AdvertisingIncludes, optional) – Fields that can be optionally included in the advertising packet. Only the AdvertisingIncludes.TX_POWER flag seems to work correctly with bluez.

  • duration (int, optional) – Duration of the advert when multiple adverts are ongoing.

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

Register this advert with bluez to start advertising.

Parameters
  • bus (MessageBus) – The message bus used to communicate with bluez.

  • adapter (Adapter, optional) – The adapter to use.

  • path (str, optional) – The dbus path to use for registration.

class bluez_peripheral.advert.AdvertisingIncludes(value)

An enumeration.

APPEARANCE = 2

Device appearance number should be included.

LOCAL_NAME = 4

The local name of this device should be included.

TX_POWER = 1

Transmittion power should be included.

class bluez_peripheral.advert.PacketType(value)

An enumeration.

BROADCAST = 0

The relevant service(s) will be broadcast and do not require pairing.

PERIPHERAL = 1

The relevant service(s) are associated with a peripheral role.