Add BLE RTT/stream tests and live tick median in the UI, fix concurrent WebSocket writes and late BATTERY replies, and skip 2M PHY updates that assert under ESP-NOW coexistence. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package main
|
||
|
||
import (
|
||
"flag"
|
||
"fmt"
|
||
)
|
||
|
||
func runBleStream(h hostConn, args []string) error {
|
||
fs := flag.NewFlagSet("ble-stream", flag.ExitOnError)
|
||
clientID := fs.Uint("client", 0, "slave client id (0 = all_clients)")
|
||
periodMs := fs.Uint("period", 16, "BLE push period_ms (8–16)")
|
||
count := fs.Int("count", 50, "number of BleStreamTick samples")
|
||
tolMs := fs.Float64("tol", 2.0, "tolerance ms around period for window_ok")
|
||
duration := fs.Float64("timeout", 15.0, "max seconds waiting for ticks")
|
||
if err := fs.Parse(args); err != nil {
|
||
return err
|
||
}
|
||
|
||
fmt.Printf("accel stream on; period_ms=%d; collecting %d ticks…\n", *periodMs, *count)
|
||
out := measureBleStream(h, uint32(*clientID), uint32(*periodMs), *count, *tolMs, *duration)
|
||
if !out.Success {
|
||
return fmt.Errorf("%s", out.Error)
|
||
}
|
||
fmt.Printf("received=%d/%d period_ms=%d tol=±%.1f ms\n", out.Received, out.Requested, out.PeriodMs, out.TolMs)
|
||
printStat("dT ESP inter-depart", out.DTEsp)
|
||
printStat("dR PC inter-arrive", out.DRPc)
|
||
printStat("extra vs first", out.ExtraVsFirst)
|
||
fmt.Printf("outside_tol=%d/%d window_ok=%s\n", out.OutsideTol, out.DTEsp.N,
|
||
map[bool]string{true: "yes", false: "no"}[out.WindowOK])
|
||
return nil
|
||
}
|
||
|
||
func printStat(name string, s latencyStats) {
|
||
if s.N == 0 {
|
||
fmt.Printf("%s: (none)\n", name)
|
||
return
|
||
}
|
||
fmt.Printf("%s: n=%d min=%.3f median=%.3f mean=%.3f max=%.3f ms\n",
|
||
name, s.N, s.MinMs, s.MedMs, s.MeanMs, s.MaxMs)
|
||
}
|