Skip to content

Releases: hbldh/bleak

v3.0.2

02 May 23:00

Choose a tag to compare

Changed

  • Changed default value of BlueZNotifyArgs.use_start_notify to False. Fixes #1951.

v3.0.1

25 Mar 15:42

Choose a tag to compare

Fixed

  • Fixed AttributeError in start_notify() and stop_notify() on Android. Fixes #1834.

v3.0.0

22 Mar 16:54

Choose a tag to compare

Migration guide

There are only some small breaking changes, so hopefully most users can upgrade without any changes.

The exception is if your project is handling OS-specific exceptions on the GATT read and write methods. These exceptions are now wrapped in BleakGATTProtocolError to have a consistent cross-platform exception. If you need to support multiple versions of Bleak, you can catch both exceptions.

For example, if you caught BleakDBusError and parsed the string to get the GATT error, you can now catch BleakGATTProtocolError instead and it has a code property to get the actual error code.

Another change of note is the deprecation of the adapter keyword argument. We know there are lots of users of this, so we intend to have a long deprecation cycle for this (several years). If you need to support multiple versions of Bleak, you can pass both the old kwarg adapter="hci0" and the new bluez={"adapter": "hci0"} and optionally suppress the deprecation warning. Otherwise, you can just replace the old arg with the new arg as seen in the previous example.

Changelog

Added

  • Added adapter attribute to bleak.args.bluez.BlueZClientArgs and bleak.args.bluez.BlueZScannerArgs.
  • Added bluez keyword argument to BleakClient.
  • Added new bleak.args.bluez.BlueZClientArgs class.
  • Added bleak.exc.BleakGATTProtocolError and bleak.exc.BleakGATTProtocolErrorCode classes.
  • Added type hints and documentation for use_cached kwarg for read_gatt_char() and read_gatt_descriptor() methods in BleakClient.
  • Added support for "use_cached" kwarg to read_gatt_char() and read_gatt_descriptor() methods in BlueZ backend.

Changed

  • Deprecated adapter keyword argument in BleakScanner and BleakClient.
  • Changed GATT read and write methods to raise BleakGATTProtocolError when a GATT protocol error occurs.
  • Changed start/stop scanning on CoreBluetooth so that the isScanning property is not checked anymore.
  • Changed BleakClient.write_gatt_descriptor() to raise ValueError when attempting to write to the descriptor 0x2902 (Client Characteristic Configuration Descriptor, CCCD). Use start_notify() and stop_notify() instead.

Fixed

  • Fixed occasional EOFError when disconnecting in BlueZ backend. Fixes #1921.
  • Fixed a potential deadlock when turning off Bluetooth manually while starting scanning on CoreBluetooth.
  • Fixed reading descriptors 0x2900, 0x2902 and 0x2903 on CoreBluetooth backend.
  • Fixed cyclic references problem in CoreBluetooth backend causing memory leaks.
  • Fixed typehint for BleakScanner.__aexit__().

Removed

  • Removed undocumented/deprecated device keyword argument from BleakScannerBlueZDBus and BleakClientBlueZDBus.

v2.1.1

31 Dec 20:43

Choose a tag to compare

Changed

  • Changed default connect timeout for BleakClient from 10 to 30 seconds.

Fixed

  • Fixed some cases of BleakError: Could not get GATT services: Unreachable in WinRT backend by adding a retry when getting GATT services.

v2.1.0

28 Dec 19:42

Choose a tag to compare

Added

  • Added bluez parameter to BleakClient.start_notify() to allow forcing using "StartNotify" instead of "AcquireNotify" on BlueZ backend. Fixes #1885.
  • Added bleak.args.SizedBuffer type for better type hinting of buffer protocol parameters.

Fixed

  • Fixed calling logging.debug() in WinRT backend. Fixes #1882.
  • Fixed calling logging.warning() in BlueZ backend.

v2.0.0

22 Nov 18:21

Choose a tag to compare

Added

  • Added bleak.backends.get_default_backend() and BleakBackend enum for a centralized backend detection.
  • Added BleakClient().backend_id and BleakScanner().backend_id properties to identify the backend in use.

Changed

  • Use "AcquireNotify" rather than "StartNotify" for Linux backend on supported characteristics
  • Allow multiple calls to disconnect() on Windows to align behavior over all backends.
  • Raise new BleakBluetoothNotAvailableError when Bluetooth is not supported, turned off or permission is denied.

Fixed

  • Fixed potential race condition causing timeout while connecting in WinRT backend.
  • Fixed file handle leak in BlueZ backend when D-Bus connection is lost and re-established.
  • Fixed crash in CoreBluetooth backend if an ObjC delegate callback is called after the asyncio run loop stops.
  • Fixed possible deadlock when starting scanning on Windows when Bluetooth is turned off.
  • Fixed "Bluetooth device is turned off" Exception on macOS, when a Bluetooth permission request popup is shown to the user by the OS.

Removed

  • Removed support for Python 3.9.
  • Removed support for macOS < 10.15.

v1.1.1

07 Sep 18:44

Choose a tag to compare

Fixed

  • Fixed D-Bus connection leak on connection failure in BlueZ backend.
  • Fixed characteristic's max write without response size using wrong characteristic's value. Fixes #1820.
  • Fixed AttributeError in Python4Android backend when accessing is_connected before connecting. Fixes #1791.

v1.1.0

10 Aug 22:49

Choose a tag to compare

Added

  • Added support for Pythonista iOS app backend.
  • Added BleakClient.name property for getting the peripheral's name. Fixes #1802.

Fixed

  • Fixed BleakClient.connect() on Android when service characteristics have descriptors. Fixes #1803.
  • Fixed disconnect callback not called on Windows when Bleak initiates disconnection.

v1.0.1

30 Jun 23:08

Choose a tag to compare

Changed

  • Added deprecation warnings for importing bleak.args.* types from bleak.backends.*.

Fixed

  • Restored **kwargs in BLEDevice() constructor. Fixes #1783.
  • Restored importing OrPattern from bleak.backends.bluezdbus.advertisement_monitor.

v1.0.0

28 Jun 22:13

Choose a tag to compare

Added

  • Added pair parameter to BleakClient() constructor to allow pairing before connecting. Fixes #309.
  • Added notification_discriminator parameter to start_notify() on CoreBluetooth backend. Merged #1742.

Changed

  • Enabled extended advertising scanning in the WinRT backend. Merged #1705.
  • Made response argument of class BleakClient.write_gatt_char() explicitly optional. Fixes #1730.
  • Updated Poetry build system version to >=2.0. Merged #1718.
  • Log to stderr instead of stdout when BLEAK_LOGGING is enabled. Merged #1709.
  • Updated winrt backend to use PyWinRT >= 3.1.
  • Changed return type of connect(), disconnect(), pair() and unpair() methods to None.
  • Moved backend-specific arg types to new bleak.args sub-package.
  • BLEDevice.name will now return None instead of the address when the name is not available. Merged #1762.
  • Deprecated protection_level kwarg for pairing in WinRT backend. Merged #1770.

Fixed

  • Fixed resolvable private address not updated after connecting in BlueZ backend. Fixes #1737.
  • Fixed possible KeyError when getting services in BlueZ backend. Fixes #1435.
  • Fix D-Bus connection leak when connecting to a device fails in BlueZ backend. Fixes #1698.
  • Fixed possible deadlock when connecting on WinRT backend when device is already connected. Fixes #1757.
  • Fixed getting notifications from devices connected to BLE adapters with index >9 (hci10, hci11, ...). Merged #1744.
  • Fixed ATT error code 15 description to "Insufficient Encryption". Merged #1746.

Removed

  • Removed support for Python 3.8. The minimum supported version is now Python 3.9.
  • Removed deprecated parameters, properties and methods.
  • Removed support for macOS < 10.13.
  • Removed support for BlueZ < 5.55.