powerpods/goTool/cmd_tap.go
simon 31e539052a Unify cache polling on CACHE_STATUS and split API docs.
Replace separate accel/tap snapshot UART commands with one clients[] response
that omits unsubscribed fields; remove snapshot handlers and CLI commands.
Add goTool/docs for WebSocket streams and REST; tap-snapshot REST uses CACHE_STATUS.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 21:23:09 +02:00

59 lines
1.5 KiB
Go

package main
import (
"flag"
"fmt"
"powerpod/gotool/pb"
)
func runTapNotify(sp *serialPort, args []string) error {
fs := flag.NewFlagSet("tap-notify", flag.ExitOnError)
write := fs.Bool("set", false, "write tap notify flags (default: read)")
clientID := fs.Uint("client", 0, "client id (>0 required for read/set one slave)")
all := fs.Bool("all", false, "apply to all registered slaves (with -set)")
single := fs.Bool("single", false, "notify on single tap")
doubleTap := fs.Bool("double", false, "notify on double tap")
triple := fs.Bool("triple", false, "notify on triple tap")
if err := fs.Parse(args); err != nil {
return err
}
if !*write && (*all || *clientID == 0) {
return fmt.Errorf("read requires -client <id>")
}
if *write && !*all && *clientID == 0 {
return fmt.Errorf("set requires -client <id> or -all")
}
r, err := sp.TapNotify(&pb.TapNotifyRequest{
Write: *write,
ClientId: uint32(*clientID),
AllClients: *all,
Single: *single,
DoubleTap: *doubleTap,
Triple: *triple,
})
if err != nil {
return err
}
fmt.Printf("client_id=%d success=%v slaves_updated=%d single=%v double=%v triple=%v\n",
r.GetClientId(), r.GetSuccess(), r.GetSlavesUpdated(),
r.GetSingle(), r.GetDoubleTap(), r.GetTriple())
return nil
}
func tapKindLabel(k pb.TapKind) string {
switch k {
case pb.TapKind_TAP_SINGLE:
return "single"
case pb.TapKind_TAP_DOUBLE:
return "double"
case pb.TapKind_TAP_TRIPLE:
return "triple"
default:
return "none"
}
}