From e59fa3ad8a132a6ed9cf0bb85f8d2b3862daf582 Mon Sep 17 00:00:00 2001 From: Tomi Tuhkanen Date: Sat, 27 Jul 2024 11:11:35 +0300 Subject: [PATCH] feat: use bleak as default adapter on all platforms (#249) --- CHANGELOG.md | 1 + README.md | 6 ++---- ruuvitag_sensor/adapters/__init__.py | 14 ++++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4c6be..eb85bcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index ffa18e1..d24cfab 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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" diff --git a/ruuvitag_sensor/adapters/__init__.py b/ruuvitag_sensor/adapters/__init__.py index ab1b964..b0103bf 100644 --- a/ruuvitag_sensor/adapters/__init__.py +++ b/ruuvitag_sensor/adapters/__init__.py @@ -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):