From 88f552cb65a778262fe8cf51d2b0691a6ce241be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lobodinsky=CC=81?= Date: Fri, 31 Dec 2021 08:40:37 +0100 Subject: [PATCH] Fixed BLE connections to Hubs under macOS 12 Addresses #23. --- CONTRIBUTING.md | 17 +++++++++++++++++ pybricksdev/ble/__init__.py | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 443e465..1ae6249 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,3 +36,20 @@ Python VS Code extension so that it does not modify the `.vscode/settings.json` file in the project when you select the interpreter. [DeprecatePythonPath]: https://github.com/microsoft/vscode-python/wiki/AB-Experiments#deprecatepythonpath + +### Test your changes + +#### Run a script on your Hub + + poetry run pybricksdev run ble test.py + +#### Build and install your changes globally + + poetry build + pipx install --force ./dist/pybricksdev-1.0.0a19.tar.gz + +#### Inject a custom dependency + +For instance, if you want the installed `pybricksdev` to use code from the `develop` branch of the `bleak` package. + + pipx inject pybricksdev https://github.com/hbldh/bleak/archive/refs/heads/develop.zip diff --git a/pybricksdev/ble/__init__.py b/pybricksdev/ble/__init__.py index 2530260..12819de 100644 --- a/pybricksdev/ble/__init__.py +++ b/pybricksdev/ble/__init__.py @@ -54,7 +54,9 @@ def match_uuid_and_name(device: BLEDevice, adv: AdvertisementData): return True - device = await BleakScanner.find_device_by_filter(match_uuid_and_name, timeout) + device = await BleakScanner.find_device_by_filter( + match_uuid_and_name, timeout, service_uuids=[service] + ) if device is None: raise asyncio.TimeoutError