BluezDbus Advertisement Module¶
API¶
- class able.bluezdbus.advertisement.BluezLEAdvertisement(advert_wrapper, local_name='BLE Peripheral', advertisement_type=AdvertisementType.PERIPHERAL)[source]¶
Class implementation of the BLE Advertisement Service through Dbus-Next, this is specific to the Linux platform and serves as the low level handler for individual advertisements.
Note that right now we have not implemented a check for the advertisement’s length so if you see errors in trying to add an advertisement, try removing some fields and try again, you may be over the max advertising length for your hardware.
Note that the advertisement will also try to be restored if it is detected that the advertisement was released, triggering the application that holds it to refresh the advertisement in an attempt to recover it.
- Parameters
local_name (str) – The name you wish to include within advertisement packets as the local name, defaults to BLE Peripheral
advertisement_type (AdvertisementType, optional) – What type of advertisement this is, see AdvertisementType for the available types.
- add_manufacturer_data(manufacturer_id, manufacturer_data)[source]¶
Updates the manufacturer data of the advertisement to include the specified manufacturer data. Refer to the reference doc above for the limitations on manufacturer data.
TODO(Bernie, Ori): Add limitations for what the manufacturer data can be
- Parameters
manufacturer_id (int) – the id of the manufacturer to add the manufacturer data to, see the Bluetooth Special Interest groups website for what manufacturer id’s are valid to be used in your use case.
manufacturer_data (Union[str, bytes]) – the manufacturer data to add
- Returns
None
- Return type
None
- add_service_data(service_uuid, service_data)[source]¶
Updates the service data of the advertisement to include the specified service data. Refer to the reference doc above for the limitations on service data.
- Raises
ValueError – Will raise a value error if the service_uuid param does not correspond to a service uuid that this advertisement has.
- Parameters
service_uuid (Union[str, uuid.UUID]) – The uuid of the service to add the service data to, this must be a service uuid you have already added to the advertisement.
service_data (Union[str, bytes]) – The service data to include in the advertisement under the service uuid.
- Return type
None- Returns
None
- add_service_uuid(service_uuid)[source]¶
Adds a service uuid to the advertisement object. Must follow the bluez spec for a service uuid otherwise bluez will reject the advertisement.
- Parameters
service_uuid (Union[str, uuid.UUID]) – What service uuid should be added to this advertisement.
- Return type
None- Returns
None
- async update_service_data(service_uuid, service_data)[source]¶
Update previously set service data with new data and refresh the advertisement using the bound application. This can be called after the ABlePeripheralServer that owns this advertisement has started advertising.
- Raises
RuntimeError – Will raise an exception if this advertisement has not yet been added to an application, this is required for refreshing the service data.
- Parameters
service_uuid (Union[str, uuid.UUID]) – the uuid of the service whose service data you are updating.
service_data (Union[str, bytes]) – the service data to overwrite the previous service data with.
- Returns
None
- Return type
None
References¶
For reference of dbus_next see the DBus Next Pypi and the DBus Next Repo. For reference of the members of this implementation see the Bluez Advertising API