Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions catprinter/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from bleak import BleakClient, BleakScanner
from bleak.backends.scanner import AdvertisementData
from bleak.backends.device import BLEDevice
from bleak.backends.bluezdbus.client import BleakClientBlueZDBus
from catprinter import logger

# For some reason, bleak reports the 0xaf30 service on my macOS, while it reports
Expand Down Expand Up @@ -96,6 +97,11 @@ async def run_ble(data, device: Optional[str]):
return
logger.info(f"⏳ Connecting to {address}...")
async with BleakClient(address) as client:
# XXX: BlueZ incorrectly reports a fixed MTU of 23; force MTU negotiation manually.
# https://bleak.readthedocs.io/en/latest/api/client.html#bleak.BleakClient.mtu_size
if isinstance(client, BleakClientBlueZDBus):
await client._acquire_mtu()

logger.info(f"✅ Connected: {client.is_connected}; MTU: {client.mtu_size}")
chunk_size = client.mtu_size - 3
event = asyncio.Event()
Expand Down
Loading