debug(meshcore): enable BLE debug mode and disconnect before connect

- Enable debug=True on MeshCore.create_ble() to surface verbose logs
- Disconnect any existing BlueZ connection before bleak connects to
  avoid conflicts from prior bluetoothctl/pairing sessions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-05-13 21:15:24 +01:00
parent b26d94c967
commit 77cdd56641
+14 -1
View File
@@ -107,7 +107,20 @@ class AsyncWorker:
self._mc = await MeshCore.create_tcp(host=cfg.host, port=cfg.port, debug=False)
transport, device = "tcp", f"{cfg.host}:{cfg.port}"
elif isinstance(cfg, BLEConfig):
self._mc = await MeshCore.create_ble(address=cfg.device_address, debug=False)
# Disconnect any existing BlueZ connection so bleak gets a clean slate
if cfg.device_address:
try:
import subprocess
subprocess.run(
["bluetoothctl", "disconnect", cfg.device_address],
timeout=3,
capture_output=True,
)
await asyncio.sleep(1.0)
except Exception:
pass
self._mc = await MeshCore.create_ble(address=cfg.device_address, debug=True)
transport, device = "ble", cfg.device_address or "auto"
else:
raise RuntimeError(f"Unknown connection config type: {type(cfg)}")