Skip to content

Commit

Permalink
feat: use bleak as default adapter on all platforms (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttu committed Jul 27, 2024
1 parent c501d94 commit e59fa3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### [Unreleased]
* ADD: Install Bleak automatically on all platforms
* CHANGE: Async Bleak adapter as default adapter on all platforms

## [2.3.1] - 2024-03-10
* ADD: Bluez as option to RUUVI_BLE_ADAPTER environment variable
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ RuuviTag Sensor Python Package
* Supports [Data Format 2, 3, 4 and 5](https://docs.ruuvi.com/)
* __NOTE:__ Data Formats 2, 3 and 4 are _deprecated_ and should not be used
* [Bleak](https://github.com/hbldh/bleak) communication module (Windows, macOS and Linux)
* Default adapter for Windows and macOS
* Default adapter for all supported operating systems
* Bleak supports
* [Async-methods](#usage)
* [Observable streams](#usage)
* [Install guide](#Bleak)
* Bluez (Linux-only)
* Default adapter for Linux
* Bluez supports
* [Sync-methods](#usage)
* [Observable streams](#usage)
* [Install guide](#BlueZ)
* __NOTE:__ The BlueZ-adapter implementation uses deprecated BlueZ tools that are no longer supported.
* Even though BlueZ is still the default adapter, it is recommended to use the Bleak-communication adapter with Linux. Bleak will be the default adapter for Linux in the next major release.
* Bleson-adapter supports sync-methods, but please be aware that it is not fully supported due to the alpha release status of the Bleson communication module. See [Bleson](#Bleson) for more information.
* Python 3.7+
* For Python 2.x or <3.7 support, check [installation instructions](#python-2x-and-36-and-below) for an older version
Expand Down Expand Up @@ -425,7 +423,7 @@ $ sudo apt-get install bluez bluez-hcidump

`ruuvitag-sensor` package uses internally _hciconfig_, _hcitool_ and _hcidump_. These tools are deprecated. In case tools are missing, an older version of BlueZ is required ([Issue](https://github.com/ttu/ruuvitag-sensor/issues/31))

If you wish to test the library on Windows or macOS, enable it with `RUUVI_BLE_ADAPTER` environment variable.
Enable Bluez with the `RUUVI_BLE_ADAPTER` environment variable.

```sh
$ export RUUVI_BLE_ADAPTER="bluez"
Expand Down
14 changes: 4 additions & 10 deletions ruuvitag_sensor/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,15 @@ def get_ble_adapter():
return BleCommunicationNixFile()

if is_ci_env:
# Use BleCommunicationDummy for CI as it can't use BlueZ
# Use BleCommunicationDummy for CI as it can't use Bleak/BlueZ
from ruuvitag_sensor.adapters.dummy import BleCommunicationDummy

return BleCommunicationDummy()

# Use default adapter for platform
if sys.platform.startswith("win") or sys.platform.startswith("darwin"):
from ruuvitag_sensor.adapters.bleak_ble import BleCommunicationBleak
# Bleak is default adapter for all platforms
from ruuvitag_sensor.adapters.bleak_ble import BleCommunicationBleak

return BleCommunicationBleak()

# BlueZ is default for Linux
from ruuvitag_sensor.adapters.nix_hci import BleCommunicationNix

return BleCommunicationNix()
return BleCommunicationBleak()


def is_async_adapter(ble: object):
Expand Down

0 comments on commit e59fa3a

Please sign in to comment.