From 47c75110c9748a43cff9b9d28a5737b3778c7f45 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 29 May 2026 19:11:36 +0200 Subject: [PATCH] Stream slave accel via ESP-NOW with master snapshot cache. Slaves push BMA456 samples at 16ms when enabled; the master caches per client and exposes ACCEL_SNAPSHOT and ACCEL_STREAM over UART. goTool adds dashboard stream controls, HTTP accel-stream routes, and an external WebSocket API with per-connection receive/interval and slave stream commands. Co-authored-by: Cursor --- goTool/README.md | 98 ++++- goTool/accel_stream_ctl.go | 40 ++ goTool/api_accel_stream.go | 220 +++++++++++ goTool/api_serve.go | 3 +- goTool/api_stream.go | 476 ++++++++++++++++++++++++ goTool/client_api.go | 145 +++++++- goTool/cmd_accel.go | 21 +- goTool/cmd_serve.go | 23 +- goTool/dashboard.go | 199 +++++++++- goTool/main.go | 2 +- goTool/pb/uart_messages.pb.go | 581 ++++++++++++++++++++++-------- goTool/webui/index.html | 79 +++- main/CMakeLists.txt | 3 +- main/README.md | 23 +- main/bosch456.c | 2 +- main/client_registry.c | 79 ++++ main/client_registry.h | 17 + main/cmd/cmd_accel_read.c | 34 -- main/cmd/cmd_accel_read.h | 6 - main/cmd/cmd_accel_snapshot.c | 68 ++++ main/cmd/cmd_accel_snapshot.h | 6 + main/cmd/cmd_accel_stream.c | 96 +++++ main/cmd/cmd_accel_stream.h | 6 + main/cmd/cmd_client_info.c | 1 + main/cmd/cmd_handler.c | 6 +- main/esp_now_comm.c | 123 +++++++ main/esp_now_comm.h | 4 + main/powerpod.c | 6 +- main/proto/esp_now_messages.pb.c | 6 + main/proto/esp_now_messages.pb.h | 64 +++- main/proto/esp_now_messages.proto | 18 + main/proto/uart_messages.pb.c | 13 +- main/proto/uart_messages.pb.h | 182 +++++++--- main/proto/uart_messages.proto | 51 ++- main/uart.h | 8 +- 35 files changed, 2409 insertions(+), 300 deletions(-) create mode 100644 goTool/accel_stream_ctl.go create mode 100644 goTool/api_accel_stream.go create mode 100644 goTool/api_stream.go delete mode 100644 main/cmd/cmd_accel_read.c delete mode 100644 main/cmd/cmd_accel_read.h create mode 100644 main/cmd/cmd_accel_snapshot.c create mode 100644 main/cmd/cmd_accel_snapshot.h create mode 100644 main/cmd/cmd_accel_stream.c create mode 100644 main/cmd/cmd_accel_stream.h diff --git a/goTool/README.md b/goTool/README.md index 3f7b122..51fe065 100644 --- a/goTool/README.md +++ b/goTool/README.md @@ -25,7 +25,7 @@ go run . -port /dev/ttyUSB0 clients | `version` | `0x03` | Prints `version` and `git_hash` from firmware | | `clients` | `0x04` | Lists slaves registered on the master via ESP-NOW | | `deadzone` | `0x06` | Get/set accelerometer deadzone LSB (`-set`, `-value`, `-client`, `-all`) | -| `accel` | `0x18` | Read current BMA456 XYZ (raw LSB, ±2g); alias `accel-read` | +| `accel` | `0x18` | Cached slave accel snapshot from master (`ACCEL_SNAPSHOT`); alias `accel-read` | | `unicast-test` | `0x07` | Sends ESP-NOW unicast test to one slave (`-client`, `-seq`) | | `test` | — | Run an automated scenario (JSON configs under `testdata/`) | | `serve` | — | Web dashboard at `http://localhost:8080` (WebSocket live updates) | @@ -62,11 +62,91 @@ Polls the master over UART and pushes state to the browser via WebSocket (Alpine ```bash go run . -port /dev/ttyUSB0 serve go run . -port /dev/ttyUSB0 serve -addr :8080 -interval 2s +go run . -port /dev/ttyUSB0 serve -api-addr :8081 -accel-interval 16ms make gotool-serve PORT=/dev/ttyUSB0 ``` Open [http://localhost:8080](http://localhost:8080) — shows master firmware info and the ESP-NOW client table from `CLIENT_INFO`. +### External API (second HTTP server) + +`serve` starts a separate listener (default **`:8081`**, disable with `-api-addr ""`) for external programs. It shares the same UART connection as the dashboard. + +| Endpoint | Description | +|----------|-------------| +| `GET /` or `GET /api/v1/` | JSON service info (`default_interval_ms`, min/max, `serial_port`) | +| `WebSocket /ws` | Per-connection accel receive + interval; slave ESP-NOW stream control | + +Two layers: + +1. **`set_stream`** — this WebSocket connection: whether to receive `accel` JSON and at what poll rate (1 ms … 10 s per client; server UART poll uses the minimum among active subscribers). +2. **`set_accel_stream`** — firmware: whether a slave sends accel to the master over ESP-NOW (16 ms on the pod). + +Polling runs only when at least one connection has `receive_accel: true` **and** at least one slave streams (via `set_accel_stream` or dashboard `:8080`). + +**Hello** (on connect; accel is off until `set_stream`): + +```json +{"type":"hello","serial_port":"/dev/ttyUSB0","interval_ms":16,"commands":["set_stream","get_stream","set_accel_stream","get_accel_stream"]} +``` + +**Receive accel on this connection** (optional `interval_ms`, default from `-accel-interval`): + +```json +{"type":"set_stream","enable":true,"interval_ms":32} +{"type":"get_stream"} +``` + +Reply: + +```json +{"type":"stream_status","receive_accel":true,"interval_ms":32,"success":true} +``` + +**Slave ESP-NOW stream** (per `client_id`): + +```json +{"type":"set_accel_stream","client_id":16,"enable":true} +{"type":"get_accel_stream","client_id":16} +``` + +Reply: + +```json +{"type":"accel_stream_status","client_id":16,"enabled":true,"success":true} +``` + +**Accel** (only to connections with `receive_accel: true`, and only while slaves stream): + +```json +{"type":"accel","t":1716900123456789012,"success":true,"clients":[{"client_id":16,"valid":true,"x":12,"y":-34,"z":16384,"age_ms":8}]} +``` + +`t` is Unix time in nanoseconds. Each `clients[]` entry is one slave's latest cached sample (raw LSB, ±2g). + +Example (Python): + +```python +import asyncio, json, websockets + +async def main(): + async with websockets.connect("ws://127.0.0.1:8081/ws") as ws: + print(await ws.recv()) # hello + await ws.send(json.dumps({"type": "set_stream", "enable": True, "interval_ms": 16})) + print(await ws.recv()) # stream_status + await ws.send(json.dumps({"type": "set_accel_stream", "client_id": 16, "enable": True})) + print(await ws.recv()) # accel_stream_status + while True: + msg = json.loads(await ws.recv()) + if msg.get("type") != "accel" or not msg.get("success"): + continue + for c in msg.get("clients", []): + if c.get("valid"): + print(c["client_id"], c["x"], c["y"], c["z"]) + +asyncio.run(main()) +``` + If the UART device is unplugged or the port disappears, `serve` keeps running and retries on each poll interval; the UI shows **UART off** until the port is available again. The dashboard can configure nodes using the same UART commands as the CLI: @@ -78,7 +158,21 @@ The dashboard can configure nodes using the same UART commands as the CLI: | Alle Slaves | per-slave ESP-NOW (Master bleibt unverändert; CLI `-all` setzt auch den Master) | | Unicast test | `unicast-test -client ID` | -HTTP API (used by the web UI): `GET/POST /api/deadzone`, `POST /api/unicast-test`, `POST /api/find-me`, `POST /api/restart`, `POST /api/ota` (multipart field `firmware`, max 2 MiB). +HTTP API (used by the web UI): `GET/POST /api/deadzone`, `GET/PUT /api/clients/{id}/accel-stream`, `POST /api/accel-stream` (legacy / `all_clients`), `POST /api/unicast-test`, `POST /api/find-me`, `POST /api/restart`, `POST /api/ota` (multipart field `firmware`, max 2 MiB). + +**Accel stream per slave** (must be enabled before values appear; goTool polls only while at least one slave has stream on): + +```http +GET /api/clients/16/accel-stream +→ {"enabled":false,"client_id":16,"success":true} + +PUT /api/clients/16/accel-stream +Content-Type: application/json +{"enable": true} +→ {"enabled":true,"client_id":16,"success":true} +``` + +Enable all slaves: `POST /api/accel-stream` with `{"write":true,"enable":true,"all_clients":true}`. | UI / API | Behaviour | |----------|-----------| diff --git a/goTool/accel_stream_ctl.go b/goTool/accel_stream_ctl.go new file mode 100644 index 0000000..c434f43 --- /dev/null +++ b/goTool/accel_stream_ctl.go @@ -0,0 +1,40 @@ +package main + +import "sync" + +// accelStreamCtl tracks which slaves the host wants to poll for accel (mirrors firmware). +type accelStreamCtl struct { + mu sync.Mutex + enabled map[uint32]struct{} +} + +func newAccelStreamCtl() *accelStreamCtl { + return &accelStreamCtl{enabled: make(map[uint32]struct{})} +} + +func (c *accelStreamCtl) Set(clientID uint32, on bool) { + c.mu.Lock() + defer c.mu.Unlock() + if on { + c.enabled[clientID] = struct{}{} + } else { + delete(c.enabled, clientID) + } +} + +func (c *accelStreamCtl) Any() bool { + c.mu.Lock() + defer c.mu.Unlock() + return len(c.enabled) > 0 +} + +func (c *accelStreamCtl) SyncFromClients(clients []ClientView) { + c.mu.Lock() + defer c.mu.Unlock() + c.enabled = make(map[uint32]struct{}) + for _, cl := range clients { + if cl.AccelStream { + c.enabled[cl.ID] = struct{}{} + } + } +} diff --git a/goTool/api_accel_stream.go b/goTool/api_accel_stream.go new file mode 100644 index 0000000..cab1cbb --- /dev/null +++ b/goTool/api_accel_stream.go @@ -0,0 +1,220 @@ +package main + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + + "powerpod/gotool/pb" +) + +type accelStreamAPIRequest struct { + Write bool `json:"write"` + Enable bool `json:"enable"` + ClientID uint32 `json:"client_id"` + AllClients bool `json:"all_clients"` +} + +type accelStreamAPIResponse struct { + Enabled bool `json:"enabled"` + ClientID uint32 `json:"client_id"` + Success bool `json:"success"` + SlavesUpdated uint32 `json:"slaves_updated"` + Error string `json:"error,omitempty"` +} + +type clientAccelStreamBody struct { + Enable bool `json:"enable"` +} + +func mountAccelStreamAPI(mux *http.ServeMux, link *managedSerial, hub *wsHub, ctl *accelStreamCtl) { + mux.HandleFunc("GET /api/clients/{clientID}/accel-stream", func(w http.ResponseWriter, r *http.Request) { + clientID, err := parsePathClientID(r) + if err != nil { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: err.Error()}) + return + } + serveAccelStreamGet(w, clientID, link, hub, ctl) + }) + mux.HandleFunc("PUT /api/clients/{clientID}/accel-stream", func(w http.ResponseWriter, r *http.Request) { + clientID, err := parsePathClientID(r) + if err != nil { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: err.Error()}) + return + } + serveClientAccelStreamPut(w, r, clientID, link, hub, ctl) + }) + + mux.HandleFunc("/api/accel-stream", func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet: + serveAccelStreamGetQuery(w, r, link, hub, ctl) + case http.MethodPost: + serveAccelStreamPost(w, r, link, hub, ctl) + default: + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + } + }) +} + +func parsePathClientID(r *http.Request) (uint32, error) { + s := r.PathValue("clientID") + if s == "" { + return 0, fmt.Errorf("client_id required") + } + v, err := strconv.ParseUint(s, 10, 32) + if err != nil || v == 0 { + return 0, fmt.Errorf("invalid client_id") + } + return uint32(v), nil +} + +func applyAccelStreamClient(link *managedSerial, hub *wsHub, ctl *accelStreamCtl, clientID uint32, enable bool) accelStreamAPIResponse { + resp, err := link.AccelStream(&pb.AccelStreamRequest{ + Write: true, + Enable: enable, + ClientId: clientID, + }) + if err != nil { + return accelStreamAPIResponse{ + ClientID: clientID, + Error: err.Error(), + } + } + out := accelStreamAPIResponse{ + Enabled: enable, + ClientID: resp.GetClientId(), + Success: resp.GetSuccess(), + SlavesUpdated: resp.GetSlavesUpdated(), + } + if resp.GetSuccess() { + if ctl != nil { + ctl.Set(clientID, enable) + } + if hub != nil { + hub.patchClientAccelStream(clientID, enable) + } + } else { + out.Enabled = resp.GetEnabled() + } + return out +} + +func serveAccelStreamGet(w http.ResponseWriter, clientID uint32, link *managedSerial, hub *wsHub, ctl *accelStreamCtl) { + resp, err := link.AccelStreamPoll(&pb.AccelStreamRequest{ + Write: false, + ClientId: clientID, + }) + if err != nil { + writeJSON(w, http.StatusServiceUnavailable, accelStreamAPIResponse{ + ClientID: clientID, + Error: err.Error(), + }) + return + } + if ctl != nil { + ctl.Set(clientID, resp.GetEnabled()) + } + writeJSON(w, http.StatusOK, accelStreamAPIResponse{ + Enabled: resp.GetEnabled(), + ClientID: resp.GetClientId(), + Success: resp.GetSuccess(), + }) +} + +func serveAccelStreamGetQuery(w http.ResponseWriter, r *http.Request, link *managedSerial, hub *wsHub, ctl *accelStreamCtl) { + clientID, err := parseUintQuery(r, "client_id", 0) + if err != nil || clientID == 0 { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: "client_id required"}) + return + } + serveAccelStreamGet(w, clientID, link, hub, ctl) +} + +func serveClientAccelStreamPut(w http.ResponseWriter, r *http.Request, clientID uint32, link *managedSerial, hub *wsHub, ctl *accelStreamCtl) { + var body clientAccelStreamBody + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: "invalid JSON"}) + return + } + out := applyAccelStreamClient(link, hub, ctl, clientID, body.Enable) + status := http.StatusOK + if out.Error != "" { + status = http.StatusServiceUnavailable + } else if !out.Success { + status = http.StatusServiceUnavailable + } + writeJSON(w, status, out) +} + +func serveAccelStreamPost(w http.ResponseWriter, r *http.Request, link *managedSerial, hub *wsHub, ctl *accelStreamCtl) { + var body accelStreamAPIRequest + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: "invalid JSON"}) + return + } + + if body.AllClients { + updated, err := applyAccelStreamAll(link, body.Enable) + if err != nil { + writeJSON(w, http.StatusServiceUnavailable, accelStreamAPIResponse{Error: err.Error()}) + return + } + clients, _ := link.listClientsPoll() + for _, c := range clients { + if ctl != nil { + ctl.Set(c.GetId(), body.Enable) + } + if hub != nil { + hub.patchClientAccelStream(c.GetId(), body.Enable) + } + } + writeJSON(w, http.StatusOK, accelStreamAPIResponse{ + Enabled: body.Enable, + Success: updated > 0, + SlavesUpdated: updated, + }) + return + } + + if body.ClientID == 0 { + writeJSON(w, http.StatusBadRequest, accelStreamAPIResponse{Error: "client_id required"}) + return + } + + out := applyAccelStreamClient(link, hub, ctl, body.ClientID, body.Enable) + status := http.StatusOK + if out.Error != "" || !out.Success { + status = http.StatusServiceUnavailable + } + writeJSON(w, status, out) +} + +func applyAccelStreamAll(link *managedSerial, enable bool) (uint32, error) { + clients, err := link.listClients() + if err != nil { + return 0, err + } + var updated uint32 + for _, c := range clients { + resp, err := link.AccelStream(&pb.AccelStreamRequest{ + Write: true, + Enable: enable, + ClientId: c.GetId(), + }) + if err != nil { + continue + } + if resp.GetSuccess() { + updated++ + } + } + if len(clients) == 0 { + return 0, fmt.Errorf("no slaves registered") + } + if updated == 0 { + return 0, fmt.Errorf("accel stream not applied to any slave") + } + return updated, nil +} diff --git a/goTool/api_serve.go b/goTool/api_serve.go index b7dc7e4..9de85bf 100644 --- a/goTool/api_serve.go +++ b/goTool/api_serve.go @@ -67,7 +67,8 @@ type otaAPIResponse struct { Error string `json:"error,omitempty"` } -func mountServeAPI(mux *http.ServeMux, link *managedSerial, hub *wsHub) { +func mountServeAPI(mux *http.ServeMux, link *managedSerial, hub *wsHub, streamCtl *accelStreamCtl) { + mountAccelStreamAPI(mux, link, hub, streamCtl) mux.HandleFunc("/api/deadzone", func(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: diff --git a/goTool/api_stream.go b/goTool/api_stream.go new file mode 100644 index 0000000..7e7b6f8 --- /dev/null +++ b/goTool/api_stream.go @@ -0,0 +1,476 @@ +package main + +import ( + "context" + "encoding/json" + "errors" + "log" + "net/http" + "sync" + "time" + + "github.com/gorilla/websocket" + "powerpod/gotool/pb" +) + +const ( + defaultAccelStreamInterval = 16 * time.Millisecond + minAPIStreamInterval = 1 * time.Millisecond + maxAPIStreamInterval = 10 * time.Second +) + +// AccelClientSample is one slave's cached accel on the master. +type AccelClientSample struct { + ClientID uint32 `json:"client_id"` + Valid bool `json:"valid"` + X int32 `json:"x,omitempty"` + Y int32 `json:"y,omitempty"` + Z int32 `json:"z,omitempty"` + AgeMs uint32 `json:"age_ms,omitempty"` +} + +// AccelStreamMessage is sent to external WebSocket clients. +type AccelStreamMessage struct { + Type string `json:"type"` // "hello" | "accel" + Serial string `json:"serial_port,omitempty"` + IntervalMs int `json:"interval_ms,omitempty"` + Commands []string `json:"commands,omitempty"` + + T int64 `json:"t,omitempty"` // Unix nanoseconds + Success bool `json:"success,omitempty"` + Clients []AccelClientSample `json:"clients,omitempty"` + Error string `json:"error,omitempty"` +} + +// StreamStatusMessage is the reply to set_stream / get_stream (this connection). +type StreamStatusMessage struct { + Type string `json:"type"` // "stream_status" + ReceiveAccel bool `json:"receive_accel"` + IntervalMs int `json:"interval_ms"` + Success bool `json:"success"` + Error string `json:"error,omitempty"` +} + +// AccelStreamStatusMessage is the reply to set_accel_stream / get_accel_stream (slave). +type AccelStreamStatusMessage struct { + Type string `json:"type"` // "accel_stream_status" + ClientID uint32 `json:"client_id"` + Enabled bool `json:"enabled"` + Success bool `json:"success"` + SlavesUpdated uint32 `json:"slaves_updated,omitempty"` + Error string `json:"error,omitempty"` +} + +type accelWSCommand struct { + Type string `json:"type"` + ClientID uint32 `json:"client_id"` + Enable *bool `json:"enable"` + IntervalMs *int `json:"interval_ms"` +} + +type APIInfoResponse struct { + Name string `json:"name"` + Version string `json:"version"` + SerialPort string `json:"serial_port"` + WebSocket string `json:"websocket"` + DefaultIntervalMs int `json:"default_interval_ms"` + MinIntervalMs int `json:"min_interval_ms"` + MaxIntervalMs int `json:"max_interval_ms"` + Description string `json:"description"` +} + +type wsSubscriber struct { + conn *websocket.Conn + receiveAccel bool + interval time.Duration + lastSent time.Time +} + +type accelStreamHub struct { + mu sync.RWMutex + clients map[*websocket.Conn]*wsSubscriber + defaultInterval time.Duration + configChanged chan struct{} +} + +func newAccelStreamHub(defaultInterval time.Duration) *accelStreamHub { + return &accelStreamHub{ + clients: make(map[*websocket.Conn]*wsSubscriber), + defaultInterval: defaultInterval, + configChanged: make(chan struct{}, 1), + } +} + +func (h *accelStreamHub) notifyConfigChanged() { + select { + case h.configChanged <- struct{}{}: + default: + } +} + +func clampAPIInterval(d time.Duration) time.Duration { + if d < minAPIStreamInterval { + return minAPIStreamInterval + } + if d > maxAPIStreamInterval { + return maxAPIStreamInterval + } + return d +} + +func (h *accelStreamHub) register(conn *websocket.Conn, portName string) *wsSubscriber { + sub := &wsSubscriber{ + conn: conn, + receiveAccel: false, + interval: h.defaultInterval, + } + h.mu.Lock() + h.clients[conn] = sub + h.mu.Unlock() + + hello := AccelStreamMessage{ + Type: "hello", + Serial: portName, + IntervalMs: int(h.defaultInterval / time.Millisecond), + Commands: []string{"set_stream", "get_stream", "set_accel_stream", "get_accel_stream"}, + } + if data, err := json.Marshal(hello); err == nil { + _ = conn.WriteMessage(websocket.TextMessage, data) + } + return sub +} + +func (h *accelStreamHub) unregister(conn *websocket.Conn) { + h.mu.Lock() + delete(h.clients, conn) + h.mu.Unlock() + h.notifyConfigChanged() +} + +func (h *accelStreamHub) anyWantsAccel() bool { + h.mu.RLock() + defer h.mu.RUnlock() + for _, sub := range h.clients { + if sub.receiveAccel { + return true + } + } + return false +} + +func (h *accelStreamHub) minWantedInterval() time.Duration { + h.mu.RLock() + defer h.mu.RUnlock() + var min time.Duration + for _, sub := range h.clients { + if !sub.receiveAccel { + continue + } + if min == 0 || sub.interval < min { + min = sub.interval + } + } + if min == 0 { + return h.defaultInterval + } + return min +} + +func (h *accelStreamHub) setStream(sub *wsSubscriber, enable bool, intervalMs *int) StreamStatusMessage { + h.mu.Lock() + sub.receiveAccel = enable + if intervalMs != nil { + sub.interval = clampAPIInterval(time.Duration(*intervalMs) * time.Millisecond) + } + ms := int(sub.interval / time.Millisecond) + h.mu.Unlock() + h.notifyConfigChanged() + + return StreamStatusMessage{ + Type: "stream_status", + ReceiveAccel: enable, + IntervalMs: ms, + Success: true, + } +} + +func (h *accelStreamHub) getStream(sub *wsSubscriber) StreamStatusMessage { + h.mu.RLock() + defer h.mu.RUnlock() + return StreamStatusMessage{ + Type: "stream_status", + ReceiveAccel: sub.receiveAccel, + IntervalMs: int(sub.interval / time.Millisecond), + Success: true, + } +} + +func (h *accelStreamHub) deliver(msg AccelStreamMessage) { + data, err := json.Marshal(msg) + if err != nil { + return + } + + now := time.Now() + h.mu.Lock() + defer h.mu.Unlock() + for conn, sub := range h.clients { + if !sub.receiveAccel { + continue + } + if !sub.lastSent.IsZero() && now.Sub(sub.lastSent) < sub.interval { + continue + } + sub.lastSent = now + if err := conn.WriteMessage(websocket.TextMessage, data); err != nil { + delete(h.clients, conn) + _ = conn.Close() + } + } +} + +func runAccelStreamer(link *managedSerial, hub *accelStreamHub, dash *wsHub, ctl *accelStreamCtl, stop <-chan struct{}) { + var ticker *time.Ticker + var tick <-chan time.Time + + resetTicker := func() { + if ticker != nil { + ticker.Stop() + } + interval := hub.minWantedInterval() + ticker = time.NewTicker(interval) + tick = ticker.C + } + resetTicker() + defer func() { + if ticker != nil { + ticker.Stop() + } + }() + + for { + select { + case <-stop: + return + case <-hub.configChanged: + resetTicker() + case <-tick: + if !hub.anyWantsAccel() { + continue + } + if !accelStreamPollingActive(dash, ctl) { + continue + } + now := time.Now().UnixNano() + resp, err := link.readAccelSnapshotPoll(0) + if errors.Is(err, errUARTBusy) { + hub.deliver(AccelStreamMessage{ + Type: "accel", + T: now, + Success: false, + Error: "uart busy", + }) + continue + } + if err != nil { + hub.deliver(AccelStreamMessage{ + Type: "accel", + T: now, + Success: false, + Error: err.Error(), + }) + continue + } + clients := make([]AccelClientSample, 0, len(resp.GetSamples())) + for _, s := range resp.GetSamples() { + clients = append(clients, AccelClientSample{ + ClientID: s.GetClientId(), + Valid: s.GetValid(), + X: s.GetX(), + Y: s.GetY(), + Z: s.GetZ(), + AgeMs: s.GetAgeMs(), + }) + } + hub.deliver(AccelStreamMessage{ + Type: "accel", + T: now, + Success: true, + Clients: clients, + }) + } + } +} + +func accelStreamPollingActive(dash *wsHub, ctl *accelStreamCtl) bool { + if ctl != nil && ctl.Any() { + return true + } + return dash != nil && dash.anyAccelStreamEnabled() +} + +func writeStreamStatus(conn *websocket.Conn, msg StreamStatusMessage) { + data, err := json.Marshal(msg) + if err != nil { + return + } + _ = conn.WriteMessage(websocket.TextMessage, data) +} + +func writeAccelStreamStatus(conn *websocket.Conn, out accelStreamAPIResponse) { + msg := AccelStreamStatusMessage{ + Type: "accel_stream_status", + ClientID: out.ClientID, + Enabled: out.Enabled, + Success: out.Success, + SlavesUpdated: out.SlavesUpdated, + Error: out.Error, + } + data, err := json.Marshal(msg) + if err != nil { + return + } + _ = conn.WriteMessage(websocket.TextMessage, data) +} + +func handleAccelWSCommand(conn *websocket.Conn, sub *wsSubscriber, data []byte, link *managedSerial, dash *wsHub, ctl *accelStreamCtl, hub *accelStreamHub) { + var cmd accelWSCommand + if err := json.Unmarshal(data, &cmd); err != nil { + writeStreamStatus(conn, StreamStatusMessage{Type: "stream_status", Error: "invalid JSON"}) + return + } + + switch cmd.Type { + case "set_stream": + if cmd.Enable == nil { + writeStreamStatus(conn, StreamStatusMessage{ + Type: "stream_status", + Error: "enable required", + }) + return + } + writeStreamStatus(conn, hub.setStream(sub, *cmd.Enable, cmd.IntervalMs)) + + case "get_stream": + writeStreamStatus(conn, hub.getStream(sub)) + + case "set_accel_stream": + if cmd.ClientID == 0 { + writeAccelStreamStatus(conn, accelStreamAPIResponse{Error: "client_id required"}) + return + } + if cmd.Enable == nil { + writeAccelStreamStatus(conn, accelStreamAPIResponse{ + ClientID: cmd.ClientID, + Error: "enable required", + }) + return + } + writeAccelStreamStatus(conn, applyAccelStreamClient(link, dash, ctl, cmd.ClientID, *cmd.Enable)) + + case "get_accel_stream": + if cmd.ClientID == 0 { + writeAccelStreamStatus(conn, accelStreamAPIResponse{Error: "client_id required"}) + return + } + resp, err := link.AccelStreamPoll(&pb.AccelStreamRequest{ + Write: false, + ClientId: cmd.ClientID, + }) + if err != nil { + writeAccelStreamStatus(conn, accelStreamAPIResponse{ + ClientID: cmd.ClientID, + Error: err.Error(), + }) + return + } + if ctl != nil { + ctl.Set(cmd.ClientID, resp.GetEnabled()) + } + writeAccelStreamStatus(conn, accelStreamAPIResponse{ + Enabled: resp.GetEnabled(), + ClientID: resp.GetClientId(), + Success: resp.GetSuccess(), + }) + + default: + writeStreamStatus(conn, StreamStatusMessage{ + Type: "stream_status", + Error: "unknown type (set_stream, get_stream, set_accel_stream, get_accel_stream)", + }) + } +} + +func serveExternalWS(conn *websocket.Conn, link *managedSerial, dash *wsHub, ctl *accelStreamCtl, portName string, hub *accelStreamHub) { + sub := hub.register(conn, portName) + defer hub.unregister(conn) + defer conn.Close() + + for { + _, data, err := conn.ReadMessage() + if err != nil { + return + } + handleAccelWSCommand(conn, sub, data, link, dash, ctl, hub) + } +} + +func mountExternalAPI(mux *http.ServeMux, portName string, defaultInterval time.Duration, hub *accelStreamHub, link *managedSerial, dash *wsHub, ctl *accelStreamCtl) { + defMs := int(defaultInterval / time.Millisecond) + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" && r.URL.Path != "/api/v1" && r.URL.Path != "/api/v1/" { + http.NotFound(w, r) + return + } + if r.Method != http.MethodGet { + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + return + } + writeJSON(w, http.StatusOK, APIInfoResponse{ + Name: "powerpod-external-api", + Version: "1", + SerialPort: portName, + WebSocket: "/ws", + DefaultIntervalMs: defMs, + MinIntervalMs: int(minAPIStreamInterval / time.Millisecond), + MaxIntervalMs: int(maxAPIStreamInterval / time.Millisecond), + Description: "WebSocket: per-connection accel receive + interval; slave stream via set_accel_stream", + }) + }) + + mux.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) { + conn, err := wsUpgrader.Upgrade(w, r, nil) + if err != nil { + log.Printf("api websocket upgrade: %v", err) + return + } + serveExternalWS(conn, link, dash, ctl, portName, hub) + }) +} + +func runAPIServer(portName string, link *managedSerial, addr string, defaultInterval time.Duration, dash *wsHub, ctl *accelStreamCtl, stop <-chan struct{}) *http.Server { + hub := newAccelStreamHub(defaultInterval) + go runAccelStreamer(link, hub, dash, ctl, stop) + + mux := http.NewServeMux() + mountExternalAPI(mux, portName, defaultInterval, hub, link, dash, ctl) + + srv := &http.Server{Addr: addr, Handler: mux} + go func() { + log.Printf("external API http://localhost%s WebSocket ws://localhost%s/ws (default accel interval %s, per-client via set_stream)", + addr, addr, defaultInterval.String()) + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + log.Printf("external API server: %v", err) + } + }() + return srv +} + +func shutdownAPIServer(srv *http.Server) { + if srv == nil { + return + } + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + _ = srv.Shutdown(ctx) +} diff --git a/goTool/client_api.go b/goTool/client_api.go index e91a108..5bf7920 100644 --- a/goTool/client_api.go +++ b/goTool/client_api.go @@ -40,6 +40,70 @@ func (m *managedSerial) listClientsPoll() ([]*pb.ClientInfo, error) { return decodeClientsPayload(payload) } +func (m *managedSerial) readAccelSnapshotPoll(clientID uint32) (*pb.AccelSnapshotResponse, error) { + msg := &pb.UartMessage{ + Type: pb.MessageType_ACCEL_SNAPSHOT, + Payload: &pb.UartMessage_AccelSnapshotRequest{ + AccelSnapshotRequest: &pb.AccelSnapshotRequest{ClientId: clientID}, + }, + } + body, err := proto.Marshal(msg) + if err != nil { + return nil, fmt.Errorf("encode: %w", err) + } + payload := append([]byte{byte(pb.MessageType_ACCEL_SNAPSHOT)}, body...) + respPayload, err := m.exchangePayloadPoll(payload, "ACCEL_SNAPSHOT") + if err != nil { + return nil, err + } + return decodeAccelSnapshotPayload(respPayload) +} + +func (m *managedSerial) AccelStream(req *pb.AccelStreamRequest) (*pb.AccelStreamResponse, error) { + return m.accelStreamVia(m.withPort, req) +} + +func (m *managedSerial) AccelStreamPoll(req *pb.AccelStreamRequest) (*pb.AccelStreamResponse, error) { + return m.accelStreamVia(m.withPortPoll, req) +} + +// SetAccelStream enables or disables the ESP-NOW accel stream for one slave (master UART). +func (m *managedSerial) SetAccelStream(clientID uint32, enable bool) (*pb.AccelStreamResponse, error) { + return m.AccelStream(&pb.AccelStreamRequest{ + Write: true, + Enable: enable, + ClientId: clientID, + }) +} + +// GetAccelStream returns whether the accel stream is enabled for a slave on the master. +func (m *managedSerial) GetAccelStream(clientID uint32) (bool, error) { + resp, err := m.AccelStreamPoll(&pb.AccelStreamRequest{ + Write: false, + ClientId: clientID, + }) + if err != nil { + return false, err + } + if !resp.GetSuccess() { + return false, fmt.Errorf("accel stream read failed for client %d", clientID) + } + return resp.GetEnabled(), nil +} + +func (m *managedSerial) accelStreamVia( + portFn func(func(*serialPort) error) error, + req *pb.AccelStreamRequest, +) (*pb.AccelStreamResponse, error) { + var resp *pb.AccelStreamResponse + err := portFn(func(sp *serialPort) error { + var e error + resp, e = sp.AccelStream(req) + return e + }) + return resp, err +} + func (m *managedSerial) AccelDeadzone(req *pb.AccelDeadzoneRequest) (*pb.AccelDeadzoneResponse, error) { return m.accelDeadzoneVia(m.withPort, req) } @@ -101,25 +165,43 @@ func decodeClientsPayload(payload []byte) ([]*pb.ClientInfo, error) { return info.GetClients(), nil } -func (s *serialPort) readAccel() (*pb.AccelReadResponse, error) { - payload, err := s.exchange(byte(pb.MessageType_ACCEL_READ), "ACCEL_READ") - if err != nil { - return nil, err +func decodeAccelSnapshotPayload(payload []byte) (*pb.AccelSnapshotResponse, error) { + if len(payload) < 1 { + return nil, fmt.Errorf("empty response payload") } var msg pb.UartMessage if err := proto.Unmarshal(payload[1:], &msg); err != nil { return nil, fmt.Errorf("decode: %w", err) } - if msg.GetType() != pb.MessageType_ACCEL_READ { + if msg.GetType() != pb.MessageType_ACCEL_SNAPSHOT { return nil, fmt.Errorf("unexpected type %v", msg.GetType()) } - r := msg.GetAccelReadResponse() + r := msg.GetAccelSnapshotResponse() if r == nil { - return nil, fmt.Errorf("missing accel_read_response") + return nil, fmt.Errorf("missing accel_snapshot_response") } return r, nil } +func (s *serialPort) readAccelSnapshot(clientID uint32) (*pb.AccelSnapshotResponse, error) { + msg := &pb.UartMessage{ + Type: pb.MessageType_ACCEL_SNAPSHOT, + Payload: &pb.UartMessage_AccelSnapshotRequest{ + AccelSnapshotRequest: &pb.AccelSnapshotRequest{ClientId: clientID}, + }, + } + body, err := proto.Marshal(msg) + if err != nil { + return nil, fmt.Errorf("encode: %w", err) + } + payload := append([]byte{byte(pb.MessageType_ACCEL_SNAPSHOT)}, body...) + respPayload, err := s.exchangePayload(payload, "ACCEL_SNAPSHOT") + if err != nil { + return nil, err + } + return decodeAccelSnapshotPayload(respPayload) +} + func (s *serialPort) getVersion() (*pb.VersionResponse, error) { payload, err := s.exchange(byte(pb.MessageType_VERSION), "VERSION") if err != nil { @@ -136,6 +218,33 @@ func (s *serialPort) listClients() ([]*pb.ClientInfo, error) { return decodeClientsPayload(payload) } +func (s *serialPort) AccelStream(req *pb.AccelStreamRequest) (*pb.AccelStreamResponse, error) { + msg := &pb.UartMessage{ + Type: pb.MessageType_ACCEL_STREAM, + Payload: &pb.UartMessage_AccelStreamRequest{ + AccelStreamRequest: req, + }, + } + body, err := proto.Marshal(msg) + if err != nil { + return nil, fmt.Errorf("encode: %w", err) + } + payload := append([]byte{byte(pb.MessageType_ACCEL_STREAM)}, body...) + respPayload, err := s.exchangePayload(payload, "ACCEL_STREAM") + if err != nil { + return nil, err + } + var respMsg pb.UartMessage + if err := proto.Unmarshal(respPayload[1:], &respMsg); err != nil { + return nil, fmt.Errorf("decode: %w", err) + } + r := respMsg.GetAccelStreamResponse() + if r == nil { + return nil, fmt.Errorf("missing accel_stream_response") + } + return r, nil +} + func (s *serialPort) accelDeadzone(req *pb.AccelDeadzoneRequest) (*pb.AccelDeadzoneResponse, error) { msg := &pb.UartMessage{ Type: pb.MessageType_ACCEL_DEADZONE, @@ -234,6 +343,28 @@ func (s *serialPort) GetVersion() (*pb.VersionResponse, error) { return s.getVer func (s *serialPort) ListClients() ([]*pb.ClientInfo, error) { return s.listClients() } +func (s *serialPort) SetAccelStream(clientID uint32, enable bool) (*pb.AccelStreamResponse, error) { + return s.AccelStream(&pb.AccelStreamRequest{ + Write: true, + Enable: enable, + ClientId: clientID, + }) +} + +func (s *serialPort) GetAccelStream(clientID uint32) (bool, error) { + resp, err := s.AccelStream(&pb.AccelStreamRequest{ + Write: false, + ClientId: clientID, + }) + if err != nil { + return false, err + } + if !resp.GetSuccess() { + return false, fmt.Errorf("accel stream read failed for client %d", clientID) + } + return resp.GetEnabled(), nil +} + func (s *serialPort) AccelDeadzone(req *pb.AccelDeadzoneRequest) (*pb.AccelDeadzoneResponse, error) { return s.accelDeadzone(req) } diff --git a/goTool/cmd_accel.go b/goTool/cmd_accel.go index 7ab5351..4b60249 100644 --- a/goTool/cmd_accel.go +++ b/goTool/cmd_accel.go @@ -5,13 +5,26 @@ import ( ) func runAccel(sp *serialPort) error { - r, err := sp.readAccel() + return runAccelSnapshot(sp, 0) +} + +func runAccelSnapshot(sp *serialPort, clientID uint32) error { + r, err := sp.readAccelSnapshot(clientID) if err != nil { return err } - if !r.GetSuccess() { - return fmt.Errorf("accel read failed (sensor not ready?)") + samples := r.GetSamples() + if len(samples) == 0 { + fmt.Println("no accel samples (no slaves or no ESP-NOW stream yet)") + return nil + } + for _, s := range samples { + if !s.GetValid() { + fmt.Printf("client %d: no sample yet\n", s.GetClientId()) + continue + } + fmt.Printf("client %d: x=%d y=%d z=%d (age %d ms, raw LSB ±2g)\n", + s.GetClientId(), s.GetX(), s.GetY(), s.GetZ(), s.GetAgeMs()) } - fmt.Printf("accel: x=%d y=%d z=%d (raw LSB, ±2g)\n", r.GetX(), r.GetY(), r.GetZ()) return nil } diff --git a/goTool/cmd_serve.go b/goTool/cmd_serve.go index 71e430f..e8dfb87 100644 --- a/goTool/cmd_serve.go +++ b/goTool/cmd_serve.go @@ -21,7 +21,9 @@ var wsUpgrader = websocket.Upgrader{ func runServe(portName string, baud int, args []string) error { serveFlags := flag.NewFlagSet("serve", flag.ExitOnError) - addr := serveFlags.String("addr", ":8080", "HTTP listen address") + addr := serveFlags.String("addr", ":8080", "dashboard HTTP listen address") + apiAddr := serveFlags.String("api-addr", ":8081", "external API HTTP listen address (empty to disable)") + accelInterval := serveFlags.Duration("accel-interval", defaultAccelStreamInterval, "accel WebSocket sample period on API server") interval := serveFlags.Duration("interval", 2*time.Second, "UART poll interval") if err := serveFlags.Parse(args); err != nil { return err @@ -35,12 +37,20 @@ func runServe(portName string, baud int, args []string) error { defer link.Close() hub := newWSHub() + streamCtl := newAccelStreamCtl() stop := make(chan struct{}) defer close(stop) - go runPoller(link, portName, hub, *interval, stop) + go runPoller(link, portName, hub, streamCtl, *interval, stop) + go runAccelDashboardPoller(link, hub, *accelInterval, stop) + + var apiSrv *http.Server + if *apiAddr != "" { + apiSrv = runAPIServer(portName, link, *apiAddr, *accelInterval, hub, streamCtl, stop) + defer shutdownAPIServer(apiSrv) + } mux := http.NewServeMux() - mountServeAPI(mux, link, hub) + mountServeAPI(mux, link, hub, streamCtl) mux.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) { conn, err := wsUpgrader.Upgrade(w, r, nil) if err != nil { @@ -64,7 +74,10 @@ func runServe(portName string, baud int, args []string) error { } mux.Handle("/", http.FileServer(http.FS(ui))) - log.Printf("dashboard http://localhost%s (UART %s @ %d baud, poll %s, auto-reconnect)", - *addr, portName, baud, interval.String()) + log.Printf("dashboard http://localhost%s (UART %s @ %d baud, poll %s, accel %s, auto-reconnect)", + *addr, portName, baud, interval.String(), accelInterval.String()) + if *apiAddr == "" { + log.Printf("external API disabled (-api-addr \"\")") + } return http.ListenAndServe(*addr, mux) } diff --git a/goTool/dashboard.go b/goTool/dashboard.go index 2477286..43fe43a 100644 --- a/goTool/dashboard.go +++ b/goTool/dashboard.go @@ -32,6 +32,12 @@ type ClientView struct { Used bool `json:"used"` LastPing uint32 `json:"last_ping"` LastSuccessPing uint32 `json:"last_success_ping"` + AccelValid bool `json:"accel_valid"` + AccelX int32 `json:"accel_x"` + AccelY int32 `json:"accel_y"` + AccelZ int32 `json:"accel_z"` + AccelAgeMs uint32 `json:"accel_age_ms"` + AccelStream bool `json:"accel_stream"` } type DashboardState struct { @@ -56,6 +62,8 @@ func newWSHub() *wsHub { func (h *wsHub) setState(st DashboardState) { h.mu.Lock() + prev := h.state.Clients + st.Clients = preserveClientAccel(st.Clients, prev) h.state = st conns := make([]*websocket.Conn, 0, len(h.clients)) for c := range h.clients { @@ -89,6 +97,136 @@ func (h *wsHub) unregister(c *websocket.Conn) { h.mu.Unlock() } +func applyAccelSamples(clients []ClientView, samples []*pb.AccelSample) []ClientView { + if len(samples) == 0 { + return clients + } + byID := make(map[uint32]*pb.AccelSample, len(samples)) + for _, s := range samples { + byID[s.GetClientId()] = s + } + out := make([]ClientView, len(clients)) + for i, c := range clients { + out[i] = c + if !c.AccelStream { + out[i].AccelValid = false + continue + } + s, ok := byID[c.ID] + if !ok { + continue + } + out[i].AccelValid = s.GetValid() + if s.GetValid() { + out[i].AccelX = s.GetX() + out[i].AccelY = s.GetY() + out[i].AccelZ = s.GetZ() + out[i].AccelAgeMs = s.GetAgeMs() + } + } + return out +} + +func preserveClientAccel(newClients, oldClients []ClientView) []ClientView { + if len(oldClients) == 0 { + return newClients + } + oldByID := make(map[uint32]ClientView, len(oldClients)) + for _, c := range oldClients { + oldByID[c.ID] = c + } + out := make([]ClientView, len(newClients)) + for i, c := range newClients { + out[i] = c + if !c.AccelStream { + continue + } + prev, ok := oldByID[c.ID] + if !ok || !prev.AccelValid { + continue + } + if !c.AccelValid { + out[i].AccelValid = prev.AccelValid + out[i].AccelX = prev.AccelX + out[i].AccelY = prev.AccelY + out[i].AccelZ = prev.AccelZ + out[i].AccelAgeMs = prev.AccelAgeMs + } + } + return out +} + +func anyClientAccelStream(clients []ClientView) bool { + for _, c := range clients { + if c.AccelStream { + return true + } + } + return false +} + +// patchClientAccelStream updates stream flag immediately (e.g. after REST) and pushes WS. +func (h *wsHub) patchClientAccelStream(clientID uint32, enabled bool) { + h.mu.Lock() + for i := range h.state.Clients { + if h.state.Clients[i].ID != clientID { + continue + } + h.state.Clients[i].AccelStream = enabled + if !enabled { + h.state.Clients[i].AccelValid = false + h.state.Clients[i].AccelX = 0 + h.state.Clients[i].AccelY = 0 + h.state.Clients[i].AccelZ = 0 + h.state.Clients[i].AccelAgeMs = 0 + } + break + } + st := h.state + st.UpdatedAt = time.Now().Format(time.RFC3339) + conns := make([]*websocket.Conn, 0, len(h.clients)) + for c := range h.clients { + conns = append(conns, c) + } + h.mu.Unlock() + + data, err := json.Marshal(st) + if err != nil { + return + } + for _, c := range conns { + _ = c.WriteMessage(websocket.TextMessage, data) + } +} + +func (h *wsHub) anyAccelStreamEnabled() bool { + h.mu.RLock() + defer h.mu.RUnlock() + return anyClientAccelStream(h.state.Clients) +} + +// mergeAccel updates cached accel on clients and pushes state to dashboard WebSockets. +func (h *wsHub) mergeAccel(samples []*pb.AccelSample) { + h.mu.Lock() + st := h.state + st.Clients = applyAccelSamples(st.Clients, samples) + st.UpdatedAt = time.Now().Format(time.RFC3339) + h.state = st + conns := make([]*websocket.Conn, 0, len(h.clients)) + for c := range h.clients { + conns = append(conns, c) + } + h.mu.Unlock() + + data, err := json.Marshal(st) + if err != nil { + return + } + for _, c := range conns { + _ = c.WriteMessage(websocket.TextMessage, data) + } +} + func (h *wsHub) broadcastRaw(v any) { h.mu.RLock() conns := make([]*websocket.Conn, 0, len(h.clients)) @@ -106,7 +244,7 @@ func (h *wsHub) broadcastRaw(v any) { } } -func pollDashboard(link *managedSerial, portName string, last *DashboardState) DashboardState { +func pollDashboard(link *managedSerial, portName string, last *DashboardState, streamCtl *accelStreamCtl) DashboardState { st := DashboardState{ UpdatedAt: time.Now().Format(time.RFC3339), SerialPort: portName, @@ -152,15 +290,63 @@ func pollDashboard(link *managedSerial, portName string, last *DashboardState) D Used: c.GetUsed(), LastPing: c.GetLastPing(), LastSuccessPing: c.GetLastSuccessPing(), - } - if dz, err := readDeadzonePoll(link, c.GetId()); err == nil { - cv.Deadzone = dz + AccelStream: c.GetAccelStreamEnabled(), } st.Clients = append(st.Clients, cv) } + if anyClientAccelStream(st.Clients) { + for i := range st.Clients { + if !st.Clients[i].AccelStream { + continue + } + if dz, err := readDeadzonePoll(link, st.Clients[i].ID); err == nil { + st.Clients[i].Deadzone = dz + } + } + if snap, err := link.readAccelSnapshotPoll(0); err == nil { + st.Clients = applyAccelSamples(st.Clients, snap.GetSamples()) + } + } else { + for i, c := range clients { + if dz, err := readDeadzonePoll(link, c.GetId()); err == nil { + st.Clients[i].Deadzone = dz + } + } + } + if streamCtl != nil { + streamCtl.SyncFromClients(st.Clients) + } return st } +func runAccelDashboardPoller(link *managedSerial, hub *wsHub, interval time.Duration, stop <-chan struct{}) { + ticker := time.NewTicker(interval) + defer ticker.Stop() + + for { + select { + case <-stop: + return + case <-ticker.C: + if hub.clientCount() == 0 || !hub.anyAccelStreamEnabled() { + continue + } + snap, err := link.readAccelSnapshotPoll(0) + if err != nil { + continue + } + hub.mergeAccel(snap.GetSamples()) + } + } +} + +func (h *wsHub) clientCount() int { + h.mu.RLock() + n := len(h.clients) + h.mu.RUnlock() + return n +} + func pausedPollState(portName string, last *DashboardState) DashboardState { if last != nil && last.UARTConnected { st := *last @@ -208,14 +394,15 @@ func formatMAC(mac []byte) string { return hex.EncodeToString(mac) } -func runPoller(link *managedSerial, portName string, hub *wsHub, interval time.Duration, stop <-chan struct{}) { +func runPoller(link *managedSerial, portName string, hub *wsHub, streamCtl *accelStreamCtl, interval time.Duration, stop <-chan struct{}) { + // streamCtl kept for external API; dashboard uses hub.state AccelStream flags. ticker := time.NewTicker(interval) defer ticker.Stop() uartUp := false var lastGood DashboardState publish := func() { - st := pollDashboard(link, portName, &lastGood) + st := pollDashboard(link, portName, &lastGood, streamCtl) if st.UARTConnected && st.SerialOK { lastGood = st } diff --git a/goTool/main.go b/goTool/main.go index 0a80570..b97c0b8 100644 --- a/goTool/main.go +++ b/goTool/main.go @@ -16,7 +16,7 @@ func usage() { fmt.Fprintf(os.Stderr, " version firmware version and git hash\n") fmt.Fprintf(os.Stderr, " clients registered ESP-NOW slaves on the master\n") fmt.Fprintf(os.Stderr, " deadzone get/set accelerometer deadzone (LSB)\n") - fmt.Fprintf(os.Stderr, " accel read current accelerometer XYZ (raw LSB)\n") + fmt.Fprintf(os.Stderr, " accel read cached slave accel snapshot from master\n") fmt.Fprintf(os.Stderr, " unicast-test send ESP-NOW unicast test to one slave\n") fmt.Fprintf(os.Stderr, " test run automated scenario (see testdata/)\n") fmt.Fprintf(os.Stderr, " serve web dashboard (Bootstrap + WebSocket)\n") diff --git a/goTool/pb/uart_messages.pb.go b/goTool/pb/uart_messages.pb.go index a82da2d..e03a68b 100644 --- a/goTool/pb/uart_messages.pb.go +++ b/goTool/pb/uart_messages.pb.go @@ -41,7 +41,8 @@ const ( MessageType_OTA_SLAVE_PROGRESS MessageType = 21 MessageType_FIND_ME MessageType = 22 MessageType_RESTART MessageType = 23 - MessageType_ACCEL_READ MessageType = 24 + MessageType_ACCEL_SNAPSHOT MessageType = 24 + MessageType_ACCEL_STREAM MessageType = 25 ) // Enum value maps for MessageType. @@ -64,7 +65,8 @@ var ( 21: "OTA_SLAVE_PROGRESS", 22: "FIND_ME", 23: "RESTART", - 24: "ACCEL_READ", + 24: "ACCEL_SNAPSHOT", + 25: "ACCEL_STREAM", } MessageType_value = map[string]int32{ "UNKNOWN": 0, @@ -84,7 +86,8 @@ var ( "OTA_SLAVE_PROGRESS": 21, "FIND_ME": 22, "RESTART": 23, - "ACCEL_READ": 24, + "ACCEL_SNAPSHOT": 24, + "ACCEL_STREAM": 25, } ) @@ -141,8 +144,10 @@ type UartMessage struct { // *UartMessage_EspnowFindMeResponse // *UartMessage_RestartRequest // *UartMessage_RestartResponse - // *UartMessage_AccelReadRequest - // *UartMessage_AccelReadResponse + // *UartMessage_AccelSnapshotRequest + // *UartMessage_AccelSnapshotResponse + // *UartMessage_AccelStreamRequest + // *UartMessage_AccelStreamResponse Payload isUartMessage_Payload `protobuf_oneof:"payload"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -381,19 +386,37 @@ func (x *UartMessage) GetRestartResponse() *RestartResponse { return nil } -func (x *UartMessage) GetAccelReadRequest() *AccelReadRequest { +func (x *UartMessage) GetAccelSnapshotRequest() *AccelSnapshotRequest { if x != nil { - if x, ok := x.Payload.(*UartMessage_AccelReadRequest); ok { - return x.AccelReadRequest + if x, ok := x.Payload.(*UartMessage_AccelSnapshotRequest); ok { + return x.AccelSnapshotRequest } } return nil } -func (x *UartMessage) GetAccelReadResponse() *AccelReadResponse { +func (x *UartMessage) GetAccelSnapshotResponse() *AccelSnapshotResponse { if x != nil { - if x, ok := x.Payload.(*UartMessage_AccelReadResponse); ok { - return x.AccelReadResponse + if x, ok := x.Payload.(*UartMessage_AccelSnapshotResponse); ok { + return x.AccelSnapshotResponse + } + } + return nil +} + +func (x *UartMessage) GetAccelStreamRequest() *AccelStreamRequest { + if x != nil { + if x, ok := x.Payload.(*UartMessage_AccelStreamRequest); ok { + return x.AccelStreamRequest + } + } + return nil +} + +func (x *UartMessage) GetAccelStreamResponse() *AccelStreamResponse { + if x != nil { + if x, ok := x.Payload.(*UartMessage_AccelStreamResponse); ok { + return x.AccelStreamResponse } } return nil @@ -487,12 +510,20 @@ type UartMessage_RestartResponse struct { RestartResponse *RestartResponse `protobuf:"bytes,22,opt,name=restart_response,json=restartResponse,proto3,oneof"` } -type UartMessage_AccelReadRequest struct { - AccelReadRequest *AccelReadRequest `protobuf:"bytes,23,opt,name=accel_read_request,json=accelReadRequest,proto3,oneof"` +type UartMessage_AccelSnapshotRequest struct { + AccelSnapshotRequest *AccelSnapshotRequest `protobuf:"bytes,23,opt,name=accel_snapshot_request,json=accelSnapshotRequest,proto3,oneof"` } -type UartMessage_AccelReadResponse struct { - AccelReadResponse *AccelReadResponse `protobuf:"bytes,24,opt,name=accel_read_response,json=accelReadResponse,proto3,oneof"` +type UartMessage_AccelSnapshotResponse struct { + AccelSnapshotResponse *AccelSnapshotResponse `protobuf:"bytes,24,opt,name=accel_snapshot_response,json=accelSnapshotResponse,proto3,oneof"` +} + +type UartMessage_AccelStreamRequest struct { + AccelStreamRequest *AccelStreamRequest `protobuf:"bytes,25,opt,name=accel_stream_request,json=accelStreamRequest,proto3,oneof"` +} + +type UartMessage_AccelStreamResponse struct { + AccelStreamResponse *AccelStreamResponse `protobuf:"bytes,26,opt,name=accel_stream_response,json=accelStreamResponse,proto3,oneof"` } func (*UartMessage_AckPayload) isUartMessage_Payload() {} @@ -537,9 +568,13 @@ func (*UartMessage_RestartRequest) isUartMessage_Payload() {} func (*UartMessage_RestartResponse) isUartMessage_Payload() {} -func (*UartMessage_AccelReadRequest) isUartMessage_Payload() {} +func (*UartMessage_AccelSnapshotRequest) isUartMessage_Payload() {} -func (*UartMessage_AccelReadResponse) isUartMessage_Payload() {} +func (*UartMessage_AccelSnapshotResponse) isUartMessage_Payload() {} + +func (*UartMessage_AccelStreamRequest) isUartMessage_Payload() {} + +func (*UartMessage_AccelStreamResponse) isUartMessage_Payload() {} type Ack struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -691,8 +726,10 @@ type ClientInfo struct { LastPing uint32 `protobuf:"varint,5,opt,name=last_ping,json=lastPing,proto3" json:"last_ping,omitempty"` LastSuccessPing uint32 `protobuf:"varint,6,opt,name=last_success_ping,json=lastSuccessPing,proto3" json:"last_success_ping,omitempty"` Version uint32 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // * Master: ESP-NOW accel stream enabled for this slave. + AccelStreamEnabled bool `protobuf:"varint,8,opt,name=accel_stream_enabled,json=accelStreamEnabled,proto3" json:"accel_stream_enabled,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ClientInfo) Reset() { @@ -774,6 +811,13 @@ func (x *ClientInfo) GetVersion() uint32 { return 0 } +func (x *ClientInfo) GetAccelStreamEnabled() bool { + if x != nil { + return x.AccelStreamEnabled + } + return false +} + type ClientInfoResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Clients []*ClientInfo `protobuf:"bytes,1,rep,name=clients,proto3" json:"clients,omitempty"` @@ -1069,27 +1113,32 @@ func (x *AccelDeadzoneResponse) GetSlavesUpdated() uint32 { return 0 } -// Host → device: read current BMA456 accelerometer sample (raw LSB, ±2g range). -type AccelReadRequest struct { +// Host → master: enable/disable slave accel ESP-NOW stream (~16 ms per slave). +// write=false: read; write=true: apply. client_id 0 invalid for write (use >0 or all_clients). +type AccelStreamRequest struct { state protoimpl.MessageState `protogen:"open.v1"` + Write bool `protobuf:"varint,1,opt,name=write,proto3" json:"write,omitempty"` + Enable bool `protobuf:"varint,2,opt,name=enable,proto3" json:"enable,omitempty"` + ClientId uint32 `protobuf:"varint,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + AllClients bool `protobuf:"varint,4,opt,name=all_clients,json=allClients,proto3" json:"all_clients,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AccelReadRequest) Reset() { - *x = AccelReadRequest{} +func (x *AccelStreamRequest) Reset() { + *x = AccelStreamRequest{} mi := &file_uart_messages_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AccelReadRequest) String() string { +func (x *AccelStreamRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AccelReadRequest) ProtoMessage() {} +func (*AccelStreamRequest) ProtoMessage() {} -func (x *AccelReadRequest) ProtoReflect() protoreflect.Message { +func (x *AccelStreamRequest) ProtoReflect() protoreflect.Message { mi := &file_uart_messages_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1101,35 +1150,63 @@ func (x *AccelReadRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AccelReadRequest.ProtoReflect.Descriptor instead. -func (*AccelReadRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use AccelStreamRequest.ProtoReflect.Descriptor instead. +func (*AccelStreamRequest) Descriptor() ([]byte, []int) { return file_uart_messages_proto_rawDescGZIP(), []int{10} } -type AccelReadResponse struct { +func (x *AccelStreamRequest) GetWrite() bool { + if x != nil { + return x.Write + } + return false +} + +func (x *AccelStreamRequest) GetEnable() bool { + if x != nil { + return x.Enable + } + return false +} + +func (x *AccelStreamRequest) GetClientId() uint32 { + if x != nil { + return x.ClientId + } + return 0 +} + +func (x *AccelStreamRequest) GetAllClients() bool { + if x != nil { + return x.AllClients + } + return false +} + +type AccelStreamResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - X int32 `protobuf:"zigzag32,2,opt,name=x,proto3" json:"x,omitempty"` - Y int32 `protobuf:"zigzag32,3,opt,name=y,proto3" json:"y,omitempty"` - Z int32 `protobuf:"zigzag32,4,opt,name=z,proto3" json:"z,omitempty"` + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + ClientId uint32 `protobuf:"varint,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"` + SlavesUpdated uint32 `protobuf:"varint,4,opt,name=slaves_updated,json=slavesUpdated,proto3" json:"slaves_updated,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AccelReadResponse) Reset() { - *x = AccelReadResponse{} +func (x *AccelStreamResponse) Reset() { + *x = AccelStreamResponse{} mi := &file_uart_messages_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AccelReadResponse) String() string { +func (x *AccelStreamResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AccelReadResponse) ProtoMessage() {} +func (*AccelStreamResponse) ProtoMessage() {} -func (x *AccelReadResponse) ProtoReflect() protoreflect.Message { +func (x *AccelStreamResponse) ProtoReflect() protoreflect.Message { mi := &file_uart_messages_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1141,39 +1218,214 @@ func (x *AccelReadResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AccelReadResponse.ProtoReflect.Descriptor instead. -func (*AccelReadResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use AccelStreamResponse.ProtoReflect.Descriptor instead. +func (*AccelStreamResponse) Descriptor() ([]byte, []int) { return file_uart_messages_proto_rawDescGZIP(), []int{11} } -func (x *AccelReadResponse) GetSuccess() bool { +func (x *AccelStreamResponse) GetEnabled() bool { + if x != nil { + return x.Enabled + } + return false +} + +func (x *AccelStreamResponse) GetClientId() uint32 { + if x != nil { + return x.ClientId + } + return 0 +} + +func (x *AccelStreamResponse) GetSuccess() bool { if x != nil { return x.Success } return false } -func (x *AccelReadResponse) GetX() int32 { +func (x *AccelStreamResponse) GetSlavesUpdated() uint32 { + if x != nil { + return x.SlavesUpdated + } + return 0 +} + +// Host → master: read cached accel samples from slaves (only while stream enabled). +// client_id 0 = all registered slaves; otherwise one slave. +type AccelSnapshotRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccelSnapshotRequest) Reset() { + *x = AccelSnapshotRequest{} + mi := &file_uart_messages_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccelSnapshotRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccelSnapshotRequest) ProtoMessage() {} + +func (x *AccelSnapshotRequest) ProtoReflect() protoreflect.Message { + mi := &file_uart_messages_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccelSnapshotRequest.ProtoReflect.Descriptor instead. +func (*AccelSnapshotRequest) Descriptor() ([]byte, []int) { + return file_uart_messages_proto_rawDescGZIP(), []int{12} +} + +func (x *AccelSnapshotRequest) GetClientId() uint32 { + if x != nil { + return x.ClientId + } + return 0 +} + +type AccelSample struct { + state protoimpl.MessageState `protogen:"open.v1"` + ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + Valid bool `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"` + X int32 `protobuf:"zigzag32,3,opt,name=x,proto3" json:"x,omitempty"` + Y int32 `protobuf:"zigzag32,4,opt,name=y,proto3" json:"y,omitempty"` + Z int32 `protobuf:"zigzag32,5,opt,name=z,proto3" json:"z,omitempty"` + // * Milliseconds since last ESP-NOW sample from this slave. + AgeMs uint32 `protobuf:"varint,6,opt,name=age_ms,json=ageMs,proto3" json:"age_ms,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccelSample) Reset() { + *x = AccelSample{} + mi := &file_uart_messages_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccelSample) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccelSample) ProtoMessage() {} + +func (x *AccelSample) ProtoReflect() protoreflect.Message { + mi := &file_uart_messages_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccelSample.ProtoReflect.Descriptor instead. +func (*AccelSample) Descriptor() ([]byte, []int) { + return file_uart_messages_proto_rawDescGZIP(), []int{13} +} + +func (x *AccelSample) GetClientId() uint32 { + if x != nil { + return x.ClientId + } + return 0 +} + +func (x *AccelSample) GetValid() bool { + if x != nil { + return x.Valid + } + return false +} + +func (x *AccelSample) GetX() int32 { if x != nil { return x.X } return 0 } -func (x *AccelReadResponse) GetY() int32 { +func (x *AccelSample) GetY() int32 { if x != nil { return x.Y } return 0 } -func (x *AccelReadResponse) GetZ() int32 { +func (x *AccelSample) GetZ() int32 { if x != nil { return x.Z } return 0 } +func (x *AccelSample) GetAgeMs() uint32 { + if x != nil { + return x.AgeMs + } + return 0 +} + +type AccelSnapshotResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Samples []*AccelSample `protobuf:"bytes,1,rep,name=samples,proto3" json:"samples,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccelSnapshotResponse) Reset() { + *x = AccelSnapshotResponse{} + mi := &file_uart_messages_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccelSnapshotResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccelSnapshotResponse) ProtoMessage() {} + +func (x *AccelSnapshotResponse) ProtoReflect() protoreflect.Message { + mi := &file_uart_messages_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccelSnapshotResponse.ProtoReflect.Descriptor instead. +func (*AccelSnapshotResponse) Descriptor() ([]byte, []int) { + return file_uart_messages_proto_rawDescGZIP(), []int{14} +} + +func (x *AccelSnapshotResponse) GetSamples() []*AccelSample { + if x != nil { + return x.Samples + } + return nil +} + type EspNowUnicastTestRequest struct { state protoimpl.MessageState `protogen:"open.v1"` ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` @@ -1184,7 +1436,7 @@ type EspNowUnicastTestRequest struct { func (x *EspNowUnicastTestRequest) Reset() { *x = EspNowUnicastTestRequest{} - mi := &file_uart_messages_proto_msgTypes[12] + mi := &file_uart_messages_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1196,7 +1448,7 @@ func (x *EspNowUnicastTestRequest) String() string { func (*EspNowUnicastTestRequest) ProtoMessage() {} func (x *EspNowUnicastTestRequest) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[12] + mi := &file_uart_messages_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1209,7 +1461,7 @@ func (x *EspNowUnicastTestRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EspNowUnicastTestRequest.ProtoReflect.Descriptor instead. func (*EspNowUnicastTestRequest) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{12} + return file_uart_messages_proto_rawDescGZIP(), []int{15} } func (x *EspNowUnicastTestRequest) GetClientId() uint32 { @@ -1236,7 +1488,7 @@ type EspNowUnicastTestResponse struct { func (x *EspNowUnicastTestResponse) Reset() { *x = EspNowUnicastTestResponse{} - mi := &file_uart_messages_proto_msgTypes[13] + mi := &file_uart_messages_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1248,7 +1500,7 @@ func (x *EspNowUnicastTestResponse) String() string { func (*EspNowUnicastTestResponse) ProtoMessage() {} func (x *EspNowUnicastTestResponse) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[13] + mi := &file_uart_messages_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1261,7 +1513,7 @@ func (x *EspNowUnicastTestResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use EspNowUnicastTestResponse.ProtoReflect.Descriptor instead. func (*EspNowUnicastTestResponse) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{13} + return file_uart_messages_proto_rawDescGZIP(), []int{16} } func (x *EspNowUnicastTestResponse) GetSuccess() bool { @@ -1302,7 +1554,7 @@ type LedRingProgressRequest struct { func (x *LedRingProgressRequest) Reset() { *x = LedRingProgressRequest{} - mi := &file_uart_messages_proto_msgTypes[14] + mi := &file_uart_messages_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1314,7 +1566,7 @@ func (x *LedRingProgressRequest) String() string { func (*LedRingProgressRequest) ProtoMessage() {} func (x *LedRingProgressRequest) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[14] + mi := &file_uart_messages_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1327,7 +1579,7 @@ func (x *LedRingProgressRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LedRingProgressRequest.ProtoReflect.Descriptor instead. func (*LedRingProgressRequest) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{14} + return file_uart_messages_proto_rawDescGZIP(), []int{17} } func (x *LedRingProgressRequest) GetMode() uint32 { @@ -1405,7 +1657,7 @@ type LedRingProgressResponse struct { func (x *LedRingProgressResponse) Reset() { *x = LedRingProgressResponse{} - mi := &file_uart_messages_proto_msgTypes[15] + mi := &file_uart_messages_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1417,7 +1669,7 @@ func (x *LedRingProgressResponse) String() string { func (*LedRingProgressResponse) ProtoMessage() {} func (x *LedRingProgressResponse) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[15] + mi := &file_uart_messages_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1430,7 +1682,7 @@ func (x *LedRingProgressResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LedRingProgressResponse.ProtoReflect.Descriptor instead. func (*LedRingProgressResponse) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{15} + return file_uart_messages_proto_rawDescGZIP(), []int{18} } func (x *LedRingProgressResponse) GetSuccess() bool { @@ -1471,7 +1723,7 @@ type EspNowFindMeRequest struct { func (x *EspNowFindMeRequest) Reset() { *x = EspNowFindMeRequest{} - mi := &file_uart_messages_proto_msgTypes[16] + mi := &file_uart_messages_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1483,7 +1735,7 @@ func (x *EspNowFindMeRequest) String() string { func (*EspNowFindMeRequest) ProtoMessage() {} func (x *EspNowFindMeRequest) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[16] + mi := &file_uart_messages_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1496,7 +1748,7 @@ func (x *EspNowFindMeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EspNowFindMeRequest.ProtoReflect.Descriptor instead. func (*EspNowFindMeRequest) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{16} + return file_uart_messages_proto_rawDescGZIP(), []int{19} } func (x *EspNowFindMeRequest) GetClientId() uint32 { @@ -1516,7 +1768,7 @@ type EspNowFindMeResponse struct { func (x *EspNowFindMeResponse) Reset() { *x = EspNowFindMeResponse{} - mi := &file_uart_messages_proto_msgTypes[17] + mi := &file_uart_messages_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1528,7 +1780,7 @@ func (x *EspNowFindMeResponse) String() string { func (*EspNowFindMeResponse) ProtoMessage() {} func (x *EspNowFindMeResponse) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[17] + mi := &file_uart_messages_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1541,7 +1793,7 @@ func (x *EspNowFindMeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use EspNowFindMeResponse.ProtoReflect.Descriptor instead. func (*EspNowFindMeResponse) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{17} + return file_uart_messages_proto_rawDescGZIP(), []int{20} } func (x *EspNowFindMeResponse) GetSuccess() bool { @@ -1568,7 +1820,7 @@ type RestartRequest struct { func (x *RestartRequest) Reset() { *x = RestartRequest{} - mi := &file_uart_messages_proto_msgTypes[18] + mi := &file_uart_messages_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1580,7 +1832,7 @@ func (x *RestartRequest) String() string { func (*RestartRequest) ProtoMessage() {} func (x *RestartRequest) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[18] + mi := &file_uart_messages_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1593,7 +1845,7 @@ func (x *RestartRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RestartRequest.ProtoReflect.Descriptor instead. func (*RestartRequest) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{18} + return file_uart_messages_proto_rawDescGZIP(), []int{21} } func (x *RestartRequest) GetClientId() uint32 { @@ -1613,7 +1865,7 @@ type RestartResponse struct { func (x *RestartResponse) Reset() { *x = RestartResponse{} - mi := &file_uart_messages_proto_msgTypes[19] + mi := &file_uart_messages_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1625,7 +1877,7 @@ func (x *RestartResponse) String() string { func (*RestartResponse) ProtoMessage() {} func (x *RestartResponse) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[19] + mi := &file_uart_messages_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1638,7 +1890,7 @@ func (x *RestartResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RestartResponse.ProtoReflect.Descriptor instead. func (*RestartResponse) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{19} + return file_uart_messages_proto_rawDescGZIP(), []int{22} } func (x *RestartResponse) GetSuccess() bool { @@ -1665,7 +1917,7 @@ type OtaStartPayload struct { func (x *OtaStartPayload) Reset() { *x = OtaStartPayload{} - mi := &file_uart_messages_proto_msgTypes[20] + mi := &file_uart_messages_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1677,7 +1929,7 @@ func (x *OtaStartPayload) String() string { func (*OtaStartPayload) ProtoMessage() {} func (x *OtaStartPayload) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[20] + mi := &file_uart_messages_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1690,7 +1942,7 @@ func (x *OtaStartPayload) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaStartPayload.ProtoReflect.Descriptor instead. func (*OtaStartPayload) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{20} + return file_uart_messages_proto_rawDescGZIP(), []int{23} } func (x *OtaStartPayload) GetTotalSize() uint32 { @@ -1711,7 +1963,7 @@ type OtaPayload struct { func (x *OtaPayload) Reset() { *x = OtaPayload{} - mi := &file_uart_messages_proto_msgTypes[21] + mi := &file_uart_messages_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1723,7 +1975,7 @@ func (x *OtaPayload) String() string { func (*OtaPayload) ProtoMessage() {} func (x *OtaPayload) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[21] + mi := &file_uart_messages_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1736,7 +1988,7 @@ func (x *OtaPayload) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaPayload.ProtoReflect.Descriptor instead. func (*OtaPayload) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{21} + return file_uart_messages_proto_rawDescGZIP(), []int{24} } func (x *OtaPayload) GetSeq() uint32 { @@ -1762,7 +2014,7 @@ type OtaEndPayload struct { func (x *OtaEndPayload) Reset() { *x = OtaEndPayload{} - mi := &file_uart_messages_proto_msgTypes[22] + mi := &file_uart_messages_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1774,7 +2026,7 @@ func (x *OtaEndPayload) String() string { func (*OtaEndPayload) ProtoMessage() {} func (x *OtaEndPayload) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[22] + mi := &file_uart_messages_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1787,7 +2039,7 @@ func (x *OtaEndPayload) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaEndPayload.ProtoReflect.Descriptor instead. func (*OtaEndPayload) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{22} + return file_uart_messages_proto_rawDescGZIP(), []int{25} } // Device → host status (also used as ACK after each 4 KiB written). @@ -1804,7 +2056,7 @@ type OtaStatusPayload struct { func (x *OtaStatusPayload) Reset() { *x = OtaStatusPayload{} - mi := &file_uart_messages_proto_msgTypes[23] + mi := &file_uart_messages_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1816,7 +2068,7 @@ func (x *OtaStatusPayload) String() string { func (*OtaStatusPayload) ProtoMessage() {} func (x *OtaStatusPayload) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[23] + mi := &file_uart_messages_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1829,7 +2081,7 @@ func (x *OtaStatusPayload) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaStatusPayload.ProtoReflect.Descriptor instead. func (*OtaStatusPayload) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{23} + return file_uart_messages_proto_rawDescGZIP(), []int{26} } func (x *OtaStatusPayload) GetStatus() uint32 { @@ -1870,7 +2122,7 @@ type OtaSlaveProgressRequest struct { func (x *OtaSlaveProgressRequest) Reset() { *x = OtaSlaveProgressRequest{} - mi := &file_uart_messages_proto_msgTypes[24] + mi := &file_uart_messages_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1882,7 +2134,7 @@ func (x *OtaSlaveProgressRequest) String() string { func (*OtaSlaveProgressRequest) ProtoMessage() {} func (x *OtaSlaveProgressRequest) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[24] + mi := &file_uart_messages_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1895,7 +2147,7 @@ func (x *OtaSlaveProgressRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaSlaveProgressRequest.ProtoReflect.Descriptor instead. func (*OtaSlaveProgressRequest) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{24} + return file_uart_messages_proto_rawDescGZIP(), []int{27} } func (x *OtaSlaveProgressRequest) GetClientId() uint32 { @@ -1919,7 +2171,7 @@ type OtaSlaveProgressEntry struct { func (x *OtaSlaveProgressEntry) Reset() { *x = OtaSlaveProgressEntry{} - mi := &file_uart_messages_proto_msgTypes[25] + mi := &file_uart_messages_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1931,7 +2183,7 @@ func (x *OtaSlaveProgressEntry) String() string { func (*OtaSlaveProgressEntry) ProtoMessage() {} func (x *OtaSlaveProgressEntry) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[25] + mi := &file_uart_messages_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1944,7 +2196,7 @@ func (x *OtaSlaveProgressEntry) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaSlaveProgressEntry.ProtoReflect.Descriptor instead. func (*OtaSlaveProgressEntry) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{25} + return file_uart_messages_proto_rawDescGZIP(), []int{28} } func (x *OtaSlaveProgressEntry) GetClientId() uint32 { @@ -1995,7 +2247,7 @@ type OtaSlaveProgressResponse struct { func (x *OtaSlaveProgressResponse) Reset() { *x = OtaSlaveProgressResponse{} - mi := &file_uart_messages_proto_msgTypes[26] + mi := &file_uart_messages_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2007,7 +2259,7 @@ func (x *OtaSlaveProgressResponse) String() string { func (*OtaSlaveProgressResponse) ProtoMessage() {} func (x *OtaSlaveProgressResponse) ProtoReflect() protoreflect.Message { - mi := &file_uart_messages_proto_msgTypes[26] + mi := &file_uart_messages_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2020,7 +2272,7 @@ func (x *OtaSlaveProgressResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use OtaSlaveProgressResponse.ProtoReflect.Descriptor instead. func (*OtaSlaveProgressResponse) Descriptor() ([]byte, []int) { - return file_uart_messages_proto_rawDescGZIP(), []int{26} + return file_uart_messages_proto_rawDescGZIP(), []int{29} } func (x *OtaSlaveProgressResponse) GetActive() bool { @@ -2062,7 +2314,7 @@ var File_uart_messages_proto protoreflect.FileDescriptor const file_uart_messages_proto_rawDesc = "" + "\n" + - "\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\x83\x0e\n" + + "\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\xba\x0f\n" + "\vUartMessage\x12%\n" + "\x04type\x18\x01 \x01(\x0e2\x11.alox.MessageTypeR\x04type\x12,\n" + "\vack_payload\x18\x02 \x01(\v2\t.alox.AckH\x00R\n" + @@ -2089,9 +2341,11 @@ const file_uart_messages_proto_rawDesc = "" + "\x16espnow_find_me_request\x18\x13 \x01(\v2\x19.alox.EspNowFindMeRequestH\x00R\x13espnowFindMeRequest\x12S\n" + "\x17espnow_find_me_response\x18\x14 \x01(\v2\x1a.alox.EspNowFindMeResponseH\x00R\x14espnowFindMeResponse\x12?\n" + "\x0frestart_request\x18\x15 \x01(\v2\x14.alox.RestartRequestH\x00R\x0erestartRequest\x12B\n" + - "\x10restart_response\x18\x16 \x01(\v2\x15.alox.RestartResponseH\x00R\x0frestartResponse\x12F\n" + - "\x12accel_read_request\x18\x17 \x01(\v2\x16.alox.AccelReadRequestH\x00R\x10accelReadRequest\x12I\n" + - "\x13accel_read_response\x18\x18 \x01(\v2\x17.alox.AccelReadResponseH\x00R\x11accelReadResponseB\t\n" + + "\x10restart_response\x18\x16 \x01(\v2\x15.alox.RestartResponseH\x00R\x0frestartResponse\x12R\n" + + "\x16accel_snapshot_request\x18\x17 \x01(\v2\x1a.alox.AccelSnapshotRequestH\x00R\x14accelSnapshotRequest\x12U\n" + + "\x17accel_snapshot_response\x18\x18 \x01(\v2\x1b.alox.AccelSnapshotResponseH\x00R\x15accelSnapshotResponse\x12L\n" + + "\x14accel_stream_request\x18\x19 \x01(\v2\x18.alox.AccelStreamRequestH\x00R\x12accelStreamRequest\x12O\n" + + "\x15accel_stream_response\x18\x1a \x01(\v2\x19.alox.AccelStreamResponseH\x00R\x13accelStreamResponseB\t\n" + "\apayload\"\x05\n" + "\x03Ack\"!\n" + "\vEchoPayload\x12\x12\n" + @@ -2099,7 +2353,7 @@ const file_uart_messages_proto_rawDesc = "" + "\x0fVersionResponse\x12\x18\n" + "\aversion\x18\x01 \x01(\rR\aversion\x12\x19\n" + "\bgit_hash\x18\x02 \x01(\tR\agitHash\x12+\n" + - "\x11running_partition\x18\x03 \x01(\tR\x10runningPartition\"\xc3\x01\n" + + "\x11running_partition\x18\x03 \x01(\tR\x10runningPartition\"\xf5\x01\n" + "\n" + "ClientInfo\x12\x0e\n" + "\x02id\x18\x01 \x01(\rR\x02id\x12\x1c\n" + @@ -2108,7 +2362,8 @@ const file_uart_messages_proto_rawDesc = "" + "\x03mac\x18\x04 \x01(\fR\x03mac\x12\x1b\n" + "\tlast_ping\x18\x05 \x01(\rR\blastPing\x12*\n" + "\x11last_success_ping\x18\x06 \x01(\rR\x0flastSuccessPing\x12\x18\n" + - "\aversion\x18\a \x01(\rR\aversion\"@\n" + + "\aversion\x18\a \x01(\rR\aversion\x120\n" + + "\x14accel_stream_enabled\x18\b \x01(\bR\x12accelStreamEnabled\"@\n" + "\x12ClientInfoResponse\x12*\n" + "\aclients\x18\x01 \x03(\v2\x10.alox.ClientInfoR\aclients\"e\n" + "\vClientInput\x12\x0e\n" + @@ -2128,13 +2383,29 @@ const file_uart_messages_proto_rawDesc = "" + "\bdeadzone\x18\x01 \x01(\rR\bdeadzone\x12\x1b\n" + "\tclient_id\x18\x02 \x01(\rR\bclientId\x12\x18\n" + "\asuccess\x18\x03 \x01(\bR\asuccess\x12%\n" + - "\x0eslaves_updated\x18\x04 \x01(\rR\rslavesUpdated\"\x12\n" + - "\x10AccelReadRequest\"W\n" + - "\x11AccelReadResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12\f\n" + - "\x01x\x18\x02 \x01(\x11R\x01x\x12\f\n" + - "\x01y\x18\x03 \x01(\x11R\x01y\x12\f\n" + - "\x01z\x18\x04 \x01(\x11R\x01z\"I\n" + + "\x0eslaves_updated\x18\x04 \x01(\rR\rslavesUpdated\"\x80\x01\n" + + "\x12AccelStreamRequest\x12\x14\n" + + "\x05write\x18\x01 \x01(\bR\x05write\x12\x16\n" + + "\x06enable\x18\x02 \x01(\bR\x06enable\x12\x1b\n" + + "\tclient_id\x18\x03 \x01(\rR\bclientId\x12\x1f\n" + + "\vall_clients\x18\x04 \x01(\bR\n" + + "allClients\"\x8d\x01\n" + + "\x13AccelStreamResponse\x12\x18\n" + + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x1b\n" + + "\tclient_id\x18\x02 \x01(\rR\bclientId\x12\x18\n" + + "\asuccess\x18\x03 \x01(\bR\asuccess\x12%\n" + + "\x0eslaves_updated\x18\x04 \x01(\rR\rslavesUpdated\"3\n" + + "\x14AccelSnapshotRequest\x12\x1b\n" + + "\tclient_id\x18\x01 \x01(\rR\bclientId\"\x81\x01\n" + + "\vAccelSample\x12\x1b\n" + + "\tclient_id\x18\x01 \x01(\rR\bclientId\x12\x14\n" + + "\x05valid\x18\x02 \x01(\bR\x05valid\x12\f\n" + + "\x01x\x18\x03 \x01(\x11R\x01x\x12\f\n" + + "\x01y\x18\x04 \x01(\x11R\x01y\x12\f\n" + + "\x01z\x18\x05 \x01(\x11R\x01z\x12\x15\n" + + "\x06age_ms\x18\x06 \x01(\rR\x05ageMs\"K\n" + + "\x15AccelSnapshotResponse\x122\n" + + "\asamples\x18\x01 \x03(\v2\x11.alox.AccelSampleB\x05\x92?\x02\x10\x10R\asamples\"I\n" + "\x18EspNowUnicastTestRequest\x12\x1b\n" + "\tclient_id\x18\x01 \x01(\rR\bclientId\x12\x10\n" + "\x03seq\x18\x02 \x01(\rR\x03seq\"G\n" + @@ -2197,7 +2468,7 @@ const file_uart_messages_proto_rawDesc = "" + "\x0faggregate_bytes\x18\x03 \x01(\rR\x0eaggregateBytes\x12\x1f\n" + "\vslave_count\x18\x04 \x01(\rR\n" + "slaveCount\x12:\n" + - "\x06slaves\x18\x05 \x03(\v2\x1b.alox.OtaSlaveProgressEntryB\x05\x92?\x02\x10\x10R\x06slaves*\xad\x02\n" + + "\x06slaves\x18\x05 \x03(\v2\x1b.alox.OtaSlaveProgressEntryB\x05\x92?\x02\x10\x10R\x06slaves*\xc3\x02\n" + "\vMessageType\x12\v\n" + "\aUNKNOWN\x10\x00\x12\a\n" + "\x03ACK\x10\x01\x12\b\n" + @@ -2216,9 +2487,9 @@ const file_uart_messages_proto_rawDesc = "" + "\x10OTA_START_ESPNOW\x10\x14\x12\x16\n" + "\x12OTA_SLAVE_PROGRESS\x10\x15\x12\v\n" + "\aFIND_ME\x10\x16\x12\v\n" + - "\aRESTART\x10\x17\x12\x0e\n" + - "\n" + - "ACCEL_READ\x10\x18b\x06proto3" + "\aRESTART\x10\x17\x12\x12\n" + + "\x0eACCEL_SNAPSHOT\x10\x18\x12\x10\n" + + "\fACCEL_STREAM\x10\x19b\x06proto3" var ( file_uart_messages_proto_rawDescOnce sync.Once @@ -2233,7 +2504,7 @@ func file_uart_messages_proto_rawDescGZIP() []byte { } var file_uart_messages_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_uart_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 27) +var file_uart_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 30) var file_uart_messages_proto_goTypes = []any{ (MessageType)(0), // 0: alox.MessageType (*UartMessage)(nil), // 1: alox.UartMessage @@ -2246,23 +2517,26 @@ var file_uart_messages_proto_goTypes = []any{ (*ClientInputResponse)(nil), // 8: alox.ClientInputResponse (*AccelDeadzoneRequest)(nil), // 9: alox.AccelDeadzoneRequest (*AccelDeadzoneResponse)(nil), // 10: alox.AccelDeadzoneResponse - (*AccelReadRequest)(nil), // 11: alox.AccelReadRequest - (*AccelReadResponse)(nil), // 12: alox.AccelReadResponse - (*EspNowUnicastTestRequest)(nil), // 13: alox.EspNowUnicastTestRequest - (*EspNowUnicastTestResponse)(nil), // 14: alox.EspNowUnicastTestResponse - (*LedRingProgressRequest)(nil), // 15: alox.LedRingProgressRequest - (*LedRingProgressResponse)(nil), // 16: alox.LedRingProgressResponse - (*EspNowFindMeRequest)(nil), // 17: alox.EspNowFindMeRequest - (*EspNowFindMeResponse)(nil), // 18: alox.EspNowFindMeResponse - (*RestartRequest)(nil), // 19: alox.RestartRequest - (*RestartResponse)(nil), // 20: alox.RestartResponse - (*OtaStartPayload)(nil), // 21: alox.OtaStartPayload - (*OtaPayload)(nil), // 22: alox.OtaPayload - (*OtaEndPayload)(nil), // 23: alox.OtaEndPayload - (*OtaStatusPayload)(nil), // 24: alox.OtaStatusPayload - (*OtaSlaveProgressRequest)(nil), // 25: alox.OtaSlaveProgressRequest - (*OtaSlaveProgressEntry)(nil), // 26: alox.OtaSlaveProgressEntry - (*OtaSlaveProgressResponse)(nil), // 27: alox.OtaSlaveProgressResponse + (*AccelStreamRequest)(nil), // 11: alox.AccelStreamRequest + (*AccelStreamResponse)(nil), // 12: alox.AccelStreamResponse + (*AccelSnapshotRequest)(nil), // 13: alox.AccelSnapshotRequest + (*AccelSample)(nil), // 14: alox.AccelSample + (*AccelSnapshotResponse)(nil), // 15: alox.AccelSnapshotResponse + (*EspNowUnicastTestRequest)(nil), // 16: alox.EspNowUnicastTestRequest + (*EspNowUnicastTestResponse)(nil), // 17: alox.EspNowUnicastTestResponse + (*LedRingProgressRequest)(nil), // 18: alox.LedRingProgressRequest + (*LedRingProgressResponse)(nil), // 19: alox.LedRingProgressResponse + (*EspNowFindMeRequest)(nil), // 20: alox.EspNowFindMeRequest + (*EspNowFindMeResponse)(nil), // 21: alox.EspNowFindMeResponse + (*RestartRequest)(nil), // 22: alox.RestartRequest + (*RestartResponse)(nil), // 23: alox.RestartResponse + (*OtaStartPayload)(nil), // 24: alox.OtaStartPayload + (*OtaPayload)(nil), // 25: alox.OtaPayload + (*OtaEndPayload)(nil), // 26: alox.OtaEndPayload + (*OtaStatusPayload)(nil), // 27: alox.OtaStatusPayload + (*OtaSlaveProgressRequest)(nil), // 28: alox.OtaSlaveProgressRequest + (*OtaSlaveProgressEntry)(nil), // 29: alox.OtaSlaveProgressEntry + (*OtaSlaveProgressResponse)(nil), // 30: alox.OtaSlaveProgressResponse } var file_uart_messages_proto_depIdxs = []int32{ 0, // 0: alox.UartMessage.type:type_name -> alox.MessageType @@ -2271,32 +2545,35 @@ var file_uart_messages_proto_depIdxs = []int32{ 4, // 3: alox.UartMessage.version_response:type_name -> alox.VersionResponse 6, // 4: alox.UartMessage.client_info_response:type_name -> alox.ClientInfoResponse 8, // 5: alox.UartMessage.client_input_response:type_name -> alox.ClientInputResponse - 21, // 6: alox.UartMessage.ota_start:type_name -> alox.OtaStartPayload - 22, // 7: alox.UartMessage.ota_payload:type_name -> alox.OtaPayload - 23, // 8: alox.UartMessage.ota_end:type_name -> alox.OtaEndPayload - 24, // 9: alox.UartMessage.ota_status:type_name -> alox.OtaStatusPayload + 24, // 6: alox.UartMessage.ota_start:type_name -> alox.OtaStartPayload + 25, // 7: alox.UartMessage.ota_payload:type_name -> alox.OtaPayload + 26, // 8: alox.UartMessage.ota_end:type_name -> alox.OtaEndPayload + 27, // 9: alox.UartMessage.ota_status:type_name -> alox.OtaStatusPayload 9, // 10: alox.UartMessage.accel_deadzone_request:type_name -> alox.AccelDeadzoneRequest 10, // 11: alox.UartMessage.accel_deadzone_response:type_name -> alox.AccelDeadzoneResponse - 13, // 12: alox.UartMessage.espnow_unicast_test_request:type_name -> alox.EspNowUnicastTestRequest - 14, // 13: alox.UartMessage.espnow_unicast_test_response:type_name -> alox.EspNowUnicastTestResponse - 25, // 14: alox.UartMessage.ota_slave_progress_request:type_name -> alox.OtaSlaveProgressRequest - 27, // 15: alox.UartMessage.ota_slave_progress_response:type_name -> alox.OtaSlaveProgressResponse - 15, // 16: alox.UartMessage.led_ring_progress_request:type_name -> alox.LedRingProgressRequest - 16, // 17: alox.UartMessage.led_ring_progress_response:type_name -> alox.LedRingProgressResponse - 17, // 18: alox.UartMessage.espnow_find_me_request:type_name -> alox.EspNowFindMeRequest - 18, // 19: alox.UartMessage.espnow_find_me_response:type_name -> alox.EspNowFindMeResponse - 19, // 20: alox.UartMessage.restart_request:type_name -> alox.RestartRequest - 20, // 21: alox.UartMessage.restart_response:type_name -> alox.RestartResponse - 11, // 22: alox.UartMessage.accel_read_request:type_name -> alox.AccelReadRequest - 12, // 23: alox.UartMessage.accel_read_response:type_name -> alox.AccelReadResponse - 5, // 24: alox.ClientInfoResponse.clients:type_name -> alox.ClientInfo - 7, // 25: alox.ClientInputResponse.clients:type_name -> alox.ClientInput - 26, // 26: alox.OtaSlaveProgressResponse.slaves:type_name -> alox.OtaSlaveProgressEntry - 27, // [27:27] is the sub-list for method output_type - 27, // [27:27] is the sub-list for method input_type - 27, // [27:27] is the sub-list for extension type_name - 27, // [27:27] is the sub-list for extension extendee - 0, // [0:27] is the sub-list for field type_name + 16, // 12: alox.UartMessage.espnow_unicast_test_request:type_name -> alox.EspNowUnicastTestRequest + 17, // 13: alox.UartMessage.espnow_unicast_test_response:type_name -> alox.EspNowUnicastTestResponse + 28, // 14: alox.UartMessage.ota_slave_progress_request:type_name -> alox.OtaSlaveProgressRequest + 30, // 15: alox.UartMessage.ota_slave_progress_response:type_name -> alox.OtaSlaveProgressResponse + 18, // 16: alox.UartMessage.led_ring_progress_request:type_name -> alox.LedRingProgressRequest + 19, // 17: alox.UartMessage.led_ring_progress_response:type_name -> alox.LedRingProgressResponse + 20, // 18: alox.UartMessage.espnow_find_me_request:type_name -> alox.EspNowFindMeRequest + 21, // 19: alox.UartMessage.espnow_find_me_response:type_name -> alox.EspNowFindMeResponse + 22, // 20: alox.UartMessage.restart_request:type_name -> alox.RestartRequest + 23, // 21: alox.UartMessage.restart_response:type_name -> alox.RestartResponse + 13, // 22: alox.UartMessage.accel_snapshot_request:type_name -> alox.AccelSnapshotRequest + 15, // 23: alox.UartMessage.accel_snapshot_response:type_name -> alox.AccelSnapshotResponse + 11, // 24: alox.UartMessage.accel_stream_request:type_name -> alox.AccelStreamRequest + 12, // 25: alox.UartMessage.accel_stream_response:type_name -> alox.AccelStreamResponse + 5, // 26: alox.ClientInfoResponse.clients:type_name -> alox.ClientInfo + 7, // 27: alox.ClientInputResponse.clients:type_name -> alox.ClientInput + 14, // 28: alox.AccelSnapshotResponse.samples:type_name -> alox.AccelSample + 29, // 29: alox.OtaSlaveProgressResponse.slaves:type_name -> alox.OtaSlaveProgressEntry + 30, // [30:30] is the sub-list for method output_type + 30, // [30:30] is the sub-list for method input_type + 30, // [30:30] is the sub-list for extension type_name + 30, // [30:30] is the sub-list for extension extendee + 0, // [0:30] is the sub-list for field type_name } func init() { file_uart_messages_proto_init() } @@ -2326,8 +2603,10 @@ func file_uart_messages_proto_init() { (*UartMessage_EspnowFindMeResponse)(nil), (*UartMessage_RestartRequest)(nil), (*UartMessage_RestartResponse)(nil), - (*UartMessage_AccelReadRequest)(nil), - (*UartMessage_AccelReadResponse)(nil), + (*UartMessage_AccelSnapshotRequest)(nil), + (*UartMessage_AccelSnapshotResponse)(nil), + (*UartMessage_AccelStreamRequest)(nil), + (*UartMessage_AccelStreamResponse)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -2335,7 +2614,7 @@ func file_uart_messages_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_uart_messages_proto_rawDesc), len(file_uart_messages_proto_rawDesc)), NumEnums: 1, - NumMessages: 27, + NumMessages: 30, NumExtensions: 0, NumServices: 0, }, diff --git a/goTool/webui/index.html b/goTool/webui/index.html index 9a34b47..5b66838 100644 --- a/goTool/webui/index.html +++ b/goTool/webui/index.html @@ -55,11 +55,12 @@ .badge-offline { background: #5c6570; color: #f0f3f5; } .badge.bg-secondary { background: #4a5560 !important; color: #f0f3f5; } - .mac { + .mac, .accel { font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--pp-accent); } + .accel-stale { color: var(--pp-text-muted); } .pp-table { --bs-table-color: var(--pp-text); @@ -265,7 +266,9 @@ -

Slaves per ESP-NOW — Master-Deadzone bleibt separat.

+

+ Accel-Stream pro Slave per „Stream an“ aktivieren (~16 ms ESP-NOW). Ohne Aktivierung keine Werte. +

@@ -276,12 +279,14 @@ + +
Ver Status DeadzoneAccel (LSB)Stream Aktion