From b73cdce5691bf922e4bca81a4a39f84b17c63b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Thu, 5 Feb 2026 15:44:31 +0000 Subject: [PATCH] BLE transport: pass WinRT options to BleakClient Add an optional `winrt` argument to `SMPBLETransport`, store it, and forward it to `BleakClient` during connect. The argument is ignored on non-Windows platforms. --- smpclient/transport/ble.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smpclient/transport/ble.py b/smpclient/transport/ble.py index 8a35af5..2176b29 100644 --- a/smpclient/transport/ble.py +++ b/smpclient/transport/ble.py @@ -8,6 +8,7 @@ from uuid import UUID from bleak import BleakClient, BleakGATTCharacteristic, BleakScanner +from bleak.args.winrt import WinRTClientArgs from bleak.backends.client import BaseBleakClient from bleak.backends.device import BLEDevice from smp import header as smphdr @@ -66,11 +67,12 @@ class SMPBLETransportNotSMPServer(SMPBLETransportException): class SMPBLETransport(SMPTransport): """A Bluetooth Low Energy (BLE) SMPTransport.""" - def __init__(self) -> None: + def __init__(self, winrt: WinRTClientArgs = {}) -> None: self._buffer = bytearray() self._notify_condition = asyncio.Condition() self._disconnected_event = asyncio.Event() self._disconnected_event.set() + self._winrt = winrt self._max_write_without_response_size = 20 """Initially set to BLE minimum; may be mutated by the `connect()` method.""" @@ -90,6 +92,7 @@ async def connect(self, address: str, timeout_s: float) -> None: self._client = BleakClient( device, services=(str(SMP_SERVICE_UUID),), + winrt=self._winrt, disconnected_callback=self._set_disconnected_event, ) else: