Master can speak the same framed protobuf protocol over NimBLE or UART; goTool gains -ble, ble-rtt, and ble-stream timing checks for ESP-NOW coexistence. 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 8–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
|
||
}
|