Add LiPo battery monitoring with ESP-NOW cache and dashboard API.
Slaves report pack voltages every 30s; the master caches them for fast BATTERY_STATUS reads. goTool exposes REST/WebSocket and shows values in the dashboard, with a nanopb fix so optional lipo submessages encode. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
eb67a46158
commit
3cb0b5bbe9
@ -87,7 +87,7 @@ Polling runs only when at least one connection has `receive_accel: true` **and**
|
||||
**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","set_led_ring"]}
|
||||
{"type":"hello","serial_port":"/dev/ttyUSB0","interval_ms":16,"commands":["set_stream","get_stream","set_accel_stream","get_accel_stream","set_led_ring","get_battery"]}
|
||||
```
|
||||
|
||||
**Receive accel on this connection** (optional `interval_ms`, default from `-accel-interval`):
|
||||
@ -167,7 +167,7 @@ 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`, `GET/PUT /api/clients/{id}/accel-stream`, `POST /api/accel-stream` (legacy / `all_clients`), `POST /api/led-ring`, `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`), `GET/POST /api/battery`, `POST /api/led-ring`, `POST /api/unicast-test`, `POST /api/find-me`, `POST /api/restart`, `POST /api/ota` (multipart field `firmware`, max 2 MiB).
|
||||
|
||||
**LED ring** (`POST /api/led-ring` and WebSocket `set_led_ring` on `:8081`):
|
||||
|
||||
@ -179,6 +179,16 @@ HTTP API (used by the web UI): `GET/POST /api/deadzone`, `GET/PUT /api/clients/{
|
||||
|
||||
Modes: `clear`, `color` (full ring), `progress` (0–100), `digit` (0–10 symbols), `blink`, `find-me`. Use `client_id` (0 = master), or `all_clients` (+ optional `slaves_only`) for broadcast.
|
||||
|
||||
**Battery** (`GET/POST /api/battery`, WebSocket `get_battery` on `:8081`):
|
||||
|
||||
```json
|
||||
{"all_clients":true}
|
||||
{"client_id":0}
|
||||
{"client_id":16}
|
||||
```
|
||||
|
||||
Response: `samples[]` with `client_id`, `lipo1`/`lipo2` (`valid`, `voltage_mv`, `percent`), `age_ms`. Slaves push to the master every **30 s**; UART reads the cache (fast). Dashboard polls with `all_clients`.
|
||||
|
||||
**Accel stream per slave** (must be enabled before values appear; goTool polls only while at least one slave has stream on):
|
||||
|
||||
```http
|
||||
|
||||
60
goTool/api_battery.go
Normal file
60
goTool/api_battery.go
Normal file
@ -0,0 +1,60 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func mountBatteryAPI(mux *http.ServeMux, link *managedSerial) {
|
||||
mux.HandleFunc("/api/battery", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
serveBatteryGet(w, r, link)
|
||||
case http.MethodPost:
|
||||
serveBatteryPost(w, r, link)
|
||||
default:
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func serveBatteryGet(w http.ResponseWriter, r *http.Request, link *managedSerial) {
|
||||
req := batteryAPIRequest{}
|
||||
if v := r.URL.Query().Get("all_clients"); v == "1" || v == "true" {
|
||||
req.AllClients = true
|
||||
}
|
||||
if s := r.URL.Query().Get("client_id"); s != "" {
|
||||
id, err := strconv.ParseUint(s, 10, 32)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusBadRequest, batteryAPIResponse{Error: "invalid client_id"})
|
||||
return
|
||||
}
|
||||
req.ClientID = uint32(id)
|
||||
} else if !req.AllClients {
|
||||
req.AllClients = true
|
||||
}
|
||||
out := applyBatteryStatus(link, req)
|
||||
status := http.StatusOK
|
||||
if out.Error != "" || !out.Success {
|
||||
status = http.StatusServiceUnavailable
|
||||
}
|
||||
writeJSON(w, status, out)
|
||||
}
|
||||
|
||||
func serveBatteryPost(w http.ResponseWriter, r *http.Request, link *managedSerial) {
|
||||
var body batteryAPIRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
writeJSON(w, http.StatusBadRequest, batteryAPIResponse{Error: "invalid JSON"})
|
||||
return
|
||||
}
|
||||
if !body.AllClients && body.ClientID == 0 {
|
||||
body.AllClients = true
|
||||
}
|
||||
out := applyBatteryStatus(link, body)
|
||||
status := http.StatusOK
|
||||
if out.Error != "" || !out.Success {
|
||||
status = http.StatusServiceUnavailable
|
||||
}
|
||||
writeJSON(w, status, out)
|
||||
}
|
||||
@ -70,6 +70,7 @@ type otaAPIResponse struct {
|
||||
func mountServeAPI(mux *http.ServeMux, link *managedSerial, hub *wsHub, streamCtl *accelStreamCtl) {
|
||||
mountAccelStreamAPI(mux, link, hub, streamCtl)
|
||||
mountLedRingAPI(mux, link)
|
||||
mountBatteryAPI(mux, link)
|
||||
mux.HandleFunc("/api/deadzone", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
|
||||
@ -133,7 +133,8 @@ func (h *accelStreamHub) register(conn *websocket.Conn, portName string) *wsSubs
|
||||
Serial: portName,
|
||||
IntervalMs: int(h.defaultInterval / time.Millisecond),
|
||||
Commands: []string{
|
||||
"set_stream", "get_stream", "set_accel_stream", "get_accel_stream", "set_led_ring",
|
||||
"set_stream", "get_stream", "set_accel_stream", "get_accel_stream",
|
||||
"set_led_ring", "get_battery",
|
||||
},
|
||||
}
|
||||
if data, err := json.Marshal(hello); err == nil {
|
||||
@ -319,6 +320,15 @@ func writeStreamStatus(conn *websocket.Conn, msg StreamStatusMessage) {
|
||||
_ = conn.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
|
||||
func writeBatteryStatus(conn *websocket.Conn, out batteryAPIResponse) {
|
||||
out.Type = "battery_status"
|
||||
data, err := json.Marshal(out)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = conn.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
|
||||
func writeLedRingStatus(conn *websocket.Conn, out ledRingAPIResponse) {
|
||||
out.Type = "led_ring_status"
|
||||
data, err := json.Marshal(out)
|
||||
@ -416,10 +426,21 @@ func handleAccelWSCommand(conn *websocket.Conn, sub *wsSubscriber, data []byte,
|
||||
}
|
||||
writeLedRingStatus(conn, applyLedRing(link, body))
|
||||
|
||||
case "get_battery":
|
||||
var body batteryAPIRequest
|
||||
if err := json.Unmarshal(data, &body); err != nil {
|
||||
writeBatteryStatus(conn, batteryAPIResponse{Error: "invalid JSON"})
|
||||
return
|
||||
}
|
||||
if !body.AllClients && body.ClientID == 0 {
|
||||
body.AllClients = true
|
||||
}
|
||||
writeBatteryStatus(conn, applyBatteryStatus(link, body))
|
||||
|
||||
default:
|
||||
writeStreamStatus(conn, StreamStatusMessage{
|
||||
Type: "stream_status",
|
||||
Error: "unknown type (set_stream, get_stream, set_accel_stream, get_accel_stream, set_led_ring)",
|
||||
Error: "unknown type (set_stream, get_stream, set_accel_stream, get_accel_stream, set_led_ring, get_battery)",
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -478,6 +499,7 @@ func runAPIServer(portName string, link *managedSerial, addr string, defaultInte
|
||||
mux := http.NewServeMux()
|
||||
mountExternalAPI(mux, portName, defaultInterval, hub, link, dash, ctl)
|
||||
mountLedRingAPI(mux, link)
|
||||
mountBatteryAPI(mux, link)
|
||||
|
||||
srv := &http.Server{Addr: addr, Handler: mux}
|
||||
go func() {
|
||||
|
||||
120
goTool/battery_api.go
Normal file
120
goTool/battery_api.go
Normal file
@ -0,0 +1,120 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"powerpod/gotool/pb"
|
||||
)
|
||||
|
||||
const (
|
||||
lipoMinMv = 3000
|
||||
lipoMaxMv = 4200
|
||||
)
|
||||
|
||||
type lipoReadingJSON struct {
|
||||
Valid bool `json:"valid"`
|
||||
VoltageMv uint32 `json:"voltage_mv"`
|
||||
Percent int `json:"percent,omitempty"`
|
||||
}
|
||||
|
||||
type batterySampleJSON struct {
|
||||
ClientID uint32 `json:"client_id"`
|
||||
Lipo1 lipoReadingJSON `json:"lipo1"`
|
||||
Lipo2 lipoReadingJSON `json:"lipo2"`
|
||||
AgeMs uint32 `json:"age_ms,omitempty"`
|
||||
}
|
||||
|
||||
type batteryAPIRequest struct {
|
||||
ClientID uint32 `json:"client_id"`
|
||||
AllClients bool `json:"all_clients"`
|
||||
}
|
||||
|
||||
type batteryAPIResponse struct {
|
||||
Type string `json:"type,omitempty"` // battery_status (WebSocket)
|
||||
Success bool `json:"success"`
|
||||
Samples []batterySampleJSON `json:"samples,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func lipoPercent(mv uint32) int {
|
||||
if mv <= lipoMinMv {
|
||||
return 0
|
||||
}
|
||||
if mv >= lipoMaxMv {
|
||||
return 100
|
||||
}
|
||||
return int((mv - lipoMinMv) * 100 / (lipoMaxMv - lipoMinMv))
|
||||
}
|
||||
|
||||
func lipoFromPBMsg(l *pb.LipoReading) lipoReadingJSON {
|
||||
if l == nil {
|
||||
return lipoReadingJSON{}
|
||||
}
|
||||
return lipoFromPB(l.GetValid(), l.GetVoltageMv())
|
||||
}
|
||||
|
||||
func lipoFromPB(valid bool, mv uint32) lipoReadingJSON {
|
||||
out := lipoReadingJSON{Valid: valid, VoltageMv: mv}
|
||||
if valid {
|
||||
out.Percent = lipoPercent(mv)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func batterySamplesFromPB(samples []*pb.BatterySample) []batterySampleJSON {
|
||||
out := make([]batterySampleJSON, 0, len(samples))
|
||||
for _, s := range samples {
|
||||
out = append(out, batterySampleJSON{
|
||||
ClientID: s.GetClientId(),
|
||||
Lipo1: lipoFromPBMsg(s.GetLipo1()),
|
||||
Lipo2: lipoFromPBMsg(s.GetLipo2()),
|
||||
AgeMs: s.GetAgeMs(),
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func applyBatteryStatus(link *managedSerial, in batteryAPIRequest) batteryAPIResponse {
|
||||
resp, err := link.BatteryStatus(&pb.BatteryStatusRequest{
|
||||
ClientId: in.ClientID,
|
||||
AllClients: in.AllClients,
|
||||
})
|
||||
if err != nil {
|
||||
return batteryAPIResponse{Error: err.Error()}
|
||||
}
|
||||
samples := batterySamplesFromPB(resp.GetSamples())
|
||||
out := batteryAPIResponse{
|
||||
Success: resp.GetSuccess() || len(samples) > 0,
|
||||
Samples: samples,
|
||||
}
|
||||
if len(samples) == 0 && out.Error == "" {
|
||||
out.Error = "battery status unavailable"
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func findBatterySample(samples []batterySampleJSON, clientID uint32) (batterySampleJSON, bool) {
|
||||
for _, s := range samples {
|
||||
if s.ClientID == clientID {
|
||||
return s, true
|
||||
}
|
||||
}
|
||||
return batterySampleJSON{}, false
|
||||
}
|
||||
|
||||
// applyBatterySamplesToState merges UART/REST battery samples into dashboard views.
|
||||
func applyBatterySamplesToState(st *DashboardState, samples []batterySampleJSON) {
|
||||
if st == nil || len(samples) == 0 {
|
||||
return
|
||||
}
|
||||
if m, ok := findBatterySample(samples, 0); ok {
|
||||
st.Master.Lipo1 = m.Lipo1
|
||||
st.Master.Lipo2 = m.Lipo2
|
||||
st.Master.BatteryAgeMs = m.AgeMs
|
||||
}
|
||||
for i := range st.Clients {
|
||||
if s, ok := findBatterySample(samples, st.Clients[i].ID); ok {
|
||||
st.Clients[i].Lipo1 = s.Lipo1
|
||||
st.Clients[i].Lipo2 = s.Lipo2
|
||||
st.Clients[i].BatteryAgeMs = s.AgeMs
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,6 +59,86 @@ func (m *managedSerial) readAccelSnapshotPoll(clientID uint32) (*pb.AccelSnapsho
|
||||
return decodeAccelSnapshotPayload(respPayload)
|
||||
}
|
||||
|
||||
func decodeBatteryStatusPayload(payload []byte) (*pb.BatteryStatusResponse, error) {
|
||||
if len(payload) < 2 {
|
||||
return nil, fmt.Errorf("short battery response")
|
||||
}
|
||||
if payload[0] != byte(pb.MessageType_BATTERY_STATUS) {
|
||||
return nil, fmt.Errorf("unexpected command id 0x%02x (want 0x%02x)",
|
||||
payload[0], byte(pb.MessageType_BATTERY_STATUS))
|
||||
}
|
||||
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_BATTERY_STATUS {
|
||||
return nil, fmt.Errorf("unexpected type %v", msg.GetType())
|
||||
}
|
||||
r := msg.GetBatteryStatusResponse()
|
||||
if r == nil {
|
||||
return nil, fmt.Errorf("missing battery_status_response")
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (m *managedSerial) BatteryStatus(req *pb.BatteryStatusRequest) (*pb.BatteryStatusResponse, error) {
|
||||
var resp *pb.BatteryStatusResponse
|
||||
err := m.withPort(func(sp *serialPort) error {
|
||||
var e error
|
||||
resp, e = sp.batteryStatus(req)
|
||||
return e
|
||||
})
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (m *managedSerial) BatteryStatusPoll(req *pb.BatteryStatusRequest) (*pb.BatteryStatusResponse, error) {
|
||||
msg := &pb.UartMessage{
|
||||
Type: pb.MessageType_BATTERY_STATUS,
|
||||
Payload: &pb.UartMessage_BatteryStatusRequest{
|
||||
BatteryStatusRequest: req,
|
||||
},
|
||||
}
|
||||
body, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("encode: %w", err)
|
||||
}
|
||||
payload := append([]byte{byte(pb.MessageType_BATTERY_STATUS)}, body...)
|
||||
respPayload, err := m.batteryStatusPayloadPoll(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return decodeBatteryStatusPayload(respPayload)
|
||||
}
|
||||
|
||||
func (m *managedSerial) batteryStatusPayloadPoll(payload []byte) ([]byte, error) {
|
||||
var resp []byte
|
||||
err := m.withPortPoll(func(sp *serialPort) error {
|
||||
var e error
|
||||
resp, e = sp.exchangePayloadForBattery(payload, "BATTERY_STATUS")
|
||||
return e
|
||||
})
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (s *serialPort) batteryStatus(req *pb.BatteryStatusRequest) (*pb.BatteryStatusResponse, error) {
|
||||
msg := &pb.UartMessage{
|
||||
Type: pb.MessageType_BATTERY_STATUS,
|
||||
Payload: &pb.UartMessage_BatteryStatusRequest{
|
||||
BatteryStatusRequest: req,
|
||||
},
|
||||
}
|
||||
body, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("encode: %w", err)
|
||||
}
|
||||
payload := append([]byte{byte(pb.MessageType_BATTERY_STATUS)}, body...)
|
||||
respPayload, err := s.exchangePayloadForBattery(payload, "BATTERY_STATUS")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return decodeBatteryStatusPayload(respPayload)
|
||||
}
|
||||
|
||||
func (m *managedSerial) AccelStream(req *pb.AccelStreamRequest) (*pb.AccelStreamResponse, error) {
|
||||
return m.accelStreamVia(m.withPort, req)
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ func runServe(portName string, baud int, args []string) error {
|
||||
stop := make(chan struct{})
|
||||
defer close(stop)
|
||||
go runPoller(link, portName, hub, streamCtl, *interval, stop)
|
||||
go runBatteryPoller(link, hub, 5*time.Second, stop)
|
||||
go runAccelDashboardPoller(link, hub, *accelInterval, stop)
|
||||
|
||||
var apiSrv *http.Server
|
||||
|
||||
@ -19,6 +19,9 @@ type MasterView struct {
|
||||
GitHash string `json:"git_hash"`
|
||||
RunningPartition string `json:"running_partition,omitempty"`
|
||||
Deadzone uint32 `json:"deadzone,omitempty"`
|
||||
Lipo1 lipoReadingJSON `json:"lipo1"`
|
||||
Lipo2 lipoReadingJSON `json:"lipo2"`
|
||||
BatteryAgeMs uint32 `json:"battery_age_ms,omitempty"`
|
||||
OK bool `json:"ok"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
@ -38,6 +41,9 @@ type ClientView struct {
|
||||
AccelZ int32 `json:"accel_z"`
|
||||
AccelAgeMs uint32 `json:"accel_age_ms"`
|
||||
AccelStream bool `json:"accel_stream"`
|
||||
Lipo1 lipoReadingJSON `json:"lipo1"`
|
||||
Lipo2 lipoReadingJSON `json:"lipo2"`
|
||||
BatteryAgeMs uint32 `json:"battery_age_ms,omitempty"`
|
||||
}
|
||||
|
||||
type DashboardState struct {
|
||||
@ -62,8 +68,16 @@ func newWSHub() *wsHub {
|
||||
|
||||
func (h *wsHub) setState(st DashboardState) {
|
||||
h.mu.Lock()
|
||||
prev := h.state.Clients
|
||||
st.Clients = preserveClientAccel(st.Clients, prev)
|
||||
prev := h.state
|
||||
st.Clients = preserveClientAccel(st.Clients, prev.Clients)
|
||||
st.Clients = preserveClientBattery(st.Clients, prev.Clients)
|
||||
if !st.Master.Lipo1.Valid && !st.Master.Lipo2.Valid {
|
||||
if prev.Master.Lipo1.Valid || prev.Master.Lipo2.Valid {
|
||||
st.Master.Lipo1 = prev.Master.Lipo1
|
||||
st.Master.Lipo2 = prev.Master.Lipo2
|
||||
st.Master.BatteryAgeMs = prev.Master.BatteryAgeMs
|
||||
}
|
||||
}
|
||||
h.state = st
|
||||
conns := make([]*websocket.Conn, 0, len(h.clients))
|
||||
for c := range h.clients {
|
||||
@ -156,6 +170,33 @@ func preserveClientAccel(newClients, oldClients []ClientView) []ClientView {
|
||||
return out
|
||||
}
|
||||
|
||||
func preserveClientBattery(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.Lipo1.Valid || c.Lipo2.Valid {
|
||||
continue
|
||||
}
|
||||
prev, ok := oldByID[c.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if prev.Lipo1.Valid || prev.Lipo2.Valid {
|
||||
out[i].Lipo1 = prev.Lipo1
|
||||
out[i].Lipo2 = prev.Lipo2
|
||||
out[i].BatteryAgeMs = prev.BatteryAgeMs
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func anyClientAccelStream(clients []ClientView) bool {
|
||||
for _, c := range clients {
|
||||
if c.AccelStream {
|
||||
@ -294,6 +335,7 @@ func pollDashboard(link *managedSerial, portName string, last *DashboardState, s
|
||||
}
|
||||
st.Clients = append(st.Clients, cv)
|
||||
}
|
||||
applyBatteryToState(link, &st)
|
||||
if anyClientAccelStream(st.Clients) {
|
||||
for i := range st.Clients {
|
||||
if !st.Clients[i].AccelStream {
|
||||
@ -319,6 +361,60 @@ func pollDashboard(link *managedSerial, portName string, last *DashboardState, s
|
||||
return st
|
||||
}
|
||||
|
||||
func applyBatteryToState(link *managedSerial, st *DashboardState) {
|
||||
bat, err := link.BatteryStatusPoll(&pb.BatteryStatusRequest{AllClients: true})
|
||||
if err != nil {
|
||||
log.Printf("battery poll: %v", err)
|
||||
return
|
||||
}
|
||||
applyBatterySamplesToState(st, batterySamplesFromPB(bat.GetSamples()))
|
||||
}
|
||||
|
||||
func (h *wsHub) mergeBattery(samples []batterySampleJSON) {
|
||||
if len(samples) == 0 {
|
||||
return
|
||||
}
|
||||
h.mu.Lock()
|
||||
st := h.state
|
||||
applyBatterySamplesToState(&st, 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 runBatteryPoller(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 {
|
||||
continue
|
||||
}
|
||||
bat, err := link.BatteryStatusPoll(&pb.BatteryStatusRequest{AllClients: true})
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
hub.mergeBattery(batterySamplesFromPB(bat.GetSamples()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runAccelDashboardPoller(link *managedSerial, hub *wsHub, interval time.Duration, stop <-chan struct{}) {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
|
||||
@ -43,6 +43,7 @@ const (
|
||||
MessageType_RESTART MessageType = 23
|
||||
MessageType_ACCEL_SNAPSHOT MessageType = 24
|
||||
MessageType_ACCEL_STREAM MessageType = 25
|
||||
MessageType_BATTERY_STATUS MessageType = 26
|
||||
)
|
||||
|
||||
// Enum value maps for MessageType.
|
||||
@ -67,6 +68,7 @@ var (
|
||||
23: "RESTART",
|
||||
24: "ACCEL_SNAPSHOT",
|
||||
25: "ACCEL_STREAM",
|
||||
26: "BATTERY_STATUS",
|
||||
}
|
||||
MessageType_value = map[string]int32{
|
||||
"UNKNOWN": 0,
|
||||
@ -88,6 +90,7 @@ var (
|
||||
"RESTART": 23,
|
||||
"ACCEL_SNAPSHOT": 24,
|
||||
"ACCEL_STREAM": 25,
|
||||
"BATTERY_STATUS": 26,
|
||||
}
|
||||
)
|
||||
|
||||
@ -148,6 +151,8 @@ type UartMessage struct {
|
||||
// *UartMessage_AccelSnapshotResponse
|
||||
// *UartMessage_AccelStreamRequest
|
||||
// *UartMessage_AccelStreamResponse
|
||||
// *UartMessage_BatteryStatusRequest
|
||||
// *UartMessage_BatteryStatusResponse
|
||||
Payload isUartMessage_Payload `protobuf_oneof:"payload"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -422,6 +427,24 @@ func (x *UartMessage) GetAccelStreamResponse() *AccelStreamResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UartMessage) GetBatteryStatusRequest() *BatteryStatusRequest {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*UartMessage_BatteryStatusRequest); ok {
|
||||
return x.BatteryStatusRequest
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UartMessage) GetBatteryStatusResponse() *BatteryStatusResponse {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*UartMessage_BatteryStatusResponse); ok {
|
||||
return x.BatteryStatusResponse
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isUartMessage_Payload interface {
|
||||
isUartMessage_Payload()
|
||||
}
|
||||
@ -526,6 +549,14 @@ type UartMessage_AccelStreamResponse struct {
|
||||
AccelStreamResponse *AccelStreamResponse `protobuf:"bytes,26,opt,name=accel_stream_response,json=accelStreamResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type UartMessage_BatteryStatusRequest struct {
|
||||
BatteryStatusRequest *BatteryStatusRequest `protobuf:"bytes,27,opt,name=battery_status_request,json=batteryStatusRequest,proto3,oneof"`
|
||||
}
|
||||
|
||||
type UartMessage_BatteryStatusResponse struct {
|
||||
BatteryStatusResponse *BatteryStatusResponse `protobuf:"bytes,28,opt,name=battery_status_response,json=batteryStatusResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*UartMessage_AckPayload) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_EchoPayload) isUartMessage_Payload() {}
|
||||
@ -576,6 +607,10 @@ func (*UartMessage_AccelStreamRequest) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_AccelStreamResponse) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_BatteryStatusRequest) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_BatteryStatusResponse) isUartMessage_Payload() {}
|
||||
|
||||
type Ack struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@ -1251,6 +1286,235 @@ func (x *AccelStreamResponse) GetSlavesUpdated() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// * Host → master: read LiPo ADC voltages (master local and/or slaves via ESP-NOW).
|
||||
type BatteryStatusRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// * 0 = master only; >0 = one slave; ignored when all_clients
|
||||
ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
|
||||
// * Master (client_id 0) plus every registered slave
|
||||
AllClients bool `protobuf:"varint,2,opt,name=all_clients,json=allClients,proto3" json:"all_clients,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BatteryStatusRequest) Reset() {
|
||||
*x = BatteryStatusRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BatteryStatusRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BatteryStatusRequest) ProtoMessage() {}
|
||||
|
||||
func (x *BatteryStatusRequest) 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 BatteryStatusRequest.ProtoReflect.Descriptor instead.
|
||||
func (*BatteryStatusRequest) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *BatteryStatusRequest) GetClientId() uint32 {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *BatteryStatusRequest) GetAllClients() bool {
|
||||
if x != nil {
|
||||
return x.AllClients
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type LipoReading struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"`
|
||||
// * Estimated pack voltage in millivolts from ADC
|
||||
VoltageMv uint32 `protobuf:"varint,2,opt,name=voltage_mv,json=voltageMv,proto3" json:"voltage_mv,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *LipoReading) Reset() {
|
||||
*x = LipoReading{}
|
||||
mi := &file_uart_messages_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *LipoReading) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LipoReading) ProtoMessage() {}
|
||||
|
||||
func (x *LipoReading) 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 LipoReading.ProtoReflect.Descriptor instead.
|
||||
func (*LipoReading) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *LipoReading) GetValid() bool {
|
||||
if x != nil {
|
||||
return x.Valid
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *LipoReading) GetVoltageMv() uint32 {
|
||||
if x != nil {
|
||||
return x.VoltageMv
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type BatterySample struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
|
||||
Lipo1 *LipoReading `protobuf:"bytes,2,opt,name=lipo1,proto3" json:"lipo1,omitempty"`
|
||||
Lipo2 *LipoReading `protobuf:"bytes,3,opt,name=lipo2,proto3" json:"lipo2,omitempty"`
|
||||
// * Milliseconds since last ESP-NOW battery report from this pod.
|
||||
AgeMs uint32 `protobuf:"varint,4,opt,name=age_ms,json=ageMs,proto3" json:"age_ms,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BatterySample) Reset() {
|
||||
*x = BatterySample{}
|
||||
mi := &file_uart_messages_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BatterySample) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BatterySample) ProtoMessage() {}
|
||||
|
||||
func (x *BatterySample) 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 BatterySample.ProtoReflect.Descriptor instead.
|
||||
func (*BatterySample) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{14}
|
||||
}
|
||||
|
||||
func (x *BatterySample) GetClientId() uint32 {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *BatterySample) GetLipo1() *LipoReading {
|
||||
if x != nil {
|
||||
return x.Lipo1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BatterySample) GetLipo2() *LipoReading {
|
||||
if x != nil {
|
||||
return x.Lipo2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BatterySample) GetAgeMs() uint32 {
|
||||
if x != nil {
|
||||
return x.AgeMs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type BatteryStatusResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Samples []*BatterySample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BatteryStatusResponse) Reset() {
|
||||
*x = BatteryStatusResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BatteryStatusResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BatteryStatusResponse) ProtoMessage() {}
|
||||
|
||||
func (x *BatteryStatusResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[15]
|
||||
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 BatteryStatusResponse.ProtoReflect.Descriptor instead.
|
||||
func (*BatteryStatusResponse) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *BatteryStatusResponse) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *BatteryStatusResponse) GetSamples() []*BatterySample {
|
||||
if x != nil {
|
||||
return x.Samples
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Host → master: read cached accel samples from slaves (only while stream enabled).
|
||||
// client_id 0 = all registered slaves; otherwise one slave.
|
||||
type AccelSnapshotRequest struct {
|
||||
@ -1262,7 +1526,7 @@ type AccelSnapshotRequest struct {
|
||||
|
||||
func (x *AccelSnapshotRequest) Reset() {
|
||||
*x = AccelSnapshotRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[12]
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1274,7 +1538,7 @@ func (x *AccelSnapshotRequest) String() string {
|
||||
func (*AccelSnapshotRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AccelSnapshotRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[12]
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1287,7 +1551,7 @@ func (x *AccelSnapshotRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use AccelSnapshotRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AccelSnapshotRequest) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{12}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{16}
|
||||
}
|
||||
|
||||
func (x *AccelSnapshotRequest) GetClientId() uint32 {
|
||||
@ -1312,7 +1576,7 @@ type AccelSample struct {
|
||||
|
||||
func (x *AccelSample) Reset() {
|
||||
*x = AccelSample{}
|
||||
mi := &file_uart_messages_proto_msgTypes[13]
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1324,7 +1588,7 @@ func (x *AccelSample) String() string {
|
||||
func (*AccelSample) ProtoMessage() {}
|
||||
|
||||
func (x *AccelSample) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[13]
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1337,7 +1601,7 @@ func (x *AccelSample) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use AccelSample.ProtoReflect.Descriptor instead.
|
||||
func (*AccelSample) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{13}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{17}
|
||||
}
|
||||
|
||||
func (x *AccelSample) GetClientId() uint32 {
|
||||
@ -1391,7 +1655,7 @@ type AccelSnapshotResponse struct {
|
||||
|
||||
func (x *AccelSnapshotResponse) Reset() {
|
||||
*x = AccelSnapshotResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[14]
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1403,7 +1667,7 @@ func (x *AccelSnapshotResponse) String() string {
|
||||
func (*AccelSnapshotResponse) ProtoMessage() {}
|
||||
|
||||
func (x *AccelSnapshotResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[14]
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1416,7 +1680,7 @@ func (x *AccelSnapshotResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use AccelSnapshotResponse.ProtoReflect.Descriptor instead.
|
||||
func (*AccelSnapshotResponse) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{14}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *AccelSnapshotResponse) GetSamples() []*AccelSample {
|
||||
@ -1436,7 +1700,7 @@ type EspNowUnicastTestRequest struct {
|
||||
|
||||
func (x *EspNowUnicastTestRequest) Reset() {
|
||||
*x = EspNowUnicastTestRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[15]
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1448,7 +1712,7 @@ func (x *EspNowUnicastTestRequest) String() string {
|
||||
func (*EspNowUnicastTestRequest) ProtoMessage() {}
|
||||
|
||||
func (x *EspNowUnicastTestRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[15]
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1461,7 +1725,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{15}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{19}
|
||||
}
|
||||
|
||||
func (x *EspNowUnicastTestRequest) GetClientId() uint32 {
|
||||
@ -1488,7 +1752,7 @@ type EspNowUnicastTestResponse struct {
|
||||
|
||||
func (x *EspNowUnicastTestResponse) Reset() {
|
||||
*x = EspNowUnicastTestResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1500,7 +1764,7 @@ func (x *EspNowUnicastTestResponse) String() string {
|
||||
func (*EspNowUnicastTestResponse) ProtoMessage() {}
|
||||
|
||||
func (x *EspNowUnicastTestResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1513,7 +1777,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{16}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
func (x *EspNowUnicastTestResponse) GetSuccess() bool {
|
||||
@ -1560,7 +1824,7 @@ type LedRingProgressRequest struct {
|
||||
|
||||
func (x *LedRingProgressRequest) Reset() {
|
||||
*x = LedRingProgressRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1572,7 +1836,7 @@ func (x *LedRingProgressRequest) String() string {
|
||||
func (*LedRingProgressRequest) ProtoMessage() {}
|
||||
|
||||
func (x *LedRingProgressRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1585,7 +1849,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{17}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{21}
|
||||
}
|
||||
|
||||
func (x *LedRingProgressRequest) GetMode() uint32 {
|
||||
@ -1686,7 +1950,7 @@ type LedRingProgressResponse struct {
|
||||
|
||||
func (x *LedRingProgressResponse) Reset() {
|
||||
*x = LedRingProgressResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1698,7 +1962,7 @@ func (x *LedRingProgressResponse) String() string {
|
||||
func (*LedRingProgressResponse) ProtoMessage() {}
|
||||
|
||||
func (x *LedRingProgressResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1711,7 +1975,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{18}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{22}
|
||||
}
|
||||
|
||||
func (x *LedRingProgressResponse) GetSuccess() bool {
|
||||
@ -1766,7 +2030,7 @@ type EspNowFindMeRequest struct {
|
||||
|
||||
func (x *EspNowFindMeRequest) Reset() {
|
||||
*x = EspNowFindMeRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1778,7 +2042,7 @@ func (x *EspNowFindMeRequest) String() string {
|
||||
func (*EspNowFindMeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *EspNowFindMeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1791,7 +2055,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{19}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{23}
|
||||
}
|
||||
|
||||
func (x *EspNowFindMeRequest) GetClientId() uint32 {
|
||||
@ -1811,7 +2075,7 @@ type EspNowFindMeResponse struct {
|
||||
|
||||
func (x *EspNowFindMeResponse) Reset() {
|
||||
*x = EspNowFindMeResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1823,7 +2087,7 @@ func (x *EspNowFindMeResponse) String() string {
|
||||
func (*EspNowFindMeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *EspNowFindMeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1836,7 +2100,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{20}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{24}
|
||||
}
|
||||
|
||||
func (x *EspNowFindMeResponse) GetSuccess() bool {
|
||||
@ -1863,7 +2127,7 @@ type RestartRequest struct {
|
||||
|
||||
func (x *RestartRequest) Reset() {
|
||||
*x = RestartRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
mi := &file_uart_messages_proto_msgTypes[25]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1875,7 +2139,7 @@ func (x *RestartRequest) String() string {
|
||||
func (*RestartRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RestartRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
mi := &file_uart_messages_proto_msgTypes[25]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1888,7 +2152,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{21}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{25}
|
||||
}
|
||||
|
||||
func (x *RestartRequest) GetClientId() uint32 {
|
||||
@ -1908,7 +2172,7 @@ type RestartResponse struct {
|
||||
|
||||
func (x *RestartResponse) Reset() {
|
||||
*x = RestartResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
mi := &file_uart_messages_proto_msgTypes[26]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1920,7 +2184,7 @@ func (x *RestartResponse) String() string {
|
||||
func (*RestartResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RestartResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
mi := &file_uart_messages_proto_msgTypes[26]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1933,7 +2197,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{22}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{26}
|
||||
}
|
||||
|
||||
func (x *RestartResponse) GetSuccess() bool {
|
||||
@ -1960,7 +2224,7 @@ type OtaStartPayload struct {
|
||||
|
||||
func (x *OtaStartPayload) Reset() {
|
||||
*x = OtaStartPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
mi := &file_uart_messages_proto_msgTypes[27]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1972,7 +2236,7 @@ func (x *OtaStartPayload) String() string {
|
||||
func (*OtaStartPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaStartPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
mi := &file_uart_messages_proto_msgTypes[27]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1985,7 +2249,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{23}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{27}
|
||||
}
|
||||
|
||||
func (x *OtaStartPayload) GetTotalSize() uint32 {
|
||||
@ -2006,7 +2270,7 @@ type OtaPayload struct {
|
||||
|
||||
func (x *OtaPayload) Reset() {
|
||||
*x = OtaPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
mi := &file_uart_messages_proto_msgTypes[28]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2018,7 +2282,7 @@ func (x *OtaPayload) String() string {
|
||||
func (*OtaPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
mi := &file_uart_messages_proto_msgTypes[28]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2031,7 +2295,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{24}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{28}
|
||||
}
|
||||
|
||||
func (x *OtaPayload) GetSeq() uint32 {
|
||||
@ -2057,7 +2321,7 @@ type OtaEndPayload struct {
|
||||
|
||||
func (x *OtaEndPayload) Reset() {
|
||||
*x = OtaEndPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[25]
|
||||
mi := &file_uart_messages_proto_msgTypes[29]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2069,7 +2333,7 @@ func (x *OtaEndPayload) String() string {
|
||||
func (*OtaEndPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaEndPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[25]
|
||||
mi := &file_uart_messages_proto_msgTypes[29]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2082,7 +2346,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{25}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{29}
|
||||
}
|
||||
|
||||
// Device → host status (also used as ACK after each 4 KiB written).
|
||||
@ -2099,7 +2363,7 @@ type OtaStatusPayload struct {
|
||||
|
||||
func (x *OtaStatusPayload) Reset() {
|
||||
*x = OtaStatusPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[26]
|
||||
mi := &file_uart_messages_proto_msgTypes[30]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2111,7 +2375,7 @@ func (x *OtaStatusPayload) String() string {
|
||||
func (*OtaStatusPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaStatusPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[26]
|
||||
mi := &file_uart_messages_proto_msgTypes[30]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2124,7 +2388,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{26}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{30}
|
||||
}
|
||||
|
||||
func (x *OtaStatusPayload) GetStatus() uint32 {
|
||||
@ -2165,7 +2429,7 @@ type OtaSlaveProgressRequest struct {
|
||||
|
||||
func (x *OtaSlaveProgressRequest) Reset() {
|
||||
*x = OtaSlaveProgressRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[27]
|
||||
mi := &file_uart_messages_proto_msgTypes[31]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2177,7 +2441,7 @@ func (x *OtaSlaveProgressRequest) String() string {
|
||||
func (*OtaSlaveProgressRequest) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[27]
|
||||
mi := &file_uart_messages_proto_msgTypes[31]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2190,7 +2454,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{27}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{31}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressRequest) GetClientId() uint32 {
|
||||
@ -2214,7 +2478,7 @@ type OtaSlaveProgressEntry struct {
|
||||
|
||||
func (x *OtaSlaveProgressEntry) Reset() {
|
||||
*x = OtaSlaveProgressEntry{}
|
||||
mi := &file_uart_messages_proto_msgTypes[28]
|
||||
mi := &file_uart_messages_proto_msgTypes[32]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2226,7 +2490,7 @@ func (x *OtaSlaveProgressEntry) String() string {
|
||||
func (*OtaSlaveProgressEntry) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressEntry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[28]
|
||||
mi := &file_uart_messages_proto_msgTypes[32]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2239,7 +2503,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{28}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{32}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressEntry) GetClientId() uint32 {
|
||||
@ -2290,7 +2554,7 @@ type OtaSlaveProgressResponse struct {
|
||||
|
||||
func (x *OtaSlaveProgressResponse) Reset() {
|
||||
*x = OtaSlaveProgressResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[29]
|
||||
mi := &file_uart_messages_proto_msgTypes[33]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -2302,7 +2566,7 @@ func (x *OtaSlaveProgressResponse) String() string {
|
||||
func (*OtaSlaveProgressResponse) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[29]
|
||||
mi := &file_uart_messages_proto_msgTypes[33]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -2315,7 +2579,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{29}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{33}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressResponse) GetActive() bool {
|
||||
@ -2357,7 +2621,7 @@ var File_uart_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_uart_messages_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\xba\x0f\n" +
|
||||
"\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\xe5\x10\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" +
|
||||
@ -2388,7 +2652,9 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"\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" +
|
||||
"\x15accel_stream_response\x18\x1a \x01(\v2\x19.alox.AccelStreamResponseH\x00R\x13accelStreamResponse\x12R\n" +
|
||||
"\x16battery_status_request\x18\x1b \x01(\v2\x1a.alox.BatteryStatusRequestH\x00R\x14batteryStatusRequest\x12U\n" +
|
||||
"\x17battery_status_response\x18\x1c \x01(\v2\x1b.alox.BatteryStatusResponseH\x00R\x15batteryStatusResponseB\t\n" +
|
||||
"\apayload\"\x05\n" +
|
||||
"\x03Ack\"!\n" +
|
||||
"\vEchoPayload\x12\x12\n" +
|
||||
@ -2437,7 +2703,23 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"\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" +
|
||||
"\x0eslaves_updated\x18\x04 \x01(\rR\rslavesUpdated\"T\n" +
|
||||
"\x14BatteryStatusRequest\x12\x1b\n" +
|
||||
"\tclient_id\x18\x01 \x01(\rR\bclientId\x12\x1f\n" +
|
||||
"\vall_clients\x18\x02 \x01(\bR\n" +
|
||||
"allClients\"B\n" +
|
||||
"\vLipoReading\x12\x14\n" +
|
||||
"\x05valid\x18\x01 \x01(\bR\x05valid\x12\x1d\n" +
|
||||
"\n" +
|
||||
"voltage_mv\x18\x02 \x01(\rR\tvoltageMv\"\x95\x01\n" +
|
||||
"\rBatterySample\x12\x1b\n" +
|
||||
"\tclient_id\x18\x01 \x01(\rR\bclientId\x12'\n" +
|
||||
"\x05lipo1\x18\x02 \x01(\v2\x11.alox.LipoReadingR\x05lipo1\x12'\n" +
|
||||
"\x05lipo2\x18\x03 \x01(\v2\x11.alox.LipoReadingR\x05lipo2\x12\x15\n" +
|
||||
"\x06age_ms\x18\x04 \x01(\rR\x05ageMs\"g\n" +
|
||||
"\x15BatteryStatusResponse\x12\x18\n" +
|
||||
"\asuccess\x18\x01 \x01(\bR\asuccess\x124\n" +
|
||||
"\asamples\x18\x02 \x03(\v2\x13.alox.BatterySampleB\x05\x92?\x02\x10\x11R\asamples\"3\n" +
|
||||
"\x14AccelSnapshotRequest\x12\x1b\n" +
|
||||
"\tclient_id\x18\x01 \x01(\rR\bclientId\"\x81\x01\n" +
|
||||
"\vAccelSample\x12\x1b\n" +
|
||||
@ -2519,7 +2801,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*\xc3\x02\n" +
|
||||
"\x06slaves\x18\x05 \x03(\v2\x1b.alox.OtaSlaveProgressEntryB\x05\x92?\x02\x10\x10R\x06slaves*\xd7\x02\n" +
|
||||
"\vMessageType\x12\v\n" +
|
||||
"\aUNKNOWN\x10\x00\x12\a\n" +
|
||||
"\x03ACK\x10\x01\x12\b\n" +
|
||||
@ -2540,7 +2822,8 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"\aFIND_ME\x10\x16\x12\v\n" +
|
||||
"\aRESTART\x10\x17\x12\x12\n" +
|
||||
"\x0eACCEL_SNAPSHOT\x10\x18\x12\x10\n" +
|
||||
"\fACCEL_STREAM\x10\x19b\x06proto3"
|
||||
"\fACCEL_STREAM\x10\x19\x12\x12\n" +
|
||||
"\x0eBATTERY_STATUS\x10\x1ab\x06proto3"
|
||||
|
||||
var (
|
||||
file_uart_messages_proto_rawDescOnce sync.Once
|
||||
@ -2555,7 +2838,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, 30)
|
||||
var file_uart_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 34)
|
||||
var file_uart_messages_proto_goTypes = []any{
|
||||
(MessageType)(0), // 0: alox.MessageType
|
||||
(*UartMessage)(nil), // 1: alox.UartMessage
|
||||
@ -2570,24 +2853,28 @@ var file_uart_messages_proto_goTypes = []any{
|
||||
(*AccelDeadzoneResponse)(nil), // 10: alox.AccelDeadzoneResponse
|
||||
(*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
|
||||
(*BatteryStatusRequest)(nil), // 13: alox.BatteryStatusRequest
|
||||
(*LipoReading)(nil), // 14: alox.LipoReading
|
||||
(*BatterySample)(nil), // 15: alox.BatterySample
|
||||
(*BatteryStatusResponse)(nil), // 16: alox.BatteryStatusResponse
|
||||
(*AccelSnapshotRequest)(nil), // 17: alox.AccelSnapshotRequest
|
||||
(*AccelSample)(nil), // 18: alox.AccelSample
|
||||
(*AccelSnapshotResponse)(nil), // 19: alox.AccelSnapshotResponse
|
||||
(*EspNowUnicastTestRequest)(nil), // 20: alox.EspNowUnicastTestRequest
|
||||
(*EspNowUnicastTestResponse)(nil), // 21: alox.EspNowUnicastTestResponse
|
||||
(*LedRingProgressRequest)(nil), // 22: alox.LedRingProgressRequest
|
||||
(*LedRingProgressResponse)(nil), // 23: alox.LedRingProgressResponse
|
||||
(*EspNowFindMeRequest)(nil), // 24: alox.EspNowFindMeRequest
|
||||
(*EspNowFindMeResponse)(nil), // 25: alox.EspNowFindMeResponse
|
||||
(*RestartRequest)(nil), // 26: alox.RestartRequest
|
||||
(*RestartResponse)(nil), // 27: alox.RestartResponse
|
||||
(*OtaStartPayload)(nil), // 28: alox.OtaStartPayload
|
||||
(*OtaPayload)(nil), // 29: alox.OtaPayload
|
||||
(*OtaEndPayload)(nil), // 30: alox.OtaEndPayload
|
||||
(*OtaStatusPayload)(nil), // 31: alox.OtaStatusPayload
|
||||
(*OtaSlaveProgressRequest)(nil), // 32: alox.OtaSlaveProgressRequest
|
||||
(*OtaSlaveProgressEntry)(nil), // 33: alox.OtaSlaveProgressEntry
|
||||
(*OtaSlaveProgressResponse)(nil), // 34: alox.OtaSlaveProgressResponse
|
||||
}
|
||||
var file_uart_messages_proto_depIdxs = []int32{
|
||||
0, // 0: alox.UartMessage.type:type_name -> alox.MessageType
|
||||
@ -2596,35 +2883,40 @@ 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
|
||||
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
|
||||
28, // 6: alox.UartMessage.ota_start:type_name -> alox.OtaStartPayload
|
||||
29, // 7: alox.UartMessage.ota_payload:type_name -> alox.OtaPayload
|
||||
30, // 8: alox.UartMessage.ota_end:type_name -> alox.OtaEndPayload
|
||||
31, // 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
|
||||
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
|
||||
20, // 12: alox.UartMessage.espnow_unicast_test_request:type_name -> alox.EspNowUnicastTestRequest
|
||||
21, // 13: alox.UartMessage.espnow_unicast_test_response:type_name -> alox.EspNowUnicastTestResponse
|
||||
32, // 14: alox.UartMessage.ota_slave_progress_request:type_name -> alox.OtaSlaveProgressRequest
|
||||
34, // 15: alox.UartMessage.ota_slave_progress_response:type_name -> alox.OtaSlaveProgressResponse
|
||||
22, // 16: alox.UartMessage.led_ring_progress_request:type_name -> alox.LedRingProgressRequest
|
||||
23, // 17: alox.UartMessage.led_ring_progress_response:type_name -> alox.LedRingProgressResponse
|
||||
24, // 18: alox.UartMessage.espnow_find_me_request:type_name -> alox.EspNowFindMeRequest
|
||||
25, // 19: alox.UartMessage.espnow_find_me_response:type_name -> alox.EspNowFindMeResponse
|
||||
26, // 20: alox.UartMessage.restart_request:type_name -> alox.RestartRequest
|
||||
27, // 21: alox.UartMessage.restart_response:type_name -> alox.RestartResponse
|
||||
17, // 22: alox.UartMessage.accel_snapshot_request:type_name -> alox.AccelSnapshotRequest
|
||||
19, // 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
|
||||
13, // 26: alox.UartMessage.battery_status_request:type_name -> alox.BatteryStatusRequest
|
||||
16, // 27: alox.UartMessage.battery_status_response:type_name -> alox.BatteryStatusResponse
|
||||
5, // 28: alox.ClientInfoResponse.clients:type_name -> alox.ClientInfo
|
||||
7, // 29: alox.ClientInputResponse.clients:type_name -> alox.ClientInput
|
||||
14, // 30: alox.BatterySample.lipo1:type_name -> alox.LipoReading
|
||||
14, // 31: alox.BatterySample.lipo2:type_name -> alox.LipoReading
|
||||
15, // 32: alox.BatteryStatusResponse.samples:type_name -> alox.BatterySample
|
||||
18, // 33: alox.AccelSnapshotResponse.samples:type_name -> alox.AccelSample
|
||||
33, // 34: alox.OtaSlaveProgressResponse.slaves:type_name -> alox.OtaSlaveProgressEntry
|
||||
35, // [35:35] is the sub-list for method output_type
|
||||
35, // [35:35] is the sub-list for method input_type
|
||||
35, // [35:35] is the sub-list for extension type_name
|
||||
35, // [35:35] is the sub-list for extension extendee
|
||||
0, // [0:35] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_uart_messages_proto_init() }
|
||||
@ -2658,6 +2950,8 @@ func file_uart_messages_proto_init() {
|
||||
(*UartMessage_AccelSnapshotResponse)(nil),
|
||||
(*UartMessage_AccelStreamRequest)(nil),
|
||||
(*UartMessage_AccelStreamResponse)(nil),
|
||||
(*UartMessage_BatteryStatusRequest)(nil),
|
||||
(*UartMessage_BatteryStatusResponse)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -2665,7 +2959,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: 30,
|
||||
NumMessages: 34,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@ -119,7 +119,7 @@ func (m *managedSerial) exchangePayloadVia(
|
||||
var resp []byte
|
||||
err := portFn(func(sp *serialPort) error {
|
||||
var e error
|
||||
resp, e = sp.exchangePayloadLocked(payload, cmdName)
|
||||
resp, e = sp.exchangePayloadLocked(payload, cmdName, readTimeout)
|
||||
return e
|
||||
})
|
||||
return resp, err
|
||||
|
||||
@ -12,6 +12,9 @@ import (
|
||||
|
||||
const readTimeout = 3 * time.Second
|
||||
|
||||
// batteryReadTimeout: master may query each slave over ESP-NOW (~400 ms each).
|
||||
const batteryReadTimeout = 12 * time.Second
|
||||
|
||||
type serialPort struct {
|
||||
port serial.Port
|
||||
mu sync.Mutex
|
||||
@ -44,10 +47,16 @@ func (s *serialPort) Close() error {
|
||||
func (s *serialPort) exchangePayload(payload []byte, cmdName string) ([]byte, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.exchangePayloadLocked(payload, cmdName)
|
||||
return s.exchangePayloadLocked(payload, cmdName, readTimeout)
|
||||
}
|
||||
|
||||
func (s *serialPort) exchangePayloadLocked(payload []byte, cmdName string) ([]byte, error) {
|
||||
func (s *serialPort) exchangePayloadForBattery(payload []byte, cmdName string) ([]byte, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.exchangePayloadLocked(payload, cmdName, batteryReadTimeout)
|
||||
}
|
||||
|
||||
func (s *serialPort) exchangePayloadLocked(payload []byte, cmdName string, timeout time.Duration) ([]byte, error) {
|
||||
if len(payload) == 0 {
|
||||
return nil, fmt.Errorf("empty payload")
|
||||
}
|
||||
@ -63,6 +72,14 @@ func (s *serialPort) exchangePayloadLocked(payload []byte, cmdName string) ([]by
|
||||
return nil, fmt.Errorf("write: %w", err)
|
||||
}
|
||||
|
||||
if timeout <= 0 {
|
||||
timeout = readTimeout
|
||||
}
|
||||
if err := s.port.SetReadTimeout(timeout); err != nil {
|
||||
return nil, fmt.Errorf("set read timeout: %w", err)
|
||||
}
|
||||
defer func() { _ = s.port.SetReadTimeout(readTimeout) }()
|
||||
|
||||
respPayload, err := uartframe.ReadFrame(s.port, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read response: %w", err)
|
||||
|
||||
@ -200,6 +200,10 @@
|
||||
<dd class="col-7" x-text="state.master.running_partition || '—'"></dd>
|
||||
<dt class="col-5 text-muted">Deadzone</dt>
|
||||
<dd class="col-7" x-text="state.master.deadzone != null ? state.master.deadzone + ' LSB' : '—'"></dd>
|
||||
<dt class="col-5 text-muted">LiPo 1</dt>
|
||||
<dd class="col-7" x-text="formatLipo(state.master?.lipo1)"></dd>
|
||||
<dt class="col-5 text-muted">LiPo 2</dt>
|
||||
<dd class="col-7" x-text="formatLipo(state.master?.lipo2)"></dd>
|
||||
</dl>
|
||||
</template>
|
||||
<template x-if="state.master && !state.master.ok">
|
||||
@ -280,13 +284,14 @@
|
||||
<th>Status</th>
|
||||
<th>Deadzone</th>
|
||||
<th>Accel (LSB)</th>
|
||||
<th>Akku</th>
|
||||
<th>Stream</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template x-if="!(state.clients || []).length">
|
||||
<tr><td colspan="8" class="text-muted text-center py-4">No clients</td></tr>
|
||||
<tr><td colspan="9" class="text-muted text-center py-4">No clients</td></tr>
|
||||
</template>
|
||||
<template x-for="c in (state.clients || [])" :key="c.id + c.mac">
|
||||
<tr>
|
||||
@ -305,6 +310,7 @@
|
||||
x-text="formatAccel(c)"
|
||||
:title="accelTitle(c)"></span>
|
||||
</td>
|
||||
<td class="small" x-text="formatLipoPair(c)" :title="lipoTitle(c)"></td>
|
||||
<td>
|
||||
<button type="button"
|
||||
class="btn btn-sm"
|
||||
@ -576,9 +582,14 @@
|
||||
connect() {
|
||||
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const url = proto + '//' + location.host + '/ws';
|
||||
if (this._batteryTimer) clearInterval(this._batteryTimer);
|
||||
this._batteryTimer = setInterval(() => this.refreshBattery(), 5000);
|
||||
const connect = () => {
|
||||
this.ws = new WebSocket(url);
|
||||
this.ws.onopen = () => { this.wsConnected = true; };
|
||||
this.ws.onopen = () => {
|
||||
this.wsConnected = true;
|
||||
this.refreshBattery();
|
||||
};
|
||||
this.ws.onclose = () => {
|
||||
this.wsConnected = false;
|
||||
setTimeout(connect, 2000);
|
||||
@ -590,7 +601,13 @@
|
||||
this.applyOTAProgress(msg);
|
||||
return;
|
||||
}
|
||||
if (msg.type === 'battery_status') {
|
||||
if (msg.samples?.length) this.applyBatterySamples(msg.samples);
|
||||
return;
|
||||
}
|
||||
const prev = this.state;
|
||||
this.state = msg;
|
||||
this.preserveBatteryInState(prev, this.state);
|
||||
if (msg.master?.deadzone != null) {
|
||||
this.masterDz = msg.master.deadzone;
|
||||
}
|
||||
@ -604,10 +621,87 @@
|
||||
};
|
||||
connect();
|
||||
},
|
||||
preserveBatteryInState(prev, next) {
|
||||
if (!prev || !next) return;
|
||||
const keepLipo = (oldL, newL) => {
|
||||
if (newL?.valid) return newL;
|
||||
if (oldL?.valid) return oldL;
|
||||
return newL ?? oldL;
|
||||
};
|
||||
const keepAge = (oldAge, newAge, hasValid) => {
|
||||
if (hasValid && newAge != null) return newAge;
|
||||
if (oldAge != null && !hasValid) return oldAge;
|
||||
return newAge ?? oldAge;
|
||||
};
|
||||
if (next.master) {
|
||||
const pm = prev.master || {};
|
||||
const l1 = keepLipo(pm.lipo1, next.master.lipo1);
|
||||
const l2 = keepLipo(pm.lipo2, next.master.lipo2);
|
||||
next.master.lipo1 = l1;
|
||||
next.master.lipo2 = l2;
|
||||
next.master.battery_age_ms = keepAge(
|
||||
pm.battery_age_ms, next.master.battery_age_ms, !!(l1?.valid || l2?.valid));
|
||||
}
|
||||
if (!Array.isArray(next.clients)) return;
|
||||
const prevById = Object.fromEntries((prev.clients || []).map((c) => [c.id, c]));
|
||||
next.clients = next.clients.map((c) => {
|
||||
const p = prevById[c.id];
|
||||
if (!p) return c;
|
||||
const l1 = keepLipo(p.lipo1, c.lipo1);
|
||||
const l2 = keepLipo(p.lipo2, c.lipo2);
|
||||
return {
|
||||
...c,
|
||||
lipo1: l1,
|
||||
lipo2: l2,
|
||||
battery_age_ms: keepAge(p.battery_age_ms, c.battery_age_ms, !!(l1?.valid || l2?.valid))
|
||||
};
|
||||
});
|
||||
},
|
||||
applyBatterySamples(samples) {
|
||||
if (!samples?.length) return;
|
||||
for (const s of samples) {
|
||||
if (s.client_id === 0) {
|
||||
if (!this.state.master) this.state.master = {};
|
||||
this.state.master.lipo1 = s.lipo1;
|
||||
this.state.master.lipo2 = s.lipo2;
|
||||
this.state.master.battery_age_ms = s.age_ms;
|
||||
continue;
|
||||
}
|
||||
const c = (this.state.clients || []).find((x) => x.id === s.client_id);
|
||||
if (c) {
|
||||
c.lipo1 = s.lipo1;
|
||||
c.lipo2 = s.lipo2;
|
||||
c.battery_age_ms = s.age_ms;
|
||||
}
|
||||
}
|
||||
},
|
||||
async refreshBattery() {
|
||||
if (!this.state?.uart_connected) return;
|
||||
try {
|
||||
const r = await fetch('/api/battery?all_clients=1');
|
||||
if (!r.ok) return;
|
||||
const data = await r.json();
|
||||
if (data.samples?.length) this.applyBatterySamples(data.samples);
|
||||
} catch (_) {}
|
||||
},
|
||||
formatMac(hex) {
|
||||
if (!hex || hex.length !== 12) return hex || '';
|
||||
return hex.match(/.{2}/g).join(':');
|
||||
},
|
||||
formatLipo(l) {
|
||||
if (!l?.valid) return '—';
|
||||
const v = (l.voltage_mv / 1000).toFixed(2);
|
||||
return l.percent != null ? `${v} V (${l.percent}%)` : `${v} V`;
|
||||
},
|
||||
formatLipoPair(c) {
|
||||
return `1: ${this.formatLipo(c?.lipo1)} · 2: ${this.formatLipo(c?.lipo2)}`;
|
||||
},
|
||||
lipoTitle(c) {
|
||||
if (!c?.lipo1?.valid && !c?.lipo2?.valid) return 'Keine ADC-Daten (Cache ~30 s)';
|
||||
let t = `LiPo1 ${c.lipo1?.voltage_mv ?? '—'} mV, LiPo2 ${c.lipo2?.voltage_mv ?? '—'} mV`;
|
||||
if (c.battery_age_ms != null) t += `, Alter ${c.battery_age_ms} ms`;
|
||||
return t;
|
||||
},
|
||||
formatAccel(c) {
|
||||
if (!c?.accel_stream) return '—';
|
||||
if (!c?.accel_valid) return '…';
|
||||
|
||||
@ -25,6 +25,7 @@ idf_component_register(
|
||||
"cmd/cmd_restart.c"
|
||||
"pod_reboot.c"
|
||||
"cmd/cmd_led_ring.c"
|
||||
"cmd/cmd_battery.c"
|
||||
"cmd/cmd_ota.c"
|
||||
"cmd/cmd_ota_slave_progress.c"
|
||||
"ota_uart.c"
|
||||
|
||||
@ -116,6 +116,7 @@ Schema: `proto/esp_now_messages.proto`. Encode/decode: `esp_now_proto.c`. The ES
|
||||
| `ESPNOW_FIND_ME` | Master → slave | `EspNowFindMe` (`client_id` filter) — LED locate sequence |
|
||||
| `ESPNOW_RESTART` | Master → slave | `EspNowRestart` (`client_id` filter) — reboot slave |
|
||||
| `ESPNOW_ACCEL_SAMPLE` | Slave → master | `EspNowAccelSample` (`slave_id`, `x`, `y`, `z` raw LSB) — ~every 16 ms |
|
||||
| `ESPNOW_BATTERY_REPORT` | Slave → master | `EspNowBatteryReport` (`client_id`, `lipo1/2` mV) — ~every 30 s; cached in `client_registry` |
|
||||
| `ESPNOW_OTA_START` | Master → slave (unicast) | `EspNowOtaStart` (`total_size`) |
|
||||
| `ESPNOW_OTA_PAYLOAD` | Master → slave | `EspNowOtaPayload` (`seq`, up to 200 B `data`) |
|
||||
| `ESPNOW_OTA_END` | Master → slave | `EspNowOtaEnd` |
|
||||
@ -210,6 +211,7 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
|
||||
| 6 | `ACCEL_DEADZONE` | Implemented (`cmd/cmd_accel_deadzone.c`) — get/set accel filter LSB |
|
||||
| 7 | `ESPNOW_UNICAST_TEST` | Implemented (`cmd/cmd_espnow_unicast_test.c`) |
|
||||
| 8 | `LED_RING` | Implemented (`cmd/cmd_led_ring.c`) — ring progress bar (0–100 %, RGB, intensity) |
|
||||
| 26 | `BATTERY_STATUS` | Implemented (`cmd/cmd_battery.c`) — cached LiPo 1/2 per pod from `client_registry` (UART read, no slave round-trip) |
|
||||
| 16 | `OTA_START` | Implemented (`cmd/cmd_ota.c`) — begin UART OTA on inactive slot |
|
||||
| 17 | `OTA_PAYLOAD` | Implemented — up to 200 B per frame; device buffers 4 KiB |
|
||||
| 18 | `OTA_END` | Implemented — flush, `esp_ota_end`, push image to slaves via ESP-NOW, set boot |
|
||||
@ -370,6 +372,18 @@ go run . -port /dev/ttyUSB0 restart
|
||||
go run . -port /dev/ttyUSB0 restart -client 16
|
||||
```
|
||||
|
||||
### BATTERY_STATUS command
|
||||
|
||||
Read **cached** LiPo ADC values on the **master** (master local + one entry per registered slave). Slaves push `ESPNOW_BATTERY_REPORT` every **30 s**; the master stores them in `client_registry` (`lipo1/2_valid`, `lipo1/2_mv`, `battery_updated_at`). The master refreshes its own pack on the same interval in `master_monitor_task`.
|
||||
|
||||
**Request:** framed `26` + optional `battery_status_request` (`client_id`, `all_clients`).
|
||||
|
||||
**Response:** `battery_status_response` with `samples[]` (`client_id`, `lipo1`, `lipo2`, `age_ms`).
|
||||
|
||||
```bash
|
||||
# Host / goTool: all_clients returns master (id 0) + slaves from cache
|
||||
```
|
||||
|
||||
### LED_RING command
|
||||
|
||||
Control the 95-LED ring from the host. The firmware **does not** animate digits locally; only UART updates the display.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "freertos/queue.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char *TAG_BTN = "[BTN]";
|
||||
static const char *TAG_LIPO = "[LIPO]";
|
||||
@ -14,6 +14,8 @@ static const char *TAG_LIPO = "[LIPO]";
|
||||
#define LIPO_SAMPLE_INTERVAL_MS 10000
|
||||
#define BUTTON_QUEUE_LEN 4
|
||||
#define BUTTON_DEBOUNCE_MS 80
|
||||
#define LIPO_ADC_FULL_SCALE_MV 3300
|
||||
#define LIPO_ADC_MAX_RAW 4095
|
||||
|
||||
static QueueHandle_t s_button_queue;
|
||||
static adc_oneshot_unit_handle_t s_adc;
|
||||
@ -47,33 +49,51 @@ static esp_err_t adc_init_channel(int gpio, adc_channel_t *out_ch, bool *out_ok)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static uint32_t raw_to_mv(int raw) {
|
||||
if (raw < 0) {
|
||||
return 0;
|
||||
}
|
||||
return (uint32_t)((raw * LIPO_ADC_FULL_SCALE_MV) / LIPO_ADC_MAX_RAW);
|
||||
}
|
||||
|
||||
static void sample_one_channel(adc_channel_t ch, bool ok, uint32_t *mv_out,
|
||||
bool *valid_out) {
|
||||
*valid_out = false;
|
||||
*mv_out = 0;
|
||||
if (!ok || s_adc == NULL) {
|
||||
return;
|
||||
}
|
||||
int raw = 0;
|
||||
if (adc_oneshot_read(s_adc, ch, &raw) == ESP_OK) {
|
||||
*valid_out = true;
|
||||
*mv_out = raw_to_mv(raw);
|
||||
}
|
||||
}
|
||||
|
||||
void board_input_read_lipo(board_lipo_reading_t *out) {
|
||||
if (out == NULL) {
|
||||
return;
|
||||
}
|
||||
memset(out, 0, sizeof(*out));
|
||||
sample_one_channel(s_lipo1_ch, s_lipo1_ok, &out->lipo1_mv, &out->lipo1_valid);
|
||||
sample_one_channel(s_lipo2_ch, s_lipo2_ok, &out->lipo2_mv, &out->lipo2_valid);
|
||||
}
|
||||
|
||||
static void lipo_monitor_task(void *param) {
|
||||
(void)param;
|
||||
|
||||
ESP_LOGI(TAG_LIPO, "monitor task (interval %d ms)", LIPO_SAMPLE_INTERVAL_MS);
|
||||
|
||||
while (1) {
|
||||
int raw1 = -1;
|
||||
int raw2 = -1;
|
||||
int mv1 = -1;
|
||||
int mv2 = -1;
|
||||
|
||||
if (s_lipo1_ok) {
|
||||
raw1 = 0;
|
||||
if (adc_oneshot_read(s_adc, s_lipo1_ch, &raw1) == ESP_OK) {
|
||||
mv1 = (raw1 * 3300) / 4095;
|
||||
}
|
||||
}
|
||||
if (s_lipo2_ok) {
|
||||
raw2 = 0;
|
||||
if (adc_oneshot_read(s_adc, s_lipo2_ch, &raw2) == ESP_OK) {
|
||||
mv2 = (raw2 * 3300) / 4095;
|
||||
}
|
||||
}
|
||||
board_lipo_reading_t reading;
|
||||
board_input_read_lipo(&reading);
|
||||
|
||||
ESP_LOGI(TAG_LIPO,
|
||||
"LIPO1 GPIO%d raw=%d (~%d mV) LIPO2 GPIO%d raw=%d (~%d mV)",
|
||||
V_LIPO_1_GPIO, raw1, mv1, V_LIPO_2_GPIO, raw2, mv2);
|
||||
"LIPO1 GPIO%d %s %lu mV LIPO2 GPIO%d %s %lu mV",
|
||||
V_LIPO_1_GPIO, reading.lipo1_valid ? "ok" : "n/a",
|
||||
(unsigned long)reading.lipo1_mv, V_LIPO_2_GPIO,
|
||||
reading.lipo2_valid ? "ok" : "n/a",
|
||||
(unsigned long)reading.lipo2_mv);
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(LIPO_SAMPLE_INTERVAL_MS));
|
||||
}
|
||||
|
||||
@ -1,12 +1,25 @@
|
||||
#ifndef BOARD_INPUT_H
|
||||
#define BOARD_INPUT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
typedef struct {
|
||||
bool lipo1_valid;
|
||||
bool lipo2_valid;
|
||||
uint32_t lipo1_mv;
|
||||
uint32_t lipo2_mv;
|
||||
} board_lipo_reading_t;
|
||||
|
||||
/**
|
||||
* Button (log on press) and LiPo ADC sampling (log every 10 s).
|
||||
* Button (log on press) and LiPo ADC sampling (background log every 10 s).
|
||||
* TODO: Pin assignments come from powerpod.h and may not match final hardware yet.
|
||||
*/
|
||||
esp_err_t board_input_init(void);
|
||||
|
||||
/** On-demand ADC read of both LiPo sense inputs (if configured). */
|
||||
void board_input_read_lipo(board_lipo_reading_t *out);
|
||||
|
||||
#endif
|
||||
|
||||
@ -14,6 +14,11 @@ typedef struct {
|
||||
|
||||
static client_slot_t s_clients[CLIENT_REGISTRY_MAX];
|
||||
|
||||
static struct {
|
||||
board_lipo_reading_t reading;
|
||||
uint32_t updated_at;
|
||||
} s_master_battery;
|
||||
|
||||
uint32_t client_registry_now_ms(void) {
|
||||
return (uint32_t)(xTaskGetTickCount() * portTICK_PERIOD_MS);
|
||||
}
|
||||
@ -320,6 +325,64 @@ esp_err_t client_registry_update_accel(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void client_registry_set_master_battery(const board_lipo_reading_t *reading) {
|
||||
if (reading == NULL) {
|
||||
return;
|
||||
}
|
||||
s_master_battery.reading = *reading;
|
||||
s_master_battery.updated_at = now_ms();
|
||||
}
|
||||
|
||||
bool client_registry_get_master_battery(board_lipo_reading_t *reading_out,
|
||||
uint32_t *age_ms_out) {
|
||||
if (reading_out == NULL) {
|
||||
return false;
|
||||
}
|
||||
*reading_out = s_master_battery.reading;
|
||||
if (age_ms_out != NULL) {
|
||||
*age_ms_out = client_registry_ms_since(s_master_battery.updated_at);
|
||||
}
|
||||
return s_master_battery.updated_at != 0;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_update_battery(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t slave_id, bool lipo1_valid,
|
||||
uint32_t lipo1_mv, bool lipo2_valid,
|
||||
uint32_t lipo2_mv) {
|
||||
if (mac == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
client_slot_t *slot = find_slot(mac);
|
||||
if (slot == NULL) {
|
||||
bool is_new = false;
|
||||
esp_err_t err = client_registry_upsert(mac, slave_id, 0, true, false, &is_new);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
slot = find_slot(mac);
|
||||
if (slot == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
ESP_LOGI(TAG, "battery auto-registered id=%lu (report before heartbeat)",
|
||||
(unsigned long)slave_id);
|
||||
}
|
||||
|
||||
if (slot->info.id != slave_id) {
|
||||
ESP_LOGW(TAG, "battery id %lu → %lu for mac %02x:…:%02x",
|
||||
(unsigned long)slot->info.id, (unsigned long)slave_id, mac[0],
|
||||
mac[5]);
|
||||
slot->info.id = slave_id;
|
||||
}
|
||||
|
||||
slot->info.lipo1_valid = lipo1_valid;
|
||||
slot->info.lipo2_valid = lipo2_valid;
|
||||
slot->info.lipo1_mv = lipo1_mv;
|
||||
slot->info.lipo2_mv = lipo2_mv;
|
||||
slot->info.battery_updated_at = now_ms();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const client_info_t *client_registry_at(size_t index) {
|
||||
size_t n = 0;
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef CLIENT_REGISTRY_H
|
||||
#define CLIENT_REGISTRY_H
|
||||
|
||||
#include "board_input.h"
|
||||
#include "esp_err.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@ -29,6 +30,12 @@ typedef struct {
|
||||
uint32_t accel_updated_at;
|
||||
/** Host-enabled ESP-NOW accel stream to master. */
|
||||
bool accel_stream_enabled;
|
||||
/** Latest LiPo ADC from slave ESP-NOW battery report (~30 s). */
|
||||
bool lipo1_valid;
|
||||
bool lipo2_valid;
|
||||
uint32_t lipo1_mv;
|
||||
uint32_t lipo2_mv;
|
||||
uint32_t battery_updated_at;
|
||||
} client_info_t;
|
||||
|
||||
#define CLIENT_REGISTRY_DEFAULT_ACCEL_DEADZONE 100u
|
||||
@ -80,4 +87,15 @@ esp_err_t client_registry_set_accel_stream(uint32_t client_id, bool enabled);
|
||||
esp_err_t client_registry_get_accel_stream(uint32_t client_id, bool *enabled_out);
|
||||
size_t client_registry_set_accel_stream_all(bool enabled);
|
||||
|
||||
/** Master local LiPo (client_id 0 in UART battery responses). */
|
||||
void client_registry_set_master_battery(const board_lipo_reading_t *reading);
|
||||
bool client_registry_get_master_battery(board_lipo_reading_t *reading_out,
|
||||
uint32_t *age_ms_out);
|
||||
|
||||
/** Store latest battery report from a slave (matched by sender MAC). */
|
||||
esp_err_t client_registry_update_battery(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t slave_id, bool lipo1_valid,
|
||||
uint32_t lipo1_mv, bool lipo2_valid,
|
||||
uint32_t lipo2_mv);
|
||||
|
||||
#endif
|
||||
|
||||
119
main/cmd/cmd_battery.c
Normal file
119
main/cmd/cmd_battery.c
Normal file
@ -0,0 +1,119 @@
|
||||
#include "cmd_battery.h"
|
||||
#include "board_input.h"
|
||||
#include "client_registry.h"
|
||||
#include "esp_log.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[BATTERY]";
|
||||
|
||||
static void fill_lipo(alox_LipoReading *dst, bool *has_dst, bool valid,
|
||||
uint32_t mv) {
|
||||
if (dst == NULL || has_dst == NULL) {
|
||||
return;
|
||||
}
|
||||
*has_dst = true;
|
||||
dst->valid = valid;
|
||||
dst->voltage_mv = valid ? mv : 0;
|
||||
}
|
||||
|
||||
static bool append_battery_sample(alox_BatteryStatusResponse *resp,
|
||||
uint32_t client_id, bool lipo1_valid,
|
||||
uint32_t lipo1_mv, bool lipo2_valid,
|
||||
uint32_t lipo2_mv, uint32_t age_ms) {
|
||||
if (resp->samples_count >=
|
||||
sizeof(resp->samples) / sizeof(resp->samples[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
alox_BatterySample *sample = &resp->samples[resp->samples_count++];
|
||||
sample->client_id = client_id;
|
||||
fill_lipo(&sample->lipo1, &sample->has_lipo1, lipo1_valid, lipo1_mv);
|
||||
fill_lipo(&sample->lipo2, &sample->has_lipo2, lipo2_valid, lipo2_mv);
|
||||
sample->age_ms = age_ms;
|
||||
return lipo1_valid || lipo2_valid;
|
||||
}
|
||||
|
||||
static bool append_master_cached(alox_BatteryStatusResponse *resp) {
|
||||
board_lipo_reading_t reading;
|
||||
uint32_t age_ms = 0;
|
||||
|
||||
if (!client_registry_get_master_battery(&reading, &age_ms)) {
|
||||
board_input_read_lipo(&reading);
|
||||
client_registry_set_master_battery(&reading);
|
||||
age_ms = 0;
|
||||
}
|
||||
|
||||
return append_battery_sample(resp, 0, reading.lipo1_valid, reading.lipo1_mv,
|
||||
reading.lipo2_valid, reading.lipo2_mv, age_ms);
|
||||
}
|
||||
|
||||
static bool append_slave_cached(alox_BatteryStatusResponse *resp,
|
||||
const client_info_t *client) {
|
||||
if (client == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (client->battery_updated_at == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return append_battery_sample(
|
||||
resp, client->id, client->lipo1_valid, client->lipo1_mv,
|
||||
client->lipo2_valid, client->lipo2_mv,
|
||||
client_registry_ms_since(client->battery_updated_at));
|
||||
}
|
||||
|
||||
static void handle_battery_status(const uint8_t *data, size_t len) {
|
||||
alox_BatteryStatusRequest req = alox_BatteryStatusRequest_init_zero;
|
||||
|
||||
if (len > 0) {
|
||||
alox_UartMessage uart_msg;
|
||||
if (uart_cmd_decode(data, len, &uart_msg) == ESP_OK) {
|
||||
const alox_BatteryStatusRequest *req_ptr = UART_CMD_REQ(
|
||||
&uart_msg, alox_UartMessage_battery_status_request_tag,
|
||||
battery_status_request);
|
||||
if (req_ptr != NULL) {
|
||||
req = *req_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alox_UartMessage response;
|
||||
uart_cmd_init_response(&response, alox_MessageType_BATTERY_STATUS,
|
||||
alox_UartMessage_battery_status_response_tag);
|
||||
alox_BatteryStatusResponse *resp =
|
||||
&response.payload.battery_status_response;
|
||||
resp->success = false;
|
||||
resp->samples_count = 0;
|
||||
|
||||
bool any = false;
|
||||
|
||||
if (req.all_clients) {
|
||||
any |= append_master_cached(resp);
|
||||
for (size_t i = 0; i < client_registry_count(); i++) {
|
||||
const client_info_t *client = client_registry_at(i);
|
||||
if (client == NULL) {
|
||||
continue;
|
||||
}
|
||||
any |= append_slave_cached(resp, client);
|
||||
}
|
||||
ESP_LOGI(TAG, "battery cache all_clients → %u samples",
|
||||
(unsigned)resp->samples_count);
|
||||
} else if (req.client_id == 0) {
|
||||
any = append_master_cached(resp);
|
||||
ESP_LOGI(TAG, "battery cache master");
|
||||
} else {
|
||||
const client_info_t *client = client_registry_find_by_id(req.client_id);
|
||||
if (client != NULL) {
|
||||
any = append_slave_cached(resp, client);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "client %lu not in registry", (unsigned long)req.client_id);
|
||||
}
|
||||
}
|
||||
|
||||
resp->success = any;
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
void cmd_battery_register(void) {
|
||||
uart_cmd_register(alox_MessageType_BATTERY_STATUS, handle_battery_status);
|
||||
}
|
||||
6
main/cmd/cmd_battery.h
Normal file
6
main/cmd/cmd_battery.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef CMD_BATTERY_H
|
||||
#define CMD_BATTERY_H
|
||||
|
||||
void cmd_battery_register(void);
|
||||
|
||||
#endif
|
||||
@ -52,6 +52,8 @@ static const char *message_type_name(uint16_t id) {
|
||||
return "ACCEL_SNAPSHOT";
|
||||
case alox_MessageType_ACCEL_STREAM:
|
||||
return "ACCEL_STREAM";
|
||||
case alox_MessageType_BATTERY_STATUS:
|
||||
return "BATTERY_STATUS";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "bosch456.h"
|
||||
#include "client_registry.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "board_input.h"
|
||||
#include "cmd_led_ring.h"
|
||||
#include "led_ring.h"
|
||||
#include "ota_espnow.h"
|
||||
@ -48,6 +49,16 @@ static uint32_t s_last_discover_ms;
|
||||
static SemaphoreHandle_t s_send_done;
|
||||
static bool s_send_cb_ready;
|
||||
|
||||
#define ESPNOW_BATTERY_INTERVAL_MS 30000
|
||||
#define SLAVE_BATTERY_AFTER_JOIN_MS 150
|
||||
|
||||
typedef enum {
|
||||
SLAVE_TX_SLAVE_INFO = 1,
|
||||
SLAVE_TX_BATTERY,
|
||||
} slave_tx_op_t;
|
||||
|
||||
static QueueHandle_t s_slave_tx_queue;
|
||||
|
||||
static uint32_t now_ms(void) {
|
||||
return (uint32_t)(xTaskGetTickCount() * portTICK_PERIOD_MS);
|
||||
}
|
||||
@ -90,6 +101,7 @@ static esp_err_t ensure_broadcast_peer(void) { return ensure_peer(ESPNOW_BCAST);
|
||||
|
||||
static esp_err_t send_message_ex(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg, bool wait_done);
|
||||
static void slave_send_battery_report_to_master(void);
|
||||
|
||||
static void fill_presence(alox_EspNowSlavePresence *presence) {
|
||||
presence->network = s_config.network;
|
||||
@ -210,6 +222,21 @@ static esp_err_t send_find_me(const uint8_t *dest_mac, uint32_t client_id) {
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_battery_report(const uint8_t *dest_mac,
|
||||
const alox_EspNowBatteryReport *report) {
|
||||
if (report == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
|
||||
msg.type = alox_EspNowMessageType_ESPNOW_BATTERY_REPORT;
|
||||
msg.which_payload = alox_EspNowMessage_battery_report_tag;
|
||||
msg.payload.battery_report = *report;
|
||||
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_led_ring(const uint8_t *dest_mac, uint32_t client_id,
|
||||
const alox_LedRingProgressRequest *req) {
|
||||
if (req == NULL) {
|
||||
@ -470,6 +497,47 @@ static void slave_reset_join(void) {
|
||||
s_accel_stream_enabled = false;
|
||||
memset(s_master_mac, 0, sizeof(s_master_mac));
|
||||
s_last_discover_ms = 0;
|
||||
if (s_slave_tx_queue != NULL) {
|
||||
xQueueReset(s_slave_tx_queue);
|
||||
}
|
||||
}
|
||||
|
||||
static void slave_queue_tx(slave_tx_op_t op) {
|
||||
if (s_slave_tx_queue == NULL) {
|
||||
return;
|
||||
}
|
||||
if (xQueueSend(s_slave_tx_queue, &op, 0) != pdTRUE) {
|
||||
ESP_LOGW(TAG, "slave tx queue full (op=%d)", (int)op);
|
||||
}
|
||||
}
|
||||
|
||||
static void slave_tx_task(void *param) {
|
||||
(void)param;
|
||||
slave_tx_op_t op;
|
||||
|
||||
ESP_LOGI(TAG, "slave tx task ready");
|
||||
|
||||
while (1) {
|
||||
if (xQueueReceive(s_slave_tx_queue, &op, portMAX_DELAY) != pdTRUE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!s_slave_joined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
case SLAVE_TX_SLAVE_INFO:
|
||||
send_presence(s_master_mac, alox_EspNowMessageType_ESPNOW_SLAVE_INFO);
|
||||
break;
|
||||
case SLAVE_TX_BATTERY:
|
||||
vTaskDelay(pdMS_TO_TICKS(SLAVE_BATTERY_AFTER_JOIN_MS));
|
||||
slave_send_battery_report_to_master();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_slave_unicast_test(const uint8_t *master_mac,
|
||||
@ -499,6 +567,77 @@ static void handle_slave_restart(const uint8_t *master_mac,
|
||||
pod_schedule_restart();
|
||||
}
|
||||
|
||||
static void slave_send_battery_report_to_master(void) {
|
||||
if (!s_slave_joined) {
|
||||
return;
|
||||
}
|
||||
|
||||
board_lipo_reading_t reading;
|
||||
board_input_read_lipo(&reading);
|
||||
|
||||
alox_EspNowBatteryReport report = alox_EspNowBatteryReport_init_zero;
|
||||
report.client_id = s_own_mac[5];
|
||||
report.lipo1_valid = reading.lipo1_valid;
|
||||
report.lipo2_valid = reading.lipo2_valid;
|
||||
report.lipo1_mv = reading.lipo1_mv;
|
||||
report.lipo2_mv = reading.lipo2_mv;
|
||||
|
||||
esp_err_t err = send_battery_report(s_master_mac, &report);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "battery report send failed id=%lu: %s",
|
||||
(unsigned long)report.client_id, esp_err_to_name(err));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "battery report sent id=%lu L1=%s %lu mV L2=%s %lu mV",
|
||||
(unsigned long)report.client_id,
|
||||
report.lipo1_valid ? "ok" : "n/a",
|
||||
(unsigned long)report.lipo1_mv,
|
||||
report.lipo2_valid ? "ok" : "n/a",
|
||||
(unsigned long)report.lipo2_mv);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_slave_battery_query(const uint8_t *master_mac,
|
||||
const alox_EspNowBatteryQuery *query) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
|
||||
if (query->client_id != 0 && query->client_id != my_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_slave_joined && !mac_equal(master_mac, s_master_mac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
slave_send_battery_report_to_master();
|
||||
}
|
||||
|
||||
static void handle_master_battery_report(const uint8_t *mac,
|
||||
const alox_EspNowBatteryReport *report) {
|
||||
if (report == NULL || mac == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t err = client_registry_update_battery(
|
||||
mac, report->client_id, report->lipo1_valid, report->lipo1_mv,
|
||||
report->lipo2_valid, report->lipo2_mv);
|
||||
if (err == ESP_ERR_NOT_FOUND) {
|
||||
ESP_LOGW(TAG, "battery report from unregistered slave id=%lu",
|
||||
(unsigned long)report->client_id);
|
||||
return;
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "battery report id=%lu rejected: %s",
|
||||
(unsigned long)report->client_id, esp_err_to_name(err));
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "battery cached id=%lu L1=%s %lu mV L2=%s %lu mV",
|
||||
(unsigned long)report->client_id,
|
||||
report->lipo1_valid ? "ok" : "n/a",
|
||||
(unsigned long)report->lipo1_mv, report->lipo2_valid ? "ok" : "n/a",
|
||||
(unsigned long)report->lipo2_mv);
|
||||
}
|
||||
|
||||
static void handle_slave_led_ring(const uint8_t *master_mac,
|
||||
const alox_EspNowLedRing *msg) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
@ -670,7 +809,9 @@ static void handle_discover(const uint8_t *sender_mac,
|
||||
ESP_LOGI(TAG, "joined network %u, master %s", (unsigned)discover->network,
|
||||
mac_str);
|
||||
|
||||
send_presence(sender_mac, alox_EspNowMessageType_ESPNOW_SLAVE_INFO);
|
||||
/* Do not esp_now_send from recv callback — defer to slave_tx_task. */
|
||||
slave_queue_tx(SLAVE_TX_SLAVE_INFO);
|
||||
slave_queue_tx(SLAVE_TX_BATTERY);
|
||||
}
|
||||
|
||||
static void slave_check_master_timeout(void) {
|
||||
@ -716,6 +857,7 @@ static void slave_accel_stream_task(void *param) {
|
||||
|
||||
static void slave_heartbeat_task(void *param) {
|
||||
(void)param;
|
||||
uint32_t last_battery_ms = 0;
|
||||
|
||||
ESP_LOGI(TAG, "slave heartbeat task (interval %u ms)",
|
||||
(unsigned)ESPNOW_HEARTBEAT_INTERVAL_MS);
|
||||
@ -726,22 +868,43 @@ static void slave_heartbeat_task(void *param) {
|
||||
slave_check_master_timeout();
|
||||
|
||||
if (!s_slave_joined) {
|
||||
last_battery_ms = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
send_presence(s_master_mac, alox_EspNowMessageType_ESPNOW_HEARTBEAT);
|
||||
|
||||
uint32_t now = now_ms();
|
||||
if (last_battery_ms == 0 ||
|
||||
(now - last_battery_ms) >= ESPNOW_BATTERY_INTERVAL_MS) {
|
||||
slave_send_battery_report_to_master();
|
||||
last_battery_ms = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void master_monitor_task(void *param) {
|
||||
(void)param;
|
||||
uint32_t last_local_battery_ms = 0;
|
||||
|
||||
ESP_LOGI(TAG, "master monitor task (timeout %u ms)",
|
||||
(unsigned)ESPNOW_CLIENT_TIMEOUT_MS);
|
||||
|
||||
board_lipo_reading_t reading;
|
||||
board_input_read_lipo(&reading);
|
||||
client_registry_set_master_battery(&reading);
|
||||
last_local_battery_ms = now_ms();
|
||||
|
||||
while (1) {
|
||||
vTaskDelay(pdMS_TO_TICKS(ESPNOW_HEARTBEAT_INTERVAL_MS));
|
||||
client_registry_check_timeouts(ESPNOW_CLIENT_TIMEOUT_MS);
|
||||
|
||||
uint32_t t = now_ms();
|
||||
if (t - last_local_battery_ms >= ESPNOW_BATTERY_INTERVAL_MS) {
|
||||
board_input_read_lipo(&reading);
|
||||
client_registry_set_master_battery(&reading);
|
||||
last_local_battery_ms = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,6 +942,12 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
}
|
||||
handle_slave_accel_stream(info->src_addr, &msg.payload.accel_stream);
|
||||
break;
|
||||
case alox_EspNowMessage_battery_query_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
}
|
||||
handle_slave_battery_query(info->src_addr, &msg.payload.battery_query);
|
||||
break;
|
||||
case alox_EspNowMessage_led_ring_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
@ -838,6 +1007,17 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.which_payload == alox_EspNowMessage_battery_report_tag) {
|
||||
ensure_peer(info->src_addr);
|
||||
handle_master_battery_report(info->src_addr, &msg.payload.battery_report);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type == alox_EspNowMessageType_ESPNOW_BATTERY_REPORT &&
|
||||
msg.which_payload != alox_EspNowMessage_battery_report_tag) {
|
||||
ESP_LOGW(TAG, "master: BATTERY_REPORT type but which=%u", msg.which_payload);
|
||||
}
|
||||
|
||||
const alox_EspNowSlavePresence *presence = esp_now_proto_get_presence(&msg);
|
||||
if (presence != NULL) {
|
||||
/* Registry key is the ESP-NOW sender MAC, not the optional protobuf mac field. */
|
||||
@ -933,6 +1113,16 @@ esp_err_t esp_now_comm_init(const app_config_t *config) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
} else {
|
||||
s_slave_tx_queue = xQueueCreate(4, sizeof(slave_tx_op_t));
|
||||
if (s_slave_tx_queue == NULL) {
|
||||
ESP_LOGE(TAG, "failed to create slave tx queue");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
if (xTaskCreate(slave_tx_task, "espnow_stx", 4096, NULL, 5, NULL) !=
|
||||
pdPASS) {
|
||||
ESP_LOGE(TAG, "failed to create slave tx task");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (xTaskCreate(slave_heartbeat_task, "espnow_hb", 4096, NULL, 4, NULL) !=
|
||||
pdPASS) {
|
||||
ESP_LOGE(TAG, "failed to create heartbeat task");
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "app_config.h"
|
||||
#include "client_registry.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_now_messages.pb.h"
|
||||
#include "uart_messages.pb.h"
|
||||
|
||||
esp_err_t esp_now_comm_init(const app_config_t *config);
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "cmd_ota.h"
|
||||
#include "cmd_ota_slave_progress.h"
|
||||
#include "cmd_led_ring.h"
|
||||
#include "cmd_battery.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "powerpod.h"
|
||||
#include "driver/gpio.h"
|
||||
@ -163,6 +164,8 @@ void app_main(void) {
|
||||
ESP_LOGI(TAG, "Running Partition: %s (OTA slot %d)",
|
||||
app_config.running_partition, ota_slot);
|
||||
|
||||
board_input_init();
|
||||
|
||||
err = esp_now_comm_init(&app_config);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "ESP-NOW init failed: %s", esp_err_to_name(err));
|
||||
@ -170,8 +173,6 @@ void app_main(void) {
|
||||
|
||||
led_ring_init();
|
||||
|
||||
board_input_init();
|
||||
|
||||
if (app_config.master) {
|
||||
cmd_queue = xQueueCreate(64, sizeof(generic_msg_t));
|
||||
init_cmdHandler(cmd_queue);
|
||||
@ -185,6 +186,7 @@ void app_main(void) {
|
||||
cmd_espnow_find_me_register();
|
||||
cmd_restart_register();
|
||||
cmd_led_ring_register();
|
||||
cmd_battery_register();
|
||||
cmd_ota_register();
|
||||
cmd_ota_slave_progress_register();
|
||||
}
|
||||
|
||||
@ -30,6 +30,12 @@ PB_BIND(alox_EspNowAccelStream, alox_EspNowAccelStream, AUTO)
|
||||
PB_BIND(alox_EspNowAccelSample, alox_EspNowAccelSample, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowBatteryQuery, alox_EspNowBatteryQuery, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowBatteryReport, alox_EspNowBatteryReport, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowLedRing, alox_EspNowLedRing, AUTO)
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,9 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_RESTART = 11,
|
||||
alox_EspNowMessageType_ESPNOW_ACCEL_SAMPLE = 12,
|
||||
alox_EspNowMessageType_ESPNOW_SET_ACCEL_STREAM = 13,
|
||||
alox_EspNowMessageType_ESPNOW_LED_RING = 14
|
||||
alox_EspNowMessageType_ESPNOW_LED_RING = 14,
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_QUERY = 15,
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_REPORT = 16
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@ -76,6 +78,20 @@ typedef struct _alox_EspNowAccelSample {
|
||||
int32_t z;
|
||||
} alox_EspNowAccelSample;
|
||||
|
||||
/* * Master → slave: on-demand LiPo read (optional; slaves also push every ~30 s). */
|
||||
typedef struct _alox_EspNowBatteryQuery {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowBatteryQuery;
|
||||
|
||||
/* * Slave → master: LiPo voltages (periodic ~30 s and on query). */
|
||||
typedef struct _alox_EspNowBatteryReport {
|
||||
uint32_t client_id;
|
||||
bool lipo1_valid;
|
||||
bool lipo2_valid;
|
||||
uint32_t lipo1_mv;
|
||||
uint32_t lipo2_mv;
|
||||
} alox_EspNowBatteryReport;
|
||||
|
||||
/* * Master → slave: LED ring command (same modes as UART LedRingProgressRequest). */
|
||||
typedef struct _alox_EspNowLedRing {
|
||||
uint32_t client_id;
|
||||
@ -132,6 +148,8 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowAccelSample accel_sample;
|
||||
alox_EspNowAccelStream accel_stream;
|
||||
alox_EspNowLedRing led_ring;
|
||||
alox_EspNowBatteryQuery battery_query;
|
||||
alox_EspNowBatteryReport battery_report;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@ -142,8 +160,10 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_LED_RING
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_LED_RING+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_BATTERY_REPORT
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_BATTERY_REPORT+1))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -170,6 +190,8 @@ extern "C" {
|
||||
#define alox_EspNowAccelDeadzone_init_default {0, 0}
|
||||
#define alox_EspNowAccelStream_init_default {0, 0}
|
||||
#define alox_EspNowAccelSample_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowBatteryQuery_init_default {0}
|
||||
#define alox_EspNowBatteryReport_init_default {0, 0, 0, 0, 0}
|
||||
#define alox_EspNowLedRing_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_default {0}
|
||||
#define alox_EspNowOtaPayload_init_default {0, {0, {0}}}
|
||||
@ -184,6 +206,8 @@ extern "C" {
|
||||
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
|
||||
#define alox_EspNowAccelStream_init_zero {0, 0}
|
||||
#define alox_EspNowAccelSample_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowBatteryQuery_init_zero {0}
|
||||
#define alox_EspNowBatteryReport_init_zero {0, 0, 0, 0, 0}
|
||||
#define alox_EspNowLedRing_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_zero {0}
|
||||
#define alox_EspNowOtaPayload_init_zero {0, {0, {0}}}
|
||||
@ -210,6 +234,12 @@ extern "C" {
|
||||
#define alox_EspNowAccelSample_x_tag 2
|
||||
#define alox_EspNowAccelSample_y_tag 3
|
||||
#define alox_EspNowAccelSample_z_tag 4
|
||||
#define alox_EspNowBatteryQuery_client_id_tag 1
|
||||
#define alox_EspNowBatteryReport_client_id_tag 1
|
||||
#define alox_EspNowBatteryReport_lipo1_valid_tag 2
|
||||
#define alox_EspNowBatteryReport_lipo2_valid_tag 3
|
||||
#define alox_EspNowBatteryReport_lipo1_mv_tag 4
|
||||
#define alox_EspNowBatteryReport_lipo2_mv_tag 5
|
||||
#define alox_EspNowLedRing_client_id_tag 1
|
||||
#define alox_EspNowLedRing_mode_tag 2
|
||||
#define alox_EspNowLedRing_progress_tag 3
|
||||
@ -241,6 +271,8 @@ extern "C" {
|
||||
#define alox_EspNowMessage_accel_sample_tag 13
|
||||
#define alox_EspNowMessage_accel_stream_tag 14
|
||||
#define alox_EspNowMessage_led_ring_tag 15
|
||||
#define alox_EspNowMessage_battery_query_tag 16
|
||||
#define alox_EspNowMessage_battery_report_tag 17
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@ -293,6 +325,20 @@ X(a, STATIC, SINGULAR, SINT32, z, 4)
|
||||
#define alox_EspNowAccelSample_CALLBACK NULL
|
||||
#define alox_EspNowAccelSample_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowBatteryQuery_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowBatteryQuery_CALLBACK NULL
|
||||
#define alox_EspNowBatteryQuery_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowBatteryReport_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, lipo1_valid, 2) \
|
||||
X(a, STATIC, SINGULAR, BOOL, lipo2_valid, 3) \
|
||||
X(a, STATIC, SINGULAR, UINT32, lipo1_mv, 4) \
|
||||
X(a, STATIC, SINGULAR, UINT32, lipo2_mv, 5)
|
||||
#define alox_EspNowBatteryReport_CALLBACK NULL
|
||||
#define alox_EspNowBatteryReport_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowLedRing_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, mode, 2) \
|
||||
@ -345,7 +391,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_sample,payload.accel_sample), 13) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream,payload.accel_stream), 14) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring,payload.led_ring), 15)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring,payload.led_ring), 15) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_query,payload.battery_query), 16) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_report,payload.battery_report), 17)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@ -362,6 +410,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring,payload.led_ring), 15)
|
||||
#define alox_EspNowMessage_payload_accel_sample_MSGTYPE alox_EspNowAccelSample
|
||||
#define alox_EspNowMessage_payload_accel_stream_MSGTYPE alox_EspNowAccelStream
|
||||
#define alox_EspNowMessage_payload_led_ring_MSGTYPE alox_EspNowLedRing
|
||||
#define alox_EspNowMessage_payload_battery_query_MSGTYPE alox_EspNowBatteryQuery
|
||||
#define alox_EspNowMessage_payload_battery_report_MSGTYPE alox_EspNowBatteryReport
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
|
||||
@ -371,6 +421,8 @@ extern const pb_msgdesc_t alox_EspNowSlavePresence_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelDeadzone_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelStream_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelSample_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowBatteryQuery_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowBatteryReport_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowLedRing_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowOtaStart_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowOtaPayload_msg;
|
||||
@ -387,6 +439,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
|
||||
#define alox_EspNowAccelStream_fields &alox_EspNowAccelStream_msg
|
||||
#define alox_EspNowAccelSample_fields &alox_EspNowAccelSample_msg
|
||||
#define alox_EspNowBatteryQuery_fields &alox_EspNowBatteryQuery_msg
|
||||
#define alox_EspNowBatteryReport_fields &alox_EspNowBatteryReport_msg
|
||||
#define alox_EspNowLedRing_fields &alox_EspNowLedRing_msg
|
||||
#define alox_EspNowOtaStart_fields &alox_EspNowOtaStart_msg
|
||||
#define alox_EspNowOtaPayload_fields &alox_EspNowOtaPayload_msg
|
||||
@ -401,6 +455,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowAccelDeadzone_size 12
|
||||
#define alox_EspNowAccelSample_size 24
|
||||
#define alox_EspNowAccelStream_size 8
|
||||
#define alox_EspNowBatteryQuery_size 6
|
||||
#define alox_EspNowBatteryReport_size 22
|
||||
#define alox_EspNowDiscover_size 6
|
||||
#define alox_EspNowFindMe_size 6
|
||||
#define alox_EspNowLedRing_size 60
|
||||
|
||||
@ -20,6 +20,8 @@ enum EspNowMessageType {
|
||||
ESPNOW_ACCEL_SAMPLE = 12;
|
||||
ESPNOW_SET_ACCEL_STREAM = 13;
|
||||
ESPNOW_LED_RING = 14;
|
||||
ESPNOW_BATTERY_QUERY = 15;
|
||||
ESPNOW_BATTERY_REPORT = 16;
|
||||
}
|
||||
|
||||
message EspNowUnicastTest {
|
||||
@ -69,6 +71,20 @@ message EspNowAccelSample {
|
||||
sint32 z = 4;
|
||||
}
|
||||
|
||||
/** Master → slave: on-demand LiPo read (optional; slaves also push every ~30 s). */
|
||||
message EspNowBatteryQuery {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
/** Slave → master: LiPo voltages (periodic ~30 s and on query). */
|
||||
message EspNowBatteryReport {
|
||||
uint32 client_id = 1;
|
||||
bool lipo1_valid = 2;
|
||||
bool lipo2_valid = 3;
|
||||
uint32 lipo1_mv = 4;
|
||||
uint32 lipo2_mv = 5;
|
||||
}
|
||||
|
||||
/** Master → slave: LED ring command (same modes as UART LedRingProgressRequest). */
|
||||
message EspNowLedRing {
|
||||
uint32 client_id = 1;
|
||||
@ -121,5 +137,7 @@ message EspNowMessage {
|
||||
EspNowAccelSample accel_sample = 13;
|
||||
EspNowAccelStream accel_stream = 14;
|
||||
EspNowLedRing led_ring = 15;
|
||||
EspNowBatteryQuery battery_query = 16;
|
||||
EspNowBatteryReport battery_report = 17;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,18 @@ PB_BIND(alox_AccelStreamRequest, alox_AccelStreamRequest, AUTO)
|
||||
PB_BIND(alox_AccelStreamResponse, alox_AccelStreamResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_BatteryStatusRequest, alox_BatteryStatusRequest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_LipoReading, alox_LipoReading, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_BatterySample, alox_BatterySample, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_BatteryStatusResponse, alox_BatteryStatusResponse, 2)
|
||||
|
||||
|
||||
PB_BIND(alox_AccelSnapshotRequest, alox_AccelSnapshotRequest, AUTO)
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,8 @@ typedef enum _alox_MessageType {
|
||||
alox_MessageType_FIND_ME = 22,
|
||||
alox_MessageType_RESTART = 23,
|
||||
alox_MessageType_ACCEL_SNAPSHOT = 24,
|
||||
alox_MessageType_ACCEL_STREAM = 25
|
||||
alox_MessageType_ACCEL_STREAM = 25,
|
||||
alox_MessageType_BATTERY_STATUS = 26
|
||||
} alox_MessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@ -108,6 +109,36 @@ typedef struct _alox_AccelStreamResponse {
|
||||
uint32_t slaves_updated;
|
||||
} alox_AccelStreamResponse;
|
||||
|
||||
/* * Host → master: read LiPo ADC voltages (master local and/or slaves via ESP-NOW). */
|
||||
typedef struct _alox_BatteryStatusRequest {
|
||||
/* * 0 = master only; >0 = one slave; ignored when all_clients */
|
||||
uint32_t client_id;
|
||||
/* * Master (client_id 0) plus every registered slave */
|
||||
bool all_clients;
|
||||
} alox_BatteryStatusRequest;
|
||||
|
||||
typedef struct _alox_LipoReading {
|
||||
bool valid;
|
||||
/* * Estimated pack voltage in millivolts from ADC */
|
||||
uint32_t voltage_mv;
|
||||
} alox_LipoReading;
|
||||
|
||||
typedef struct _alox_BatterySample {
|
||||
uint32_t client_id;
|
||||
bool has_lipo1;
|
||||
alox_LipoReading lipo1;
|
||||
bool has_lipo2;
|
||||
alox_LipoReading lipo2;
|
||||
/* * Milliseconds since last ESP-NOW battery report from this pod. */
|
||||
uint32_t age_ms;
|
||||
} alox_BatterySample;
|
||||
|
||||
typedef struct _alox_BatteryStatusResponse {
|
||||
bool success;
|
||||
pb_size_t samples_count;
|
||||
alox_BatterySample samples[17];
|
||||
} alox_BatteryStatusResponse;
|
||||
|
||||
/* Host → master: read cached accel samples from slaves (only while stream enabled).
|
||||
client_id 0 = all registered slaves; otherwise one slave. */
|
||||
typedef struct _alox_AccelSnapshotRequest {
|
||||
@ -271,6 +302,8 @@ typedef struct _alox_UartMessage {
|
||||
alox_AccelSnapshotResponse accel_snapshot_response;
|
||||
alox_AccelStreamRequest accel_stream_request;
|
||||
alox_AccelStreamResponse accel_stream_response;
|
||||
alox_BatteryStatusRequest battery_status_request;
|
||||
alox_BatteryStatusResponse battery_status_response;
|
||||
} payload;
|
||||
} alox_UartMessage;
|
||||
|
||||
@ -281,8 +314,8 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
|
||||
#define _alox_MessageType_MAX alox_MessageType_ACCEL_STREAM
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_ACCEL_STREAM+1))
|
||||
#define _alox_MessageType_MAX alox_MessageType_BATTERY_STATUS
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_BATTERY_STATUS+1))
|
||||
|
||||
#define alox_UartMessage_type_ENUMTYPE alox_MessageType
|
||||
|
||||
@ -311,6 +344,10 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -329,6 +366,10 @@ extern "C" {
|
||||
#define alox_AccelDeadzoneResponse_init_default {0, 0, 0, 0}
|
||||
#define alox_AccelStreamRequest_init_default {0, 0, 0, 0}
|
||||
#define alox_AccelStreamResponse_init_default {0, 0, 0, 0}
|
||||
#define alox_BatteryStatusRequest_init_default {0, 0}
|
||||
#define alox_LipoReading_init_default {0, 0}
|
||||
#define alox_BatterySample_init_default {0, false, alox_LipoReading_init_default, false, alox_LipoReading_init_default, 0}
|
||||
#define alox_BatteryStatusResponse_init_default {0, 0, {alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default, alox_BatterySample_init_default}}
|
||||
#define alox_AccelSnapshotRequest_init_default {0}
|
||||
#define alox_AccelSample_init_default {0, 0, 0, 0, 0, 0}
|
||||
#define alox_AccelSnapshotResponse_init_default {0, {alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default}}
|
||||
@ -359,6 +400,10 @@ extern "C" {
|
||||
#define alox_AccelDeadzoneResponse_init_zero {0, 0, 0, 0}
|
||||
#define alox_AccelStreamRequest_init_zero {0, 0, 0, 0}
|
||||
#define alox_AccelStreamResponse_init_zero {0, 0, 0, 0}
|
||||
#define alox_BatteryStatusRequest_init_zero {0, 0}
|
||||
#define alox_LipoReading_init_zero {0, 0}
|
||||
#define alox_BatterySample_init_zero {0, false, alox_LipoReading_init_zero, false, alox_LipoReading_init_zero, 0}
|
||||
#define alox_BatteryStatusResponse_init_zero {0, 0, {alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero, alox_BatterySample_init_zero}}
|
||||
#define alox_AccelSnapshotRequest_init_zero {0}
|
||||
#define alox_AccelSample_init_zero {0, 0, 0, 0, 0, 0}
|
||||
#define alox_AccelSnapshotResponse_init_zero {0, {alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero}}
|
||||
@ -413,6 +458,16 @@ extern "C" {
|
||||
#define alox_AccelStreamResponse_client_id_tag 2
|
||||
#define alox_AccelStreamResponse_success_tag 3
|
||||
#define alox_AccelStreamResponse_slaves_updated_tag 4
|
||||
#define alox_BatteryStatusRequest_client_id_tag 1
|
||||
#define alox_BatteryStatusRequest_all_clients_tag 2
|
||||
#define alox_LipoReading_valid_tag 1
|
||||
#define alox_LipoReading_voltage_mv_tag 2
|
||||
#define alox_BatterySample_client_id_tag 1
|
||||
#define alox_BatterySample_lipo1_tag 2
|
||||
#define alox_BatterySample_lipo2_tag 3
|
||||
#define alox_BatterySample_age_ms_tag 4
|
||||
#define alox_BatteryStatusResponse_success_tag 1
|
||||
#define alox_BatteryStatusResponse_samples_tag 2
|
||||
#define alox_AccelSnapshotRequest_client_id_tag 1
|
||||
#define alox_AccelSample_client_id_tag 1
|
||||
#define alox_AccelSample_valid_tag 2
|
||||
@ -493,6 +548,8 @@ extern "C" {
|
||||
#define alox_UartMessage_accel_snapshot_response_tag 24
|
||||
#define alox_UartMessage_accel_stream_request_tag 25
|
||||
#define alox_UartMessage_accel_stream_response_tag 26
|
||||
#define alox_UartMessage_battery_status_request_tag 27
|
||||
#define alox_UartMessage_battery_status_response_tag 28
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_UartMessage_FIELDLIST(X, a) \
|
||||
@ -521,7 +578,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,restart_response,payload.restart_res
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_snapshot_request,payload.accel_snapshot_request), 23) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_snapshot_response,payload.accel_snapshot_response), 24) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_request,payload.accel_stream_request), 25) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_response,payload.accel_stream_response), 26)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_response,payload.accel_stream_response), 26) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_request,payload.battery_status_request), 27) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_response,payload.battery_status_response), 28)
|
||||
#define alox_UartMessage_CALLBACK NULL
|
||||
#define alox_UartMessage_DEFAULT NULL
|
||||
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
|
||||
@ -549,6 +608,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_response,payload.accel_
|
||||
#define alox_UartMessage_payload_accel_snapshot_response_MSGTYPE alox_AccelSnapshotResponse
|
||||
#define alox_UartMessage_payload_accel_stream_request_MSGTYPE alox_AccelStreamRequest
|
||||
#define alox_UartMessage_payload_accel_stream_response_MSGTYPE alox_AccelStreamResponse
|
||||
#define alox_UartMessage_payload_battery_status_request_MSGTYPE alox_BatteryStatusRequest
|
||||
#define alox_UartMessage_payload_battery_status_response_MSGTYPE alox_BatteryStatusResponse
|
||||
|
||||
#define alox_Ack_FIELDLIST(X, a) \
|
||||
|
||||
@ -631,6 +692,35 @@ X(a, STATIC, SINGULAR, UINT32, slaves_updated, 4)
|
||||
#define alox_AccelStreamResponse_CALLBACK NULL
|
||||
#define alox_AccelStreamResponse_DEFAULT NULL
|
||||
|
||||
#define alox_BatteryStatusRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, all_clients, 2)
|
||||
#define alox_BatteryStatusRequest_CALLBACK NULL
|
||||
#define alox_BatteryStatusRequest_DEFAULT NULL
|
||||
|
||||
#define alox_LipoReading_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, valid, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, voltage_mv, 2)
|
||||
#define alox_LipoReading_CALLBACK NULL
|
||||
#define alox_LipoReading_DEFAULT NULL
|
||||
|
||||
#define alox_BatterySample_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, lipo1, 2) \
|
||||
X(a, STATIC, OPTIONAL, MESSAGE, lipo2, 3) \
|
||||
X(a, STATIC, SINGULAR, UINT32, age_ms, 4)
|
||||
#define alox_BatterySample_CALLBACK NULL
|
||||
#define alox_BatterySample_DEFAULT NULL
|
||||
#define alox_BatterySample_lipo1_MSGTYPE alox_LipoReading
|
||||
#define alox_BatterySample_lipo2_MSGTYPE alox_LipoReading
|
||||
|
||||
#define alox_BatteryStatusResponse_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, success, 1) \
|
||||
X(a, STATIC, REPEATED, MESSAGE, samples, 2)
|
||||
#define alox_BatteryStatusResponse_CALLBACK NULL
|
||||
#define alox_BatteryStatusResponse_DEFAULT NULL
|
||||
#define alox_BatteryStatusResponse_samples_MSGTYPE alox_BatterySample
|
||||
|
||||
#define alox_AccelSnapshotRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_AccelSnapshotRequest_CALLBACK NULL
|
||||
@ -772,6 +862,10 @@ extern const pb_msgdesc_t alox_AccelDeadzoneRequest_msg;
|
||||
extern const pb_msgdesc_t alox_AccelDeadzoneResponse_msg;
|
||||
extern const pb_msgdesc_t alox_AccelStreamRequest_msg;
|
||||
extern const pb_msgdesc_t alox_AccelStreamResponse_msg;
|
||||
extern const pb_msgdesc_t alox_BatteryStatusRequest_msg;
|
||||
extern const pb_msgdesc_t alox_LipoReading_msg;
|
||||
extern const pb_msgdesc_t alox_BatterySample_msg;
|
||||
extern const pb_msgdesc_t alox_BatteryStatusResponse_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSnapshotRequest_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSample_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSnapshotResponse_msg;
|
||||
@ -804,6 +898,10 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_AccelDeadzoneResponse_fields &alox_AccelDeadzoneResponse_msg
|
||||
#define alox_AccelStreamRequest_fields &alox_AccelStreamRequest_msg
|
||||
#define alox_AccelStreamResponse_fields &alox_AccelStreamResponse_msg
|
||||
#define alox_BatteryStatusRequest_fields &alox_BatteryStatusRequest_msg
|
||||
#define alox_LipoReading_fields &alox_LipoReading_msg
|
||||
#define alox_BatterySample_fields &alox_BatterySample_msg
|
||||
#define alox_BatteryStatusResponse_fields &alox_BatteryStatusResponse_msg
|
||||
#define alox_AccelSnapshotRequest_fields &alox_AccelSnapshotRequest_msg
|
||||
#define alox_AccelSample_fields &alox_AccelSample_msg
|
||||
#define alox_AccelSnapshotResponse_fields &alox_AccelSnapshotResponse_msg
|
||||
@ -830,7 +928,7 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
/* alox_ClientInfo_size depends on runtime parameters */
|
||||
/* alox_ClientInfoResponse_size depends on runtime parameters */
|
||||
/* alox_ClientInputResponse_size depends on runtime parameters */
|
||||
#define ALOX_UART_MESSAGES_PB_H_MAX_SIZE alox_AccelSnapshotResponse_size
|
||||
#define ALOX_UART_MESSAGES_PB_H_MAX_SIZE alox_BatteryStatusResponse_size
|
||||
#define alox_AccelDeadzoneRequest_size 16
|
||||
#define alox_AccelDeadzoneResponse_size 20
|
||||
#define alox_AccelSample_size 32
|
||||
@ -839,6 +937,9 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_AccelStreamRequest_size 12
|
||||
#define alox_AccelStreamResponse_size 16
|
||||
#define alox_Ack_size 0
|
||||
#define alox_BatterySample_size 32
|
||||
#define alox_BatteryStatusRequest_size 8
|
||||
#define alox_BatteryStatusResponse_size 580
|
||||
#define alox_ClientInput_size 22
|
||||
#define alox_EspNowFindMeRequest_size 6
|
||||
#define alox_EspNowFindMeResponse_size 8
|
||||
@ -846,6 +947,7 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_EspNowUnicastTestResponse_size 8
|
||||
#define alox_LedRingProgressRequest_size 64
|
||||
#define alox_LedRingProgressResponse_size 32
|
||||
#define alox_LipoReading_size 8
|
||||
#define alox_OtaEndPayload_size 0
|
||||
#define alox_OtaPayload_size 209
|
||||
#define alox_OtaSlaveProgressEntry_size 30
|
||||
|
||||
@ -24,6 +24,7 @@ enum MessageType {
|
||||
RESTART = 23;
|
||||
ACCEL_SNAPSHOT = 24;
|
||||
ACCEL_STREAM = 25;
|
||||
BATTERY_STATUS = 26;
|
||||
}
|
||||
|
||||
message UartMessage {
|
||||
@ -54,6 +55,8 @@ message UartMessage {
|
||||
AccelSnapshotResponse accel_snapshot_response = 24;
|
||||
AccelStreamRequest accel_stream_request = 25;
|
||||
AccelStreamResponse accel_stream_response = 26;
|
||||
BatteryStatusRequest battery_status_request = 27;
|
||||
BatteryStatusResponse battery_status_response = 28;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +133,33 @@ message AccelStreamResponse {
|
||||
uint32 slaves_updated = 4;
|
||||
}
|
||||
|
||||
/** Host → master: read LiPo ADC voltages (master local and/or slaves via ESP-NOW). */
|
||||
message BatteryStatusRequest {
|
||||
/** 0 = master only; >0 = one slave; ignored when all_clients */
|
||||
uint32 client_id = 1;
|
||||
/** Master (client_id 0) plus every registered slave */
|
||||
bool all_clients = 2;
|
||||
}
|
||||
|
||||
message LipoReading {
|
||||
bool valid = 1;
|
||||
/** Estimated pack voltage in millivolts from ADC */
|
||||
uint32 voltage_mv = 2;
|
||||
}
|
||||
|
||||
message BatterySample {
|
||||
uint32 client_id = 1;
|
||||
LipoReading lipo1 = 2;
|
||||
LipoReading lipo2 = 3;
|
||||
/** Milliseconds since last ESP-NOW battery report from this pod. */
|
||||
uint32 age_ms = 4;
|
||||
}
|
||||
|
||||
message BatteryStatusResponse {
|
||||
bool success = 1;
|
||||
repeated BatterySample samples = 2 [(nanopb).max_count = 17];
|
||||
}
|
||||
|
||||
// Host → master: read cached accel samples from slaves (only while stream enabled).
|
||||
// client_id 0 = all registered slaves; otherwise one slave.
|
||||
message AccelSnapshotRequest {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user