From 1ce9aae1a22f68c39d8b183c39a800f8be488848 Mon Sep 17 00:00:00 2001 From: Tim Camise Date: Tue, 15 Aug 2023 13:00:47 -0700 Subject: [PATCH] Check for pairing differently on newer bluez versions --- .../open_gopro/ble/adapters/bleak_wrapper.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py b/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py index abbb1fce..5f3a2ef3 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/ble/adapters/bleak_wrapper.py @@ -8,6 +8,7 @@ import logging import platform import threading +from packaging.version import Version from typing import Pattern, Any, Callable, Optional import pexpect @@ -307,9 +308,18 @@ async def _async_def_pair() -> None: if logger.level == logging.DEBUG: bluetoothctl.logfile = sys.stdout.buffer bluetoothctl.expect("Agent registered") + # Get the version + bluetoothctl.sendline("version") + bluetoothctl.expect(r"Version") + bluetoothctl.expect(r"\n") + version = Version(bluetoothctl.before.decode("utf-8").strip()) # First see if we are already paired - bluetoothctl.sendline("paired-devices") - bluetoothctl.expect("paired-devices") + if version >= Version("5.66"): + bluetoothctl.sendline("devices Paired") + bluetoothctl.expect("devices Paired") + else: + bluetoothctl.sendline("paired-devices") + bluetoothctl.expect("paired-devices") bluetoothctl.expect(r"#") for device in bluetoothctl.before.decode("utf-8").splitlines(): if "Device" in device and device.split()[1] == handle.address: