Skip to content

Commit 1cdf8b9

Browse files
gudnimggudnimar
authored andcommitted
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.
1 parent 708ba94 commit 1cdf8b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

smpclient/transport/ble.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from uuid import UUID
99

1010
from bleak import BleakClient, BleakGATTCharacteristic, BleakScanner
11+
from bleak.args.winrt import WinRTClientArgs
1112
from bleak.backends.client import BaseBleakClient
1213
from bleak.backends.device import BLEDevice
1314
from smp import header as smphdr
@@ -66,11 +67,12 @@ class SMPBLETransportNotSMPServer(SMPBLETransportException):
6667
class SMPBLETransport(SMPTransport):
6768
"""A Bluetooth Low Energy (BLE) SMPTransport."""
6869

69-
def __init__(self) -> None:
70+
def __init__(self, winrt: WinRTClientArgs={}) -> None:
7071
self._buffer = bytearray()
7172
self._notify_condition = asyncio.Condition()
7273
self._disconnected_event = asyncio.Event()
7374
self._disconnected_event.set()
75+
self._winrt = winrt
7476

7577
self._max_write_without_response_size = 20
7678
"""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:
9092
self._client = BleakClient(
9193
device,
9294
services=(str(SMP_SERVICE_UUID),),
95+
winrt=self._winrt,
9396
disconnected_callback=self._set_disconnected_event,
9497
)
9598
else:

0 commit comments

Comments
 (0)