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
adapterattribute tobleak.args.bluez.BlueZClientArgsandbleak.args.bluez.BlueZScannerArgs. - Added
bluezkeyword argument toBleakClient. - Added new
bleak.args.bluez.BlueZClientArgsclass. - Added
bleak.exc.BleakGATTProtocolErrorandbleak.exc.BleakGATTProtocolErrorCodeclasses. - Added type hints and documentation for
use_cachedkwarg forread_gatt_char()andread_gatt_descriptor()methods inBleakClient. - Added support for
"use_cached"kwarg toread_gatt_char()andread_gatt_descriptor()methods in BlueZ backend.
Changed
- Deprecated
adapterkeyword argument inBleakScannerandBleakClient. - Changed GATT read and write methods to raise
BleakGATTProtocolErrorwhen a GATT protocol error occurs. - Changed start/stop scanning on CoreBluetooth so that the
isScanningproperty is not checked anymore. - Changed
BleakClient.write_gatt_descriptor()to raiseValueErrorwhen attempting to write to the descriptor 0x2902 (Client Characteristic Configuration Descriptor, CCCD). Usestart_notify()andstop_notify()instead.
Fixed
- Fixed occasional
EOFErrorwhen 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
devicekeyword argument fromBleakScannerBlueZDBusandBleakClientBlueZDBus.