Repository navigation
feat(holmanctl): add --run and --stop for one-shot tap control - #11
Merged
Merged
Conversation
Re-implements #3 on the current codebase so holmanctl can be used from scripts and cron: `holmanctl --connect <MAC> --run MINUTES` or `--stop` connects, writes the command, disconnects and exits. SDK: - TapTimerListener gains timer_written() and timer_write_failed(error) events, fired for writes to the manual characteristic. The base class provides no-op defaults so existing listeners keep working. holmanctl: - --run takes 1-255 minutes, validated by argparse; --run and --stop are mutually exclusive and require --connect - Disconnects after the write instead of leaving BlueZ holding the connection - Exits 1 if connecting or writing fails, instead of 0. main() now returns the exit code rather than calling sys.exit() inside callbacks - Skips run() when the outcome is already known, since gatt can report a connect failure synchronously before the loop starts, and stop() is a no-op then; run() would otherwise block forever Co-authored-by: Hamish Moffatt <hamish@moffatt.id.au> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T53VSjKogcDk3z3avG76Ay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-implements #3 by @hmoffatt on the current codebase, so
holmanctlcan start or stop the tap from a script or cron job and exit:It connects, writes the command, disconnects and exits: 0 if the tap timer accepted the command, 1 if connecting or writing failed. Hamish is credited as co-author on the commit.
#3 conflicts with
master(it predates BTX1 support and #10's reformatting), so this is a fresh implementation. It also fixes the problems found when reviewing it.SDK
TapTimerListenergains two events,timer_written()andtimer_write_failed(error), fired for writes to the manual characteristic (start()/stop()).listener.timer_written()without adding it to the base class, so every existing listener (including the README example) raisedAttributeErrorafterstart()orstop().holmanctl
--runaccepts 1-255 minutes, checked by argparse. Previously-5crashed mid-connection and600was silently capped at 255.--runand--stopare mutually exclusive and require--connect.main()now returns the exit code (the console-script wrapper passes it tosys.exit) instead of callingsys.exit()inside D-Bus callbacks.connect(), before the event loop starts, andDeviceManager.stop()is a no-op untilrun()has started.main()now skipsrun()once the listener has finished; otherwise an unknown MAC would block forever.Behaviour changes for existing commands
--connect/--autoconnection failures now exit 1 instead of 0.Tests
simulated_tap_timerfixture plays connect → resolve → write → disconnect through the realTapTimerandholmanctlcode, with switches for connect and write failures.DeviceManager.stop()now matches gatt's no-op-before-run()behaviour.finishedcheck each makes its test fail.Test plan
uv run pytest(47 passed),ruff check,ruff format --check,pyrefly check--run 1starts the tap and the process exits 0;--stopstops it; an out-of-range or wrong MAC exits 1 without hanging--run, the phone app can connect straight away (confirms the disconnect)🤖 Generated with Claude Code
https://claude.ai/code/session_01T53VSjKogcDk3z3avG76Ay