Accel/tap use fire-and-forget ESP-NOW with a 10 ms FreeRTOS-safe cadence, OTA recovers from seq gaps and auto-reboots after success, and bootloader app rollback confirms after a stable boot. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package main
|
||
|
||
import (
|
||
"flag"
|
||
"fmt"
|
||
|
||
pb "powerpod/gotool/pb"
|
||
)
|
||
|
||
func runAccelStreamCmd(h hostConn, args []string) error {
|
||
fs := flag.NewFlagSet("accel-stream", flag.ExitOnError)
|
||
clientID := fs.Uint("client", 0, "slave client id (0 with -all)")
|
||
all := fs.Bool("all", false, "all registered clients")
|
||
enable := fs.Bool("enable", true, "enable stream")
|
||
disable := fs.Bool("disable", false, "disable stream")
|
||
period := fs.Uint("period", 0, "BLE push period_ms 10–16 (0=leave/default)")
|
||
if err := fs.Parse(args); err != nil {
|
||
return err
|
||
}
|
||
on := *enable
|
||
if *disable {
|
||
on = false
|
||
}
|
||
if !*all && *clientID == 0 {
|
||
return fmt.Errorf("need -client ID or -all")
|
||
}
|
||
req := &pb.AccelStreamRequest{
|
||
Write: true,
|
||
Enable: on,
|
||
PeriodMs: uint32(*period),
|
||
}
|
||
if *all {
|
||
req.AllClients = true
|
||
} else {
|
||
req.ClientId = uint32(*clientID)
|
||
}
|
||
r, err := hostAccelStream(h, req)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
fmt.Printf("accel-stream: success=%v enabled=%v client_id=%d slaves_updated=%d\n",
|
||
r.GetSuccess(), r.GetEnabled(), r.GetClientId(), r.GetSlavesUpdated())
|
||
return nil
|
||
}
|