File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 66from bleak import BleakClient , BleakScanner
77from bleak .backends .scanner import AdvertisementData
88from bleak .backends .device import BLEDevice
9+ from bleak .backends .bluezdbus .client import BleakClientBlueZDBus
910from catprinter import logger
1011
1112# For some reason, bleak reports the 0xaf30 service on my macOS, while it reports
@@ -96,6 +97,11 @@ async def run_ble(data, device: Optional[str]):
9697 return
9798 logger .info (f"⏳ Connecting to { address } ..." )
9899 async with BleakClient (address ) as client :
100+ # XXX: BlueZ incorrectly reports a fixed MTU of 23; force MTU negotiation manually.
101+ # https://bleak.readthedocs.io/en/latest/api/client.html#bleak.BleakClient.mtu_size
102+ if isinstance (client , BleakClientBlueZDBus ):
103+ await client ._acquire_mtu ()
104+
99105 logger .info (f"✅ Connected: { client .is_connected } ; MTU: { client .mtu_size } " )
100106 chunk_size = client .mtu_size - 3
101107 event = asyncio .Event ()
You can’t perform that action at this time.
0 commit comments