API reference¶
Contents:
Class representing BLE devices¶
Generated by bleak.discover()
and bleak.backends.scanning.BaseBleakScanner
.
Wrapper class for Bluetooth LE servers returned from calling
bleak.discover()
.
Created on 2018-04-23 by hbldh <henrik.blidh@nedomkull.com>
-
class
bleak.backends.device.
BLEDevice
(address: str, name: Optional[str], details: Any, rssi: int, **kwargs)[source]¶ A simple wrapper class representing a BLE server detected during scanning.
-
address
¶ The Bluetooth address of the device on this machine (UUID on macOS).
-
details
¶ The OS native details required for connecting to the device.
-
property
metadata
¶ Gets additional advertisement data for the device.
Deprecated since version 0.19.0: Use
AdvertisementData
from detection callback orBleakScanner.discovered_devices_and_advertisement_data
instead.
-
name
¶ The operating system name of the device (not necessarily the local name from the advertising data), suitable for display to the user.
-
property
rssi
¶ Gets the RSSI of the last received advertisement.
Deprecated since version 0.19.0: Use
AdvertisementData
from detection callback orBleakScanner.discovered_devices_and_advertisement_data
instead.
-
GATT objects¶
Gatt Service Collection class and interface class for the Bleak representation of a GATT Service.
Created on 2019-03-19 by hbldh <henrik.blidh@nedomkull.com>
-
class
bleak.backends.service.
BleakGATTService
(obj)[source]¶ Interface for the Bleak representation of a GATT Service.
-
abstract
add_characteristic
(characteristic: bleak.backends.characteristic.BleakGATTCharacteristic)[source]¶ Add a
BleakGATTCharacteristic
to the service.Should not be used by end user, but rather by bleak itself.
-
abstract property
characteristics
¶ List of characteristics for this service
-
property
description
¶ String description for this service
-
get_characteristic
(uuid: Union[str, uuid.UUID]) → Optional[bleak.backends.characteristic.BleakGATTCharacteristic][source]¶ Get a characteristic by UUID.
- Parameters
uuid – The UUID to match.
- Returns
The first characteristic matching
uuid
orNone
if no matching characteristic was found.
-
abstract property
handle
¶ The handle of this service
-
abstract property
uuid
¶ The UUID to this service
-
abstract
-
class
bleak.backends.service.
BleakGATTServiceCollection
[source]¶ Simple data container for storing the peripheral’s service complement.
-
add_characteristic
(characteristic: bleak.backends.characteristic.BleakGATTCharacteristic)[source]¶ Add a
BleakGATTCharacteristic
to the service collection.Should not be used by end user, but rather by bleak itself.
-
add_descriptor
(descriptor: bleak.backends.descriptor.BleakGATTDescriptor)[source]¶ Add a
BleakGATTDescriptor
to the service collection.Should not be used by end user, but rather by bleak itself.
-
add_service
(service: bleak.backends.service.BleakGATTService)[source]¶ Add a
BleakGATTService
to the service collection.Should not be used by end user, but rather by bleak itself.
-
property
characteristics
¶ Returns dictionary of handles mapping to BleakGATTCharacteristic
-
property
descriptors
¶ Returns a dictionary of integer handles mapping to BleakGATTDescriptor
-
get_characteristic
(specifier: Union[int, str, uuid.UUID]) → Optional[bleak.backends.characteristic.BleakGATTCharacteristic][source]¶ Get a characteristic by handle (int) or UUID (str or uuid.UUID)
-
get_descriptor
(handle: int) → Optional[bleak.backends.descriptor.BleakGATTDescriptor][source]¶ Get a descriptor by integer handle
-
get_service
(specifier: Union[int, str, uuid.UUID]) → Optional[bleak.backends.service.BleakGATTService][source]¶ Get a service by handle (int) or UUID (str or uuid.UUID)
-
property
services
¶ Returns dictionary of handles mapping to BleakGATTService
-
Interface class for the Bleak representation of a GATT Characteristic
Created on 2019-03-19 by hbldh <henrik.blidh@nedomkull.com>
-
class
bleak.backends.characteristic.
BleakGATTCharacteristic
(obj: Any, max_write_without_response_size: int)[source]¶ Interface for the Bleak representation of a GATT Characteristic
-
abstract
add_descriptor
(descriptor: bleak.backends.descriptor.BleakGATTDescriptor)[source]¶ Add a
BleakGATTDescriptor
to the characteristic.Should not be used by end user, but rather by bleak itself.
-
property
description
¶ Description for this characteristic
-
abstract property
descriptors
¶ List of descriptors for this service
-
abstract
get_descriptor
(specifier: Union[int, str, uuid.UUID]) → Optional[bleak.backends.descriptor.BleakGATTDescriptor][source]¶ Get a descriptor by handle (int) or UUID (str or uuid.UUID)
-
abstract property
handle
¶ The handle for this characteristic
-
property
max_write_without_response_size
¶ Gets the maximum size in bytes that can be used for the data argument of
BleakClient.write_gatt_char()
whenresponse=False
.Warning
Linux quirk: For BlueZ versions < 5.62, this property will always return
20
.New in version 0.16.0.
-
abstract property
properties
¶ Properties of this characteristic
-
abstract property
service_handle
¶ The integer handle of the Service containing this characteristic
-
abstract property
service_uuid
¶ The UUID of the Service containing this characteristic
-
abstract property
uuid
¶ The UUID for this characteristic
-
abstract
Interface class for the Bleak representation of a GATT Descriptor
Created on 2019-03-19 by hbldh <henrik.blidh@nedomkull.com>
-
class
bleak.backends.descriptor.
BleakGATTDescriptor
(obj: Any)[source]¶ Interface for the Bleak representation of a GATT Descriptor
-
abstract property
characteristic_handle
¶ handle for the characteristic that this descriptor belongs to
-
abstract property
characteristic_uuid
¶ UUID for the characteristic that this descriptor belongs to
-
property
description
¶ A text description of what this descriptor represents
-
abstract property
handle
¶ Integer handle for this descriptor
-
abstract property
uuid
¶ UUID for this descriptor
-
abstract property
Exceptions¶
-
exception
bleak.exc.
BleakDBusError
(dbus_error: str, error_body: list)[source]¶ Specialized exception type for D-Bus errors.
-
property
dbus_error
¶ Gets the D-Bus error name, e.g.
org.freedesktop.DBus.Error.UnknownObject
.
-
property
dbus_error_details
¶ Gets the optional D-Bus error details, e.g. ‘Invalid UUID’.
-
property
Utilities¶
Deprecated¶
-
bleak.
discover
(*args, **kwargs)[source]¶ Deprecated since version 0.17.0: This method will be removed in a future version of Bleak. Use
BleakScanner.discover()
instead.