Skip to content

fix(ble): register the disconnect callback with Bleak 3.x (ROADMAP 1.7) - #35

Merged
SeanathanVT merged 1 commit into
developmentfrom
bugfix/ble-disconnect-callback
Nov 11, 2026
Merged

SeanathanVT merged 1 commit into
developmentfrom
bugfix/ble-disconnect-callback

Conversation

@SeanathanVT

Copy link
Copy Markdown
Owner

Summary

Bleak 3.x takes the disconnect callback only as a BleakClient constructor argument, and ph4-walkingpad's Controller.connect() passes none. The old set_disconn_callback/set_disconnected_callback branches never ran on Bleak 3.x, so a drop was only noticed by the staleness watchdogs (~15 s active, ~45 s idle/paused). The test fake had set_disconn_callback, which hid this.

  • app.Controller subclasses the library's Controller and overrides connect() to pass disconnected_callback=_handle_disconnect.
  • Removed the dead old-API branches and their tests.
  • _graceful_shutdown() clears connected before its own disconnect, so the now-live callback doesn't log it as a drop or record an auto-pause.

Testing

  • New test checks the arguments against the real BleakClient signature, not the fake.
  • New test: shutdown's own disconnect isn't treated as a drop (fails without the fix).
  • pytest on 3.10, 3.12, 3.13 (557 passed each); ruff check . clean.
  • Manual on macOS: power off the pad mid-session; the session should pause and reconnect start immediately, not after ~15 s.

Notes

The connect() override mirrors the library's code, so upstream changes to it won't be picked up; ph4-walkingpad is pinned <2.

🤖 Generated with Claude Code

- Override Controller.connect() to pass disconnected_callback to BleakClient
- Drop the dead set_disconn_callback/set_disconnected_callback branches
- Clear connected before shutdown's own disconnect so it isn't a drop
- Test the argument against the real BleakClient signature

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SeanathanVT SeanathanVT added the bug Something isn't working label Nov 11, 2026
@SeanathanVT
SeanathanVT merged commit 16e357b into development Nov 11, 2026
2 checks passed
@SeanathanVT
SeanathanVT deleted the bugfix/ble-disconnect-callback branch November 11, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant