This commit is contained in:
Aiden
2026-05-13 16:36:43 +10:00
parent 0824f46feb
commit 4e8be74dd9
7 changed files with 181 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ This helper can:
2. Listen for the button frames that are known to appear while disconnected.
3. Optionally transmit response frames when CAM POWER or CALL is observed.
4. Optionally mirror CALL high/low events with matching host responses.
5. Optionally transmit follow-up frames when a watched response frame appears.
Known RCP-origin button frames:
@@ -162,6 +163,18 @@ def parse_args() -> argparse.Namespace:
action="append",
help="hex frame to count when it appears in RX; can be repeated",
)
parser.add_argument(
"--followup-on-watch-frame",
action="store_true",
help="send follow-up frame(s) when any watched frame is observed",
)
parser.add_argument(
"--followup-frame",
type=parse_hex_bytes,
action="append",
help="hex frame to send after a watched frame appears; can be repeated",
)
parser.add_argument("--followup-delay", type=float, default=0.05)
parser.add_argument("--response-delay", type=float, default=0.05)
parser.add_argument("--response-repeat", type=int, default=1)
parser.add_argument("--response-interval", type=float, default=0.2)
@@ -176,7 +189,10 @@ def parse_args() -> argparse.Namespace:
help="with --mirror-call, respond once to CALL high and once to CALL low",
)
parser.add_argument("--prompt", action="store_true", help="pause before listen so you can prepare button presses")
return parser.parse_args()
args = parser.parse_args()
if args.followup_on_watch_frame and not args.followup_frame:
parser.error("--followup-on-watch-frame requires at least one --followup-frame")
return args
def main() -> int:
@@ -187,6 +203,7 @@ def main() -> int:
primer = build_frame(0x00, 0x00, args.latch_primer_command, args.state, args.value)
query = build_frame(0x00, 0x00, args.latch_query_command, args.state, args.value)
responded = False
followup_sent = False
mirrored_call_on = False
mirrored_call_off = False
totals = {name: 0 for name in KNOWN_PATTERNS}
@@ -248,6 +265,11 @@ def main() -> int:
key = hex_preview(frame)
watch_totals[key] += count
emit(f"{stamp} DETECT watch-frame {key} x{count}")
if args.followup_on_watch_frame and not followup_sent:
followup_sent = True
time.sleep(args.followup_delay)
for followup in args.followup_frame or []:
send_frame(ser, emit, "watch follow-up", followup)
if args.mirror_call:
mirrored = False