omi icon indicating copy to clipboard operation
omi copied to clipboard

Python BLE listeners remain pending after device disconnection

Open yunancun opened this issue 2 months ago • 2 comments

At e0308b66dd699bed67dc59be1f1e47237c81f387, both sdks/python/omi/ble.py::listen() and sdks/python/omi/bluetooth.py::listen_to_omi() start notifications and then wait on fixed sleeps without registering Bleak's disconnect callback. If the peripheral disconnects, a caller awaiting the listener receives no terminal signal; the high-level listener waits indefinitely and the legacy listener waits until its 99,999-second sleep ends. An offline harness invoking both actual SDK functions with a simulated Bleak client reproduces two disconnect timeouts; four cancellation/setup-error controls pass. A local candidate uses Bleak's documented disconnected_callback and an asyncio.Event, then raises ConnectionError to let the caller handle reconnection; all six cases pass on macOS/Python 3.10.1 with the SDK's pinned Bleak 0.22.3. Audio callback delivery is checked before disconnect/cancel. This tests the Python lifecycle boundary, not a physical device or the operating system Bluetooth stack; the snapshot omits the package initializer and unrelated modules, and no full SDK suite or repository preflight has run. Related #13011 discusses shared SDK session contracts; this report concerns BLE listener termination, separate from the STT sender/receiver fixes. @josancamon19, under the contribution guide's paid-work proposal process, would you approve US$10 through the documented private PayPal process after acceptance and merge for this scoped fix, regression tests, and API documentation? Please confirm whether disconnection should raise ConnectionError or return normally before a full PR. This contribution and its verification are prepared by OpenAI Codex for @yunancun; no award, reservation, human review, or payment is assumed. Payment details would stay private.

yunancun avatar Sep 09 '26 09:09 yunancun

I have implemented this fix and added comprehensive regression test coverage in PR #13315.

/claim #13290

CreamPle avatar Sep 09 '26 13:09 CreamPle

Opened https://github.com/BasedHardware/omi/pull/13580 — Fixes #13290. Hermetic BLE listener tests: 17 passed (disconnect + existing callback/service-scope suites). No live adapter.

Da7em-T avatar Sep 12 '26 11:09 Da7em-T