Compare commits
3 Commits
2e88358c53
...
95d5a9747a
| Author | SHA1 | Date | |
|---|---|---|---|
| 95d5a9747a | |||
| a9e08107b4 | |||
| 5c3cf65bca |
@ -31,6 +31,7 @@ go run . -port /dev/ttyUSB0 clients
|
||||
| `ota-progress` | 21 | Query per-slave ESP-NOW OTA progress on the master (`-client N`, default all) |
|
||||
| `led-ring` | 8 | LED ring: `-mode clear\|progress\|digit\|blink\|find-me`, … |
|
||||
| `find-me` | 22 | Locate pod (`-client 0` master, `>0` slave via ESP-NOW) |
|
||||
| `restart` | 23 | Reboot master or slave (`-client 0` / `>0`) |
|
||||
|
||||
`clients` requires slaves to have responded to master discover broadcasts first.
|
||||
|
||||
@ -42,7 +43,9 @@ Bench **configs** (`testdata/configs/`) list network, MACs, and serial ports (`u
|
||||
|
||||
```bash
|
||||
go run . test -list-configs
|
||||
go run . test -list-scenarios
|
||||
go run . test -config example-lab -scenario smoke
|
||||
go run . test -config example-lab -scenario uart_cmds
|
||||
go run . test -config my-lab -scenario smoke -port /dev/ttyUSB1 -v
|
||||
```
|
||||
|
||||
@ -73,7 +76,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`, `POST /api/unicast-test`, `POST /api/find-me`, `POST /api/ota` (multipart field `firmware`, max 2 MiB).
|
||||
HTTP API (used by the web UI): `GET/POST /api/deadzone`, `POST /api/unicast-test`, `POST /api/find-me`, `POST /api/restart`, `POST /api/ota` (multipart field `firmware`, max 2 MiB).
|
||||
|
||||
| UI / API | Behaviour |
|
||||
|----------|-----------|
|
||||
|
||||
@ -50,6 +50,16 @@ type findMeAPIResponse struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type restartAPIRequest struct {
|
||||
ClientID uint32 `json:"client_id"`
|
||||
}
|
||||
|
||||
type restartAPIResponse struct {
|
||||
Success bool `json:"success"`
|
||||
ClientID uint32 `json:"client_id,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type otaAPIResponse struct {
|
||||
Success bool `json:"success"`
|
||||
BytesWritten uint32 `json:"bytes_written,omitempty"`
|
||||
@ -82,6 +92,13 @@ func mountServeAPI(mux *http.ServeMux, link *managedSerial, hub *wsHub) {
|
||||
}
|
||||
serveFindMe(w, r, link)
|
||||
})
|
||||
mux.HandleFunc("/api/restart", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
serveRestart(w, r, link)
|
||||
})
|
||||
mux.HandleFunc("/api/ota", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
@ -233,6 +250,22 @@ func applyDeadzoneToSlaves(link *managedSerial, deadzone uint32) (uint32, error)
|
||||
return updated, nil
|
||||
}
|
||||
|
||||
func serveRestart(w http.ResponseWriter, r *http.Request, link *managedSerial) {
|
||||
var body restartAPIRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
writeJSON(w, http.StatusBadRequest, restartAPIResponse{Error: "invalid JSON"})
|
||||
return
|
||||
}
|
||||
if err := link.Restart(body.ClientID); err != nil {
|
||||
writeJSON(w, http.StatusServiceUnavailable, restartAPIResponse{
|
||||
ClientID: body.ClientID,
|
||||
Error: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, restartAPIResponse{Success: true, ClientID: body.ClientID})
|
||||
}
|
||||
|
||||
func serveFindMe(w http.ResponseWriter, r *http.Request, link *managedSerial) {
|
||||
var body findMeAPIRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
|
||||
@ -15,6 +15,10 @@ type MasterClient interface {
|
||||
ListClients() ([]*pb.ClientInfo, error)
|
||||
AccelDeadzone(req *pb.AccelDeadzoneRequest) (*pb.AccelDeadzoneResponse, error)
|
||||
EspnowUnicastTest(clientID, seq uint32) (*pb.EspNowUnicastTestResponse, error)
|
||||
LedRing(req *pb.LedRingProgressRequest) (*pb.LedRingProgressResponse, error)
|
||||
FindMe(clientID uint32) (*pb.EspNowFindMeResponse, error)
|
||||
Restart(clientID uint32) (*pb.RestartResponse, error)
|
||||
OtaSlaveProgress(clientID uint32) (*pb.OtaSlaveProgressResponse, error)
|
||||
}
|
||||
|
||||
type StepResult struct {
|
||||
@ -92,6 +96,14 @@ func runStep(bench *Bench, step Step, client MasterClient) error {
|
||||
return checkDeadzone(bench, step, client)
|
||||
case "unicast_test", "unicast":
|
||||
return checkUnicastTest(bench, step, client)
|
||||
case "led_ring", "ledring":
|
||||
return checkLedRing(step, client)
|
||||
case "find_me", "findme":
|
||||
return checkFindMe(bench, step, client)
|
||||
case "restart":
|
||||
return checkRestartCmd(bench, step, client)
|
||||
case "ota_progress", "ota_slave_progress":
|
||||
return checkOtaProgress(step, client)
|
||||
case "reset", "reboot":
|
||||
return checkReset(bench, step)
|
||||
default:
|
||||
@ -310,3 +322,203 @@ func checkUnicastTest(bench *Bench, step Step, client MasterClient) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ledRingInput struct {
|
||||
Mode string `json:"mode"`
|
||||
Progress uint `json:"progress"`
|
||||
Digit uint `json:"digit"`
|
||||
R uint `json:"r"`
|
||||
G uint `json:"g"`
|
||||
B uint `json:"b"`
|
||||
Intensity uint `json:"intensity"`
|
||||
BlinkMs uint `json:"blink_ms"`
|
||||
BlinkCount uint `json:"blink_count"`
|
||||
}
|
||||
|
||||
func ledRingModeValue(mode string) (uint32, error) {
|
||||
switch strings.ToLower(strings.ReplaceAll(mode, "-", "_")) {
|
||||
case "clear", "":
|
||||
return 0, nil
|
||||
case "progress":
|
||||
return 1, nil
|
||||
case "digit":
|
||||
return 2, nil
|
||||
case "blink":
|
||||
return 3, nil
|
||||
case "find_me", "findme":
|
||||
return 4, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("unknown led_ring mode %q", mode)
|
||||
}
|
||||
}
|
||||
|
||||
func checkLedRing(step Step, client MasterClient) error {
|
||||
var in ledRingInput
|
||||
if len(step.Input) > 0 {
|
||||
if err := json.Unmarshal(step.Input, &in); err != nil {
|
||||
return fmt.Errorf("input: %w", err)
|
||||
}
|
||||
}
|
||||
mode, err := ledRingModeValue(in.Mode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if in.Mode == "" && step.Expect.Mode != nil {
|
||||
mode = *step.Expect.Mode
|
||||
}
|
||||
|
||||
req := &pb.LedRingProgressRequest{
|
||||
Mode: mode,
|
||||
Progress: uint32(in.Progress),
|
||||
Digit: uint32(in.Digit),
|
||||
R: uint32(in.R),
|
||||
G: uint32(in.G),
|
||||
B: uint32(in.B),
|
||||
Intensity: uint32(in.Intensity),
|
||||
BlinkMs: uint32(in.BlinkMs),
|
||||
BlinkCount: uint32(in.BlinkCount),
|
||||
}
|
||||
if mode == 1 && req.GetG() == 0 && req.GetR() == 0 && req.GetB() == 0 {
|
||||
req.G = 255
|
||||
}
|
||||
|
||||
resp, err := client.LedRing(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e := step.Expect
|
||||
if e.Success != nil && resp.GetSuccess() != *e.Success {
|
||||
return fmt.Errorf("success=%v want %v", resp.GetSuccess(), *e.Success)
|
||||
}
|
||||
if e.Mode != nil && resp.GetMode() != *e.Mode {
|
||||
return fmt.Errorf("mode=%d want %d", resp.GetMode(), *e.Mode)
|
||||
}
|
||||
if e.Progress != nil && resp.GetProgress() != *e.Progress {
|
||||
return fmt.Errorf("progress=%d want %d", resp.GetProgress(), *e.Progress)
|
||||
}
|
||||
if e.Digit != nil && resp.GetDigit() != *e.Digit {
|
||||
return fmt.Errorf("digit=%d want %d", resp.GetDigit(), *e.Digit)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type findMeInput struct {
|
||||
ClientID *uint `json:"client_id"`
|
||||
Client uint `json:"client"`
|
||||
Slave string `json:"slave"`
|
||||
}
|
||||
|
||||
func checkFindMe(bench *Bench, step Step, client MasterClient) error {
|
||||
var in findMeInput
|
||||
if len(step.Input) > 0 {
|
||||
if err := json.Unmarshal(step.Input, &in); err != nil {
|
||||
return fmt.Errorf("input: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
clientID, err := resolveClientID(bench, in.Slave, in.ClientID, in.Client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := client.FindMe(clientID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e := step.Expect
|
||||
if e.Success != nil && resp.GetSuccess() != *e.Success {
|
||||
return fmt.Errorf("success=%v want %v", resp.GetSuccess(), *e.Success)
|
||||
}
|
||||
if e.Slave != "" || in.Slave != "" {
|
||||
wantSlave := e.Slave
|
||||
if wantSlave == "" {
|
||||
wantSlave = in.Slave
|
||||
}
|
||||
wantID, err := bench.ResolveClientID(wantSlave)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.GetClientId() != wantID {
|
||||
return fmt.Errorf("client_id=%d want %d", resp.GetClientId(), wantID)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type restartCmdInput struct {
|
||||
ClientID *uint `json:"client_id"`
|
||||
Client uint `json:"client"`
|
||||
Slave string `json:"slave"`
|
||||
}
|
||||
|
||||
func checkRestartCmd(bench *Bench, step Step, client MasterClient) error {
|
||||
var in restartCmdInput
|
||||
if len(step.Input) > 0 {
|
||||
if err := json.Unmarshal(step.Input, &in); err != nil {
|
||||
return fmt.Errorf("input: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
clientID, err := resolveClientID(bench, in.Slave, in.ClientID, in.Client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := client.Restart(clientID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e := step.Expect
|
||||
if e.Success != nil && resp.GetSuccess() != *e.Success {
|
||||
return fmt.Errorf("success=%v want %v", resp.GetSuccess(), *e.Success)
|
||||
}
|
||||
if resp.GetClientId() != clientID {
|
||||
return fmt.Errorf("client_id=%d want %d", resp.GetClientId(), clientID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type otaProgressInput struct {
|
||||
ClientID *uint `json:"client_id"`
|
||||
Client uint `json:"client"`
|
||||
Slave string `json:"slave"`
|
||||
}
|
||||
|
||||
func checkOtaProgress(step Step, client MasterClient) error {
|
||||
var in otaProgressInput
|
||||
if len(step.Input) > 0 {
|
||||
if err := json.Unmarshal(step.Input, &in); err != nil {
|
||||
return fmt.Errorf("input: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
clientID := uint32(in.Client)
|
||||
if in.ClientID != nil {
|
||||
clientID = uint32(*in.ClientID)
|
||||
}
|
||||
|
||||
resp, err := client.OtaSlaveProgress(clientID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e := step.Expect
|
||||
if e.Active != nil && resp.GetActive() != *e.Active {
|
||||
return fmt.Errorf("active=%v want %v", resp.GetActive(), *e.Active)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func resolveClientID(bench *Bench, slave string, clientID *uint, client uint) (uint32, error) {
|
||||
switch {
|
||||
case slave != "":
|
||||
return bench.ResolveClientID(slave)
|
||||
case clientID != nil:
|
||||
return uint32(*clientID), nil
|
||||
default:
|
||||
return uint32(client), nil
|
||||
}
|
||||
}
|
||||
|
||||
25
goTool/autotest/runner_test.go
Normal file
25
goTool/autotest/runner_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
package autotest
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLedRingModeValue(t *testing.T) {
|
||||
tests := []struct {
|
||||
mode string
|
||||
want uint32
|
||||
}{
|
||||
{"clear", 0},
|
||||
{"progress", 1},
|
||||
{"digit", 2},
|
||||
{"blink", 3},
|
||||
{"find-me", 4},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
got, err := ledRingModeValue(tc.mode)
|
||||
if err != nil {
|
||||
t.Fatalf("mode %q: %v", tc.mode, err)
|
||||
}
|
||||
if got != tc.want {
|
||||
t.Fatalf("mode %q = %d want %d", tc.mode, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,6 +45,14 @@ type Expect struct {
|
||||
|
||||
// unicast_test
|
||||
Seq *uint32 `json:"seq,omitempty"`
|
||||
|
||||
// led_ring
|
||||
Mode *uint32 `json:"mode,omitempty"`
|
||||
Progress *uint32 `json:"progress,omitempty"`
|
||||
Digit *uint32 `json:"digit,omitempty"`
|
||||
|
||||
// ota_slave_progress
|
||||
Active *bool `json:"active,omitempty"`
|
||||
}
|
||||
|
||||
func LoadScenario(path string) (*Scenario, error) {
|
||||
|
||||
@ -178,6 +178,12 @@ func (m *managedSerial) FindMe(clientID uint32) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (m *managedSerial) Restart(clientID uint32) error {
|
||||
return m.withPort(func(sp *serialPort) error {
|
||||
return runRestartClient(sp, clientID)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *serialPort) ledRingProgress(req *pb.LedRingProgressRequest) (*pb.LedRingProgressResponse, error) {
|
||||
msg := &pb.UartMessage{
|
||||
Type: pb.MessageType_LED_RING,
|
||||
@ -216,3 +222,19 @@ func (s *serialPort) AccelDeadzone(req *pb.AccelDeadzoneRequest) (*pb.AccelDeadz
|
||||
func (s *serialPort) EspnowUnicastTest(clientID, seq uint32) (*pb.EspNowUnicastTestResponse, error) {
|
||||
return s.espnowUnicastTest(clientID, seq)
|
||||
}
|
||||
|
||||
func (s *serialPort) LedRing(req *pb.LedRingProgressRequest) (*pb.LedRingProgressResponse, error) {
|
||||
return s.ledRingProgress(req)
|
||||
}
|
||||
|
||||
func (s *serialPort) FindMe(clientID uint32) (*pb.EspNowFindMeResponse, error) {
|
||||
return s.espnowFindMe(clientID)
|
||||
}
|
||||
|
||||
func (s *serialPort) Restart(clientID uint32) (*pb.RestartResponse, error) {
|
||||
return s.restart(clientID)
|
||||
}
|
||||
|
||||
func (s *serialPort) OtaSlaveProgress(clientID uint32) (*pb.OtaSlaveProgressResponse, error) {
|
||||
return QueryOtaSlaveProgress(s, clientID)
|
||||
}
|
||||
|
||||
61
goTool/cmd_restart.go
Normal file
61
goTool/cmd_restart.go
Normal file
@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"powerpod/gotool/pb"
|
||||
)
|
||||
|
||||
func runRestart(sp *serialPort, args []string) error {
|
||||
fs := flag.NewFlagSet("restart", flag.ExitOnError)
|
||||
clientID := fs.Uint("client", 0, "0=master, >0=ESP-NOW unicast to slave id")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
return runRestartClient(sp, uint32(*clientID))
|
||||
}
|
||||
|
||||
func runRestartClient(sp *serialPort, clientID uint32) error {
|
||||
resp, err := sp.restart(clientID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !resp.GetSuccess() {
|
||||
return fmt.Errorf("restart rejected (client_id=%d)", resp.GetClientId())
|
||||
}
|
||||
if clientID == 0 {
|
||||
fmt.Println("restart scheduled on master")
|
||||
} else {
|
||||
fmt.Printf("restart sent to slave %d\n", clientID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *serialPort) restart(clientID uint32) (*pb.RestartResponse, error) {
|
||||
msg := &pb.UartMessage{
|
||||
Type: pb.MessageType_RESTART,
|
||||
Payload: &pb.UartMessage_RestartRequest{
|
||||
RestartRequest: &pb.RestartRequest{ClientId: clientID},
|
||||
},
|
||||
}
|
||||
body, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("encode: %w", err)
|
||||
}
|
||||
payload := append([]byte{byte(pb.MessageType_RESTART)}, body...)
|
||||
respPayload, err := s.exchangePayload(payload, "RESTART")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var respMsg pb.UartMessage
|
||||
if err := proto.Unmarshal(respPayload[1:], &respMsg); err != nil {
|
||||
return nil, fmt.Errorf("decode: %w", err)
|
||||
}
|
||||
r := respMsg.GetRestartResponse()
|
||||
if r == nil {
|
||||
return nil, fmt.Errorf("missing restart_response")
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
@ -22,7 +22,8 @@ func usage() {
|
||||
fmt.Fprintf(os.Stderr, " ota UART OTA upload (A/B partitions)\n")
|
||||
fmt.Fprintf(os.Stderr, " ota-progress query per-slave ESP-NOW OTA progress on master\n")
|
||||
fmt.Fprintf(os.Stderr, " led-ring set LED ring progress bar (0–100%%, rgb, intensity)\n")
|
||||
fmt.Fprintf(os.Stderr, " find-me blink LED ring red/green/blue (3× each, full brightness)\n\n")
|
||||
fmt.Fprintf(os.Stderr, " find-me blink LED ring red/green/blue (3× each, full brightness)\n")
|
||||
fmt.Fprintf(os.Stderr, " restart reboot master or slave (ESP-NOW)\n\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
@ -49,7 +50,7 @@ func main() {
|
||||
os.Exit(2)
|
||||
}
|
||||
runErr = runServe(*portName, *baud, flag.Args()[1:])
|
||||
case "version", "clients", "client-info", "deadzone", "accel-deadzone", "unicast-test", "unicast_test", "led-ring", "led_ring", "find-me", "find_me", "ota", "ota-progress", "ota_progress":
|
||||
case "version", "clients", "client-info", "deadzone", "accel-deadzone", "unicast-test", "unicast_test", "led-ring", "led_ring", "find-me", "find_me", "restart", "ota", "ota-progress", "ota_progress":
|
||||
if *portName == "" {
|
||||
fmt.Fprintf(os.Stderr, "command %q requires -port\n\n", cmd)
|
||||
usage()
|
||||
@ -73,6 +74,8 @@ func main() {
|
||||
runErr = runLedRing(sp, flag.Args()[1:])
|
||||
case "find-me", "find_me":
|
||||
runErr = runFindMe(sp, flag.Args()[1:])
|
||||
case "restart":
|
||||
runErr = runRestart(sp, flag.Args()[1:])
|
||||
case "ota":
|
||||
runErr = runOTA(sp, flag.Args()[1:])
|
||||
case "ota-progress", "ota_progress":
|
||||
|
||||
@ -40,6 +40,7 @@ const (
|
||||
MessageType_OTA_START_ESPNOW MessageType = 20
|
||||
MessageType_OTA_SLAVE_PROGRESS MessageType = 21
|
||||
MessageType_FIND_ME MessageType = 22
|
||||
MessageType_RESTART MessageType = 23
|
||||
)
|
||||
|
||||
// Enum value maps for MessageType.
|
||||
@ -61,6 +62,7 @@ var (
|
||||
20: "OTA_START_ESPNOW",
|
||||
21: "OTA_SLAVE_PROGRESS",
|
||||
22: "FIND_ME",
|
||||
23: "RESTART",
|
||||
}
|
||||
MessageType_value = map[string]int32{
|
||||
"UNKNOWN": 0,
|
||||
@ -79,6 +81,7 @@ var (
|
||||
"OTA_START_ESPNOW": 20,
|
||||
"OTA_SLAVE_PROGRESS": 21,
|
||||
"FIND_ME": 22,
|
||||
"RESTART": 23,
|
||||
}
|
||||
)
|
||||
|
||||
@ -133,6 +136,8 @@ type UartMessage struct {
|
||||
// *UartMessage_LedRingProgressResponse
|
||||
// *UartMessage_EspnowFindMeRequest
|
||||
// *UartMessage_EspnowFindMeResponse
|
||||
// *UartMessage_RestartRequest
|
||||
// *UartMessage_RestartResponse
|
||||
Payload isUartMessage_Payload `protobuf_oneof:"payload"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -353,6 +358,24 @@ func (x *UartMessage) GetEspnowFindMeResponse() *EspNowFindMeResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UartMessage) GetRestartRequest() *RestartRequest {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*UartMessage_RestartRequest); ok {
|
||||
return x.RestartRequest
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UartMessage) GetRestartResponse() *RestartResponse {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*UartMessage_RestartResponse); ok {
|
||||
return x.RestartResponse
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isUartMessage_Payload interface {
|
||||
isUartMessage_Payload()
|
||||
}
|
||||
@ -433,6 +456,14 @@ type UartMessage_EspnowFindMeResponse struct {
|
||||
EspnowFindMeResponse *EspNowFindMeResponse `protobuf:"bytes,20,opt,name=espnow_find_me_response,json=espnowFindMeResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type UartMessage_RestartRequest struct {
|
||||
RestartRequest *RestartRequest `protobuf:"bytes,21,opt,name=restart_request,json=restartRequest,proto3,oneof"`
|
||||
}
|
||||
|
||||
type UartMessage_RestartResponse struct {
|
||||
RestartResponse *RestartResponse `protobuf:"bytes,22,opt,name=restart_response,json=restartResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*UartMessage_AckPayload) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_EchoPayload) isUartMessage_Payload() {}
|
||||
@ -471,6 +502,10 @@ func (*UartMessage_EspnowFindMeRequest) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_EspnowFindMeResponse) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_RestartRequest) isUartMessage_Payload() {}
|
||||
|
||||
func (*UartMessage_RestartResponse) isUartMessage_Payload() {}
|
||||
|
||||
type Ack struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@ -1383,6 +1418,103 @@ func (x *EspNowFindMeResponse) GetClientId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// * Host → master: restart local node (client_id=0) or ESP-NOW unicast to one slave.
|
||||
type RestartRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ClientId uint32 `protobuf:"varint,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RestartRequest) Reset() {
|
||||
*x = RestartRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RestartRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RestartRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RestartRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
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 RestartRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RestartRequest) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{16}
|
||||
}
|
||||
|
||||
func (x *RestartRequest) GetClientId() uint32 {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RestartResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
ClientId uint32 `protobuf:"varint,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *RestartResponse) Reset() {
|
||||
*x = RestartResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *RestartResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RestartResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RestartResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
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 RestartResponse.ProtoReflect.Descriptor instead.
|
||||
func (*RestartResponse) Descriptor() ([]byte, []int) {
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{17}
|
||||
}
|
||||
|
||||
func (x *RestartResponse) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *RestartResponse) GetClientId() uint32 {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Host → device: begin UART OTA (erase inactive OTA slot; device replies OTA_STATUS).
|
||||
type OtaStartPayload struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -1393,7 +1525,7 @@ type OtaStartPayload struct {
|
||||
|
||||
func (x *OtaStartPayload) Reset() {
|
||||
*x = OtaStartPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1405,7 +1537,7 @@ func (x *OtaStartPayload) String() string {
|
||||
func (*OtaStartPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaStartPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[16]
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1418,7 +1550,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{16}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *OtaStartPayload) GetTotalSize() uint32 {
|
||||
@ -1439,7 +1571,7 @@ type OtaPayload struct {
|
||||
|
||||
func (x *OtaPayload) Reset() {
|
||||
*x = OtaPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1451,7 +1583,7 @@ func (x *OtaPayload) String() string {
|
||||
func (*OtaPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[17]
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1464,7 +1596,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{17}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{19}
|
||||
}
|
||||
|
||||
func (x *OtaPayload) GetSeq() uint32 {
|
||||
@ -1490,7 +1622,7 @@ type OtaEndPayload struct {
|
||||
|
||||
func (x *OtaEndPayload) Reset() {
|
||||
*x = OtaEndPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1502,7 +1634,7 @@ func (x *OtaEndPayload) String() string {
|
||||
func (*OtaEndPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaEndPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[18]
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1515,7 +1647,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{18}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
// Device → host status (also used as ACK after each 4 KiB written).
|
||||
@ -1532,7 +1664,7 @@ type OtaStatusPayload struct {
|
||||
|
||||
func (x *OtaStatusPayload) Reset() {
|
||||
*x = OtaStatusPayload{}
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1544,7 +1676,7 @@ func (x *OtaStatusPayload) String() string {
|
||||
func (*OtaStatusPayload) ProtoMessage() {}
|
||||
|
||||
func (x *OtaStatusPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[19]
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1557,7 +1689,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{19}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{21}
|
||||
}
|
||||
|
||||
func (x *OtaStatusPayload) GetStatus() uint32 {
|
||||
@ -1598,7 +1730,7 @@ type OtaSlaveProgressRequest struct {
|
||||
|
||||
func (x *OtaSlaveProgressRequest) Reset() {
|
||||
*x = OtaSlaveProgressRequest{}
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1610,7 +1742,7 @@ func (x *OtaSlaveProgressRequest) String() string {
|
||||
func (*OtaSlaveProgressRequest) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[20]
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1623,7 +1755,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{20}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{22}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressRequest) GetClientId() uint32 {
|
||||
@ -1647,7 +1779,7 @@ type OtaSlaveProgressEntry struct {
|
||||
|
||||
func (x *OtaSlaveProgressEntry) Reset() {
|
||||
*x = OtaSlaveProgressEntry{}
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1659,7 +1791,7 @@ func (x *OtaSlaveProgressEntry) String() string {
|
||||
func (*OtaSlaveProgressEntry) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressEntry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[21]
|
||||
mi := &file_uart_messages_proto_msgTypes[23]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1672,7 +1804,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{21}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{23}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressEntry) GetClientId() uint32 {
|
||||
@ -1723,7 +1855,7 @@ type OtaSlaveProgressResponse struct {
|
||||
|
||||
func (x *OtaSlaveProgressResponse) Reset() {
|
||||
*x = OtaSlaveProgressResponse{}
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1735,7 +1867,7 @@ func (x *OtaSlaveProgressResponse) String() string {
|
||||
func (*OtaSlaveProgressResponse) ProtoMessage() {}
|
||||
|
||||
func (x *OtaSlaveProgressResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_uart_messages_proto_msgTypes[22]
|
||||
mi := &file_uart_messages_proto_msgTypes[24]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1748,7 +1880,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{22}
|
||||
return file_uart_messages_proto_rawDescGZIP(), []int{24}
|
||||
}
|
||||
|
||||
func (x *OtaSlaveProgressResponse) GetActive() bool {
|
||||
@ -1790,7 +1922,7 @@ var File_uart_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_uart_messages_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\xeb\v\n" +
|
||||
"\x13uart_messages.proto\x12\x04alox\x1a\fnanopb.proto\"\xf0\f\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" +
|
||||
@ -1815,7 +1947,9 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"\x19led_ring_progress_request\x18\x11 \x01(\v2\x1c.alox.LedRingProgressRequestH\x00R\x16ledRingProgressRequest\x12\\\n" +
|
||||
"\x1aled_ring_progress_response\x18\x12 \x01(\v2\x1d.alox.LedRingProgressResponseH\x00R\x17ledRingProgressResponse\x12P\n" +
|
||||
"\x16espnow_find_me_request\x18\x13 \x01(\v2\x19.alox.EspNowFindMeRequestH\x00R\x13espnowFindMeRequest\x12S\n" +
|
||||
"\x17espnow_find_me_response\x18\x14 \x01(\v2\x1a.alox.EspNowFindMeResponseH\x00R\x14espnowFindMeResponseB\t\n" +
|
||||
"\x17espnow_find_me_response\x18\x14 \x01(\v2\x1a.alox.EspNowFindMeResponseH\x00R\x14espnowFindMeResponse\x12?\n" +
|
||||
"\x0frestart_request\x18\x15 \x01(\v2\x14.alox.RestartRequestH\x00R\x0erestartRequest\x12B\n" +
|
||||
"\x10restart_response\x18\x16 \x01(\v2\x15.alox.RestartResponseH\x00R\x0frestartResponseB\t\n" +
|
||||
"\apayload\"\x05\n" +
|
||||
"\x03Ack\"!\n" +
|
||||
"\vEchoPayload\x12\x12\n" +
|
||||
@ -1879,6 +2013,11 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"\tclient_id\x18\x01 \x01(\rR\bclientId\"M\n" +
|
||||
"\x14EspNowFindMeResponse\x12\x18\n" +
|
||||
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x1b\n" +
|
||||
"\tclient_id\x18\x02 \x01(\rR\bclientId\"-\n" +
|
||||
"\x0eRestartRequest\x12\x1b\n" +
|
||||
"\tclient_id\x18\x01 \x01(\rR\bclientId\"H\n" +
|
||||
"\x0fRestartResponse\x12\x18\n" +
|
||||
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x1b\n" +
|
||||
"\tclient_id\x18\x02 \x01(\rR\bclientId\"0\n" +
|
||||
"\x0fOtaStartPayload\x12\x1d\n" +
|
||||
"\n" +
|
||||
@ -1910,7 +2049,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*\x90\x02\n" +
|
||||
"\x06slaves\x18\x05 \x03(\v2\x1b.alox.OtaSlaveProgressEntryB\x05\x92?\x02\x10\x10R\x06slaves*\x9d\x02\n" +
|
||||
"\vMessageType\x12\v\n" +
|
||||
"\aUNKNOWN\x10\x00\x12\a\n" +
|
||||
"\x03ACK\x10\x01\x12\b\n" +
|
||||
@ -1928,7 +2067,8 @@ const file_uart_messages_proto_rawDesc = "" +
|
||||
"OTA_STATUS\x10\x13\x12\x14\n" +
|
||||
"\x10OTA_START_ESPNOW\x10\x14\x12\x16\n" +
|
||||
"\x12OTA_SLAVE_PROGRESS\x10\x15\x12\v\n" +
|
||||
"\aFIND_ME\x10\x16b\x06proto3"
|
||||
"\aFIND_ME\x10\x16\x12\v\n" +
|
||||
"\aRESTART\x10\x17b\x06proto3"
|
||||
|
||||
var (
|
||||
file_uart_messages_proto_rawDescOnce sync.Once
|
||||
@ -1943,7 +2083,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, 23)
|
||||
var file_uart_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 25)
|
||||
var file_uart_messages_proto_goTypes = []any{
|
||||
(MessageType)(0), // 0: alox.MessageType
|
||||
(*UartMessage)(nil), // 1: alox.UartMessage
|
||||
@ -1962,13 +2102,15 @@ var file_uart_messages_proto_goTypes = []any{
|
||||
(*LedRingProgressResponse)(nil), // 14: alox.LedRingProgressResponse
|
||||
(*EspNowFindMeRequest)(nil), // 15: alox.EspNowFindMeRequest
|
||||
(*EspNowFindMeResponse)(nil), // 16: alox.EspNowFindMeResponse
|
||||
(*OtaStartPayload)(nil), // 17: alox.OtaStartPayload
|
||||
(*OtaPayload)(nil), // 18: alox.OtaPayload
|
||||
(*OtaEndPayload)(nil), // 19: alox.OtaEndPayload
|
||||
(*OtaStatusPayload)(nil), // 20: alox.OtaStatusPayload
|
||||
(*OtaSlaveProgressRequest)(nil), // 21: alox.OtaSlaveProgressRequest
|
||||
(*OtaSlaveProgressEntry)(nil), // 22: alox.OtaSlaveProgressEntry
|
||||
(*OtaSlaveProgressResponse)(nil), // 23: alox.OtaSlaveProgressResponse
|
||||
(*RestartRequest)(nil), // 17: alox.RestartRequest
|
||||
(*RestartResponse)(nil), // 18: alox.RestartResponse
|
||||
(*OtaStartPayload)(nil), // 19: alox.OtaStartPayload
|
||||
(*OtaPayload)(nil), // 20: alox.OtaPayload
|
||||
(*OtaEndPayload)(nil), // 21: alox.OtaEndPayload
|
||||
(*OtaStatusPayload)(nil), // 22: alox.OtaStatusPayload
|
||||
(*OtaSlaveProgressRequest)(nil), // 23: alox.OtaSlaveProgressRequest
|
||||
(*OtaSlaveProgressEntry)(nil), // 24: alox.OtaSlaveProgressEntry
|
||||
(*OtaSlaveProgressResponse)(nil), // 25: alox.OtaSlaveProgressResponse
|
||||
}
|
||||
var file_uart_messages_proto_depIdxs = []int32{
|
||||
0, // 0: alox.UartMessage.type:type_name -> alox.MessageType
|
||||
@ -1977,28 +2119,30 @@ 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
|
||||
17, // 6: alox.UartMessage.ota_start:type_name -> alox.OtaStartPayload
|
||||
18, // 7: alox.UartMessage.ota_payload:type_name -> alox.OtaPayload
|
||||
19, // 8: alox.UartMessage.ota_end:type_name -> alox.OtaEndPayload
|
||||
20, // 9: alox.UartMessage.ota_status:type_name -> alox.OtaStatusPayload
|
||||
19, // 6: alox.UartMessage.ota_start:type_name -> alox.OtaStartPayload
|
||||
20, // 7: alox.UartMessage.ota_payload:type_name -> alox.OtaPayload
|
||||
21, // 8: alox.UartMessage.ota_end:type_name -> alox.OtaEndPayload
|
||||
22, // 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
|
||||
11, // 12: alox.UartMessage.espnow_unicast_test_request:type_name -> alox.EspNowUnicastTestRequest
|
||||
12, // 13: alox.UartMessage.espnow_unicast_test_response:type_name -> alox.EspNowUnicastTestResponse
|
||||
21, // 14: alox.UartMessage.ota_slave_progress_request:type_name -> alox.OtaSlaveProgressRequest
|
||||
23, // 15: alox.UartMessage.ota_slave_progress_response:type_name -> alox.OtaSlaveProgressResponse
|
||||
23, // 14: alox.UartMessage.ota_slave_progress_request:type_name -> alox.OtaSlaveProgressRequest
|
||||
25, // 15: alox.UartMessage.ota_slave_progress_response:type_name -> alox.OtaSlaveProgressResponse
|
||||
13, // 16: alox.UartMessage.led_ring_progress_request:type_name -> alox.LedRingProgressRequest
|
||||
14, // 17: alox.UartMessage.led_ring_progress_response:type_name -> alox.LedRingProgressResponse
|
||||
15, // 18: alox.UartMessage.espnow_find_me_request:type_name -> alox.EspNowFindMeRequest
|
||||
16, // 19: alox.UartMessage.espnow_find_me_response:type_name -> alox.EspNowFindMeResponse
|
||||
5, // 20: alox.ClientInfoResponse.clients:type_name -> alox.ClientInfo
|
||||
7, // 21: alox.ClientInputResponse.clients:type_name -> alox.ClientInput
|
||||
22, // 22: alox.OtaSlaveProgressResponse.slaves:type_name -> alox.OtaSlaveProgressEntry
|
||||
23, // [23:23] is the sub-list for method output_type
|
||||
23, // [23:23] is the sub-list for method input_type
|
||||
23, // [23:23] is the sub-list for extension type_name
|
||||
23, // [23:23] is the sub-list for extension extendee
|
||||
0, // [0:23] is the sub-list for field type_name
|
||||
17, // 20: alox.UartMessage.restart_request:type_name -> alox.RestartRequest
|
||||
18, // 21: alox.UartMessage.restart_response:type_name -> alox.RestartResponse
|
||||
5, // 22: alox.ClientInfoResponse.clients:type_name -> alox.ClientInfo
|
||||
7, // 23: alox.ClientInputResponse.clients:type_name -> alox.ClientInput
|
||||
24, // 24: alox.OtaSlaveProgressResponse.slaves:type_name -> alox.OtaSlaveProgressEntry
|
||||
25, // [25:25] is the sub-list for method output_type
|
||||
25, // [25:25] is the sub-list for method input_type
|
||||
25, // [25:25] is the sub-list for extension type_name
|
||||
25, // [25:25] is the sub-list for extension extendee
|
||||
0, // [0:25] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_uart_messages_proto_init() }
|
||||
@ -2026,6 +2170,8 @@ func file_uart_messages_proto_init() {
|
||||
(*UartMessage_LedRingProgressResponse)(nil),
|
||||
(*UartMessage_EspnowFindMeRequest)(nil),
|
||||
(*UartMessage_EspnowFindMeResponse)(nil),
|
||||
(*UartMessage_RestartRequest)(nil),
|
||||
(*UartMessage_RestartResponse)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -2033,7 +2179,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: 23,
|
||||
NumMessages: 25,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
21
goTool/testdata/README.md
vendored
21
goTool/testdata/README.md
vendored
@ -44,6 +44,19 @@ Ordered steps: UART commands, delays, or esptool reset.
|
||||
**unicast_test** — `input`: `slave` or `client_id`, `seq`
|
||||
`expect`: `success`, `seq`
|
||||
|
||||
**led_ring** — `input`: `mode` (`clear`, `progress`, `digit`, `blink`, `find_me`), `progress`, `digit`, `r`/`g`/`b`, `intensity`, `blink_ms`, `blink_count`
|
||||
`expect`: `success`, `mode`, `progress`, `digit`
|
||||
|
||||
**find_me** — `input`: `client` / `client_id` or `slave` (`0` = master ring)
|
||||
`expect`: `success`
|
||||
|
||||
**restart** — `input`: `client` / `client_id` or `slave` (prefer slave in tests so UART stays up)
|
||||
`expect`: `success`
|
||||
|
||||
**ota_progress** — query `OTA_SLAVE_PROGRESS` (no firmware upload)
|
||||
`input`: optional `client_id` / `slave`
|
||||
`expect`: `active` (typically `false` when idle)
|
||||
|
||||
**reset** — esptool hard-reset via console port from bench config (no `expect`).
|
||||
`input`: `target` (`master`) or `slave` (`pod-1`), or `all: true`; optional `wait_ms` after each reset (default 2000).
|
||||
|
||||
@ -56,13 +69,19 @@ Example reset steps:
|
||||
|
||||
Requires `python -m esptool` or `esptool.py` on PATH (ESP-IDF).
|
||||
|
||||
The `smoke` scenario resets every node with a configured `console` port, waits **10 s** for boot and ESP-NOW join, then runs the UART checks.
|
||||
The `smoke` scenario resets every node with a configured `console` port, waits **10 s** for boot and ESP-NOW join, then runs a short UART smoke test.
|
||||
|
||||
The **`uart_cmds`** scenario covers all implemented UART commands **except OTA upload** (`OTA_START` / `OTA_PAYLOAD` / `OTA_END` / `OTA_START_ESPNOW`). It ends with a slave **restart** (master UART stays connected).
|
||||
|
||||
`CLIENT_INPUT` is not tested (not implemented in firmware).
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
cd goTool
|
||||
go run . test -config example-lab -scenario smoke
|
||||
go run . test -config example-lab -scenario uart_cmds
|
||||
go run . test -config my-lab -scenario smoke -port /dev/ttyUSB1
|
||||
go run . test -list-configs
|
||||
go run . test -list-scenarios
|
||||
```
|
||||
|
||||
107
goTool/testdata/scenarios/uart_cmds.json
vendored
Normal file
107
goTool/testdata/scenarios/uart_cmds.json
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"id": "uart_cmds",
|
||||
"description": "All implemented UART commands (no OTA upload). Resets bench, joins ESP-NOW, exercises each cmd; restarts slave at end.",
|
||||
"config": "example-lab",
|
||||
"steps": [
|
||||
{
|
||||
"name": "reset all nodes",
|
||||
"command": "reset",
|
||||
"input": { "all": true, "wait_ms": 2500 }
|
||||
},
|
||||
{
|
||||
"name": "boot and ESP-NOW join",
|
||||
"delay_ms": 10000
|
||||
},
|
||||
{
|
||||
"name": "VERSION",
|
||||
"command": "version",
|
||||
"expect": { "version_min": 1 }
|
||||
},
|
||||
{
|
||||
"name": "CLIENT_INFO",
|
||||
"command": "clients",
|
||||
"expect": {
|
||||
"min_clients": 1,
|
||||
"slave": "pod-1",
|
||||
"available": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ACCEL_DEADZONE read master",
|
||||
"command": "deadzone",
|
||||
"input": { "write": false, "client": 0 },
|
||||
"expect": { "success": true }
|
||||
},
|
||||
{
|
||||
"name": "ACCEL_DEADZONE write master",
|
||||
"command": "deadzone",
|
||||
"input": { "write": true, "client": 0, "value": 120 },
|
||||
"expect": { "success": true, "deadzone": 120 }
|
||||
},
|
||||
{
|
||||
"name": "ACCEL_DEADZONE read master after write",
|
||||
"command": "deadzone",
|
||||
"input": { "write": false, "client": 0 },
|
||||
"expect": { "success": true, "deadzone": 120 }
|
||||
},
|
||||
{
|
||||
"name": "LED_RING clear",
|
||||
"command": "led_ring",
|
||||
"input": { "mode": "clear" },
|
||||
"expect": { "success": true, "mode": 0 }
|
||||
},
|
||||
{
|
||||
"name": "LED_RING progress",
|
||||
"command": "led_ring",
|
||||
"input": { "mode": "progress", "progress": 40, "g": 200 },
|
||||
"expect": { "success": true, "mode": 1, "progress": 40 }
|
||||
},
|
||||
{
|
||||
"name": "LED_RING digit",
|
||||
"command": "led_ring",
|
||||
"input": { "mode": "digit", "digit": 3, "r": 255 },
|
||||
"expect": { "success": true, "mode": 2, "digit": 3 }
|
||||
},
|
||||
{
|
||||
"name": "LED_RING blink",
|
||||
"command": "led_ring",
|
||||
"input": { "mode": "blink", "r": 0, "g": 255, "b": 0, "blink_count": 1 },
|
||||
"expect": { "success": true, "mode": 3 }
|
||||
},
|
||||
{
|
||||
"name": "ESPNOW_UNICAST_TEST",
|
||||
"command": "unicast_test",
|
||||
"input": { "slave": "pod-1", "seq": 99 },
|
||||
"expect": { "success": true, "seq": 99 }
|
||||
},
|
||||
{
|
||||
"name": "FIND_ME master",
|
||||
"command": "find_me",
|
||||
"input": { "client": 0 },
|
||||
"expect": { "success": true }
|
||||
},
|
||||
{
|
||||
"name": "FIND_ME slave",
|
||||
"command": "find_me",
|
||||
"input": { "slave": "pod-1" },
|
||||
"expect": { "success": true }
|
||||
},
|
||||
{
|
||||
"name": "ACCEL_DEADZONE push to slave",
|
||||
"command": "deadzone",
|
||||
"input": { "write": true, "slave": "pod-1", "value": 110 },
|
||||
"expect": { "success": true }
|
||||
},
|
||||
{
|
||||
"name": "OTA_SLAVE_PROGRESS idle",
|
||||
"command": "ota_progress",
|
||||
"expect": { "active": false }
|
||||
},
|
||||
{
|
||||
"name": "RESTART slave (last)",
|
||||
"command": "restart",
|
||||
"input": { "slave": "pod-1" },
|
||||
"expect": { "success": true }
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -233,6 +233,12 @@
|
||||
title="LED-Ring: Rot/Grün/Blau je 3×">
|
||||
Find me
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm"
|
||||
@click="restart(0)"
|
||||
:disabled="busy || !state.uart_connected"
|
||||
title="Master neu starten">
|
||||
Restart
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-muted small mt-2 mb-0" x-show="!state.uart_connected">
|
||||
UART nicht verbunden — Eingabe gesperrt.
|
||||
@ -312,6 +318,12 @@
|
||||
title="LED-Ring Find me (ESP-NOW)">
|
||||
Find me
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm"
|
||||
@click="restart(c.id)"
|
||||
:disabled="busy || !state.uart_connected || !c.available"
|
||||
title="Neustart per ESP-NOW">
|
||||
Restart
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -366,7 +378,11 @@
|
||||
x-text="ota.masterMessage || (ota.step === 'master' ? ota.message : '')"></p>
|
||||
</td>
|
||||
<td class="ota-restart-col text-end">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm">Restart</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm"
|
||||
@click="restart(0)"
|
||||
:disabled="busy || !state.uart_connected">
|
||||
Restart
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -399,7 +415,11 @@
|
||||
<p class="small text-muted mb-0" x-text="row.bytesLabel"></p>
|
||||
</td>
|
||||
<td class="ota-restart-col text-end">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm">Restart</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm"
|
||||
@click="restart(row.id)"
|
||||
:disabled="busy || !state.uart_connected">
|
||||
Restart
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
@ -739,6 +759,27 @@
|
||||
this.busy = false;
|
||||
}
|
||||
},
|
||||
async restart(clientId = 0) {
|
||||
this.busy = true;
|
||||
try {
|
||||
const r = await fetch('/api/restart', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ client_id: clientId })
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok || !data.success) {
|
||||
this.flash(data.error || 'Restart fehlgeschlagen', false);
|
||||
return;
|
||||
}
|
||||
const label = clientId === 0 ? 'Master' : `Slave ${clientId}`;
|
||||
this.flash(`Restart ausgelöst (${label})`, true);
|
||||
} catch (e) {
|
||||
this.flash(String(e), false);
|
||||
} finally {
|
||||
this.busy = false;
|
||||
}
|
||||
},
|
||||
async findMe(clientId = 0) {
|
||||
this.busy = true;
|
||||
try {
|
||||
|
||||
@ -20,6 +20,8 @@ idf_component_register(
|
||||
"cmd_accel_deadzone.c"
|
||||
"cmd_espnow_unicast_test.c"
|
||||
"cmd_espnow_find_me.c"
|
||||
"cmd_restart.c"
|
||||
"pod_reboot.c"
|
||||
"cmd_led_ring.c"
|
||||
"cmd_ota.c"
|
||||
"cmd_ota_slave_progress.c"
|
||||
@ -30,6 +32,7 @@ idf_component_register(
|
||||
"esp_now_proto.c"
|
||||
"bosch456.c"
|
||||
"board_input.c"
|
||||
"pod_settings.c"
|
||||
"proto/uart_messages.pb.c"
|
||||
"proto/esp_now_messages.pb.c"
|
||||
"proto/pb_encode.c"
|
||||
|
||||
@ -82,12 +82,14 @@ Powerpod uses the Bosch **BMA456H** (hearable) variant, not the generic `bma456w
|
||||
|
||||
**Accel logging:** Samples are printed only when any axis changes by more than the **deadzone** (raw LSB) since the last logged sample (default **100**). This is a **software** filter on top of the sensor; it does not change BMA456 hardware thresholds.
|
||||
|
||||
**Persistence:** The local deadzone is stored in the **`nvs`** partition (namespace `powerpod`, key `accel_dz`) via `pod_settings.c`. Each node (master or slave) keeps its own value across reboot. Loaded at boot after `init_bma456()`; saved when set locally (UART `client_id = 0`, `all_clients` on master, or ESP-NOW deadzone on a slave).
|
||||
|
||||
**Configuration paths:**
|
||||
|
||||
| Path | Effect |
|
||||
|------|--------|
|
||||
| UART `ACCEL_DEADZONE` with `client_id = 0` | `bma456_set_accel_deadzone()` on the local node |
|
||||
| ESP-NOW `SET_ACCEL_DEADZONE` | Same on a slave (no-op log path if sensor not installed) |
|
||||
| UART `ACCEL_DEADZONE` with `client_id = 0` | Set + save local deadzone |
|
||||
| ESP-NOW `SET_ACCEL_DEADZONE` | Set + save on the receiving slave |
|
||||
| `make gotool-deadzone-set DEADZONE=… CLIENT=0` | Host shortcut for local deadzone |
|
||||
|
||||
**Logs:** `[BMA456] ACC X=… Y=… Z=…` when deadzone exceeded; `[BMA456] tap: single|double|triple` on interrupt.
|
||||
@ -112,6 +114,7 @@ Schema: `proto/esp_now_messages.proto`. Encode/decode: `esp_now_proto.c`. The ES
|
||||
| `ESPNOW_SET_ACCEL_DEADZONE` | Master → slave | `EspNowAccelDeadzone` (`deadzone` LSB) |
|
||||
| `ESPNOW_UNICAST_TEST` | Master → slave | `EspNowUnicastTest` (`seq`) |
|
||||
| `ESPNOW_FIND_ME` | Master → slave | `EspNowFindMe` (`client_id` filter) — LED locate sequence |
|
||||
| `ESPNOW_RESTART` | Master → slave | `EspNowRestart` (`client_id` filter) — reboot slave |
|
||||
| `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` |
|
||||
@ -213,6 +216,7 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
|
||||
| 20 | `OTA_START_ESPNOW` | Implemented — re-distribute staged image to slaves only |
|
||||
| 21 | `OTA_SLAVE_PROGRESS` | Implemented (`cmd_ota_slave_progress.c`) — query per-slave ESP-NOW OTA progress |
|
||||
| 22 | `FIND_ME` | Implemented (`cmd_espnow_find_me.c`) — `client_id=0` local ring, `>0` ESP-NOW to slave |
|
||||
| 23 | `RESTART` | Implemented (`cmd_restart.c`) — `client_id=0` reboot master, `>0` ESP-NOW reboot slave |
|
||||
|
||||
Regenerate C code:
|
||||
|
||||
@ -329,6 +333,18 @@ go run . -port /dev/ttyUSB0 find-me
|
||||
go run . -port /dev/ttyUSB0 find-me -client 16
|
||||
```
|
||||
|
||||
### RESTART command
|
||||
|
||||
Reboot the master (`client_id=0`) or one slave via ESP-NOW (`client_id` = registry id). The device sends the UART response, then restarts after ~150 ms.
|
||||
|
||||
**Request:** framed `23` + `restart_request`
|
||||
**Response:** `restart_response` (`success`, `client_id`)
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 restart
|
||||
go run . -port /dev/ttyUSB0 restart -client 16
|
||||
```
|
||||
|
||||
### LED_RING command
|
||||
|
||||
Control the 95-LED ring from the host. The firmware **does not** animate digits locally; only UART updates the display.
|
||||
@ -440,6 +456,7 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
|
||||
| `client_registry.c/h` | Registered slave table |
|
||||
| `bosch456.c/h` | BMA456H I2C driver, accel poll, tap INT, deadzone filter |
|
||||
| `board_input.c/h` | Taster GPIO12, LiPo ADC on GPIO1 / GPIO12 |
|
||||
| `pod_settings.c/h` | NVS persistence (accel deadzone, …) |
|
||||
| `led_ring.c/h` | LED ring (digit display, progress bar) |
|
||||
| `cmd_led_ring.c` | UART `LED_RING` progress command |
|
||||
| `proto/uart_messages.proto` | UART protocol schema |
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "cmd_accel_deadzone.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "pod_settings.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[ACCEL_DZ]";
|
||||
@ -19,6 +20,14 @@ static void reply(uint32_t deadzone, uint32_t client_id, bool success,
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
static void apply_local_deadzone(uint32_t deadzone) {
|
||||
bma456_set_accel_deadzone(deadzone);
|
||||
if (pod_settings_save_accel_deadzone(deadzone) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "deadzone %lu applied but not saved to NVS",
|
||||
(unsigned long)deadzone);
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t push_deadzone_to_slave(const client_info_t *client,
|
||||
uint32_t deadzone) {
|
||||
if (client == NULL) {
|
||||
@ -67,7 +76,7 @@ static void handle_accel_deadzone(const uint8_t *data, size_t len) {
|
||||
}
|
||||
|
||||
if (bma456_is_ready()) {
|
||||
bma456_set_accel_deadzone(req.deadzone);
|
||||
apply_local_deadzone(req.deadzone);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "set deadzone %lu via unicast to %u/%u slaves",
|
||||
@ -77,7 +86,7 @@ static void handle_accel_deadzone(const uint8_t *data, size_t len) {
|
||||
}
|
||||
|
||||
if (req.client_id == 0) {
|
||||
bma456_set_accel_deadzone(req.deadzone);
|
||||
apply_local_deadzone(req.deadzone);
|
||||
ESP_LOGI(TAG, "set local deadzone %lu (no ESP-NOW; use -client or -all "
|
||||
"for slaves)",
|
||||
(unsigned long)req.deadzone);
|
||||
|
||||
@ -46,6 +46,8 @@ static const char *message_type_name(uint16_t id) {
|
||||
return "OTA_SLAVE_PROGRESS";
|
||||
case alox_MessageType_FIND_ME:
|
||||
return "FIND_ME";
|
||||
case alox_MessageType_RESTART:
|
||||
return "RESTART";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
63
main/cmd_restart.c
Normal file
63
main/cmd_restart.c
Normal file
@ -0,0 +1,63 @@
|
||||
#include "client_registry.h"
|
||||
#include "cmd_restart.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "pod_reboot.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[RESTART_CMD]";
|
||||
|
||||
static void reply(bool success, uint32_t client_id) {
|
||||
alox_UartMessage response;
|
||||
uart_cmd_init_response(&response, alox_MessageType_RESTART,
|
||||
alox_UartMessage_restart_response_tag);
|
||||
response.payload.restart_response.success = success;
|
||||
response.payload.restart_response.client_id = client_id;
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
static void handle_restart(const uint8_t *data, size_t len) {
|
||||
alox_UartMessage uart_msg;
|
||||
|
||||
if (uart_cmd_decode(data, len, &uart_msg) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "decode failed");
|
||||
reply(false, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
const alox_RestartRequest *req = UART_CMD_REQ(
|
||||
&uart_msg, alox_UartMessage_restart_request_tag, restart_request);
|
||||
if (req == NULL) {
|
||||
ESP_LOGW(TAG, "missing restart request");
|
||||
reply(false, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->client_id == 0) {
|
||||
ESP_LOGI(TAG, "restart master");
|
||||
reply(true, 0);
|
||||
pod_schedule_restart();
|
||||
return;
|
||||
}
|
||||
|
||||
const client_info_t *client = client_registry_find_by_id(req->client_id);
|
||||
if (client == NULL) {
|
||||
ESP_LOGW(TAG, "client id %lu not in registry",
|
||||
(unsigned long)req->client_id);
|
||||
reply(false, req->client_id);
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t err = esp_now_comm_send_restart(client->mac, req->client_id);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "restart sent to slave %lu", (unsigned long)req->client_id);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "restart to slave %lu failed: %s",
|
||||
(unsigned long)req->client_id, esp_err_to_name(err));
|
||||
}
|
||||
reply(err == ESP_OK, req->client_id);
|
||||
}
|
||||
|
||||
void cmd_restart_register(void) {
|
||||
uart_cmd_register(alox_MessageType_RESTART, handle_restart);
|
||||
}
|
||||
6
main/cmd_restart.h
Normal file
6
main/cmd_restart.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef CMD_RESTART_H
|
||||
#define CMD_RESTART_H
|
||||
|
||||
void cmd_restart_register(void);
|
||||
|
||||
#endif
|
||||
@ -3,6 +3,8 @@
|
||||
#include "esp_now_comm.h"
|
||||
#include "led_ring.h"
|
||||
#include "ota_espnow.h"
|
||||
#include "pod_reboot.h"
|
||||
#include "pod_settings.h"
|
||||
#include "esp_now_proto.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_event.h"
|
||||
@ -13,7 +15,6 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/idf_additions.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "ota_uart.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -182,6 +183,16 @@ 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_restart(const uint8_t *dest_mac, uint32_t client_id) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
|
||||
msg.type = alox_EspNowMessageType_ESPNOW_RESTART;
|
||||
msg.which_payload = alox_EspNowMessage_restart_tag;
|
||||
msg.payload.restart.client_id = client_id;
|
||||
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_ota_start(const uint8_t *dest_mac, uint32_t total_size) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
|
||||
@ -272,6 +283,25 @@ bool esp_now_comm_get_master_mac(uint8_t mac_out[CLIENT_MAC_LEN]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_comm_send_restart(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(mac, mac_str, sizeof(mac_str));
|
||||
esp_err_t err = send_restart(mac, client_id);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "unicast RESTART to %s client_id=%lu", mac_str,
|
||||
(unsigned long)client_id);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "unicast RESTART to %s failed: %s", mac_str,
|
||||
esp_err_to_name(err));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_comm_send_find_me(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
@ -360,6 +390,24 @@ static void handle_slave_unicast_test(const uint8_t *master_mac,
|
||||
mac_str, (unsigned long)test->seq, (int)s_slave_joined);
|
||||
}
|
||||
|
||||
static void handle_slave_restart(const uint8_t *master_mac,
|
||||
const alox_EspNowRestart *req) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
|
||||
if (req->client_id != 0 && req->client_id != my_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_slave_joined && !mac_equal(master_mac, s_master_mac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(master_mac, mac_str, sizeof(mac_str));
|
||||
ESP_LOGI(TAG, "RESTART from master %s (id=%lu)", mac_str, (unsigned long)my_id);
|
||||
pod_schedule_restart();
|
||||
}
|
||||
|
||||
static void handle_slave_find_me(const uint8_t *master_mac,
|
||||
const alox_EspNowFindMe *req) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
@ -399,6 +447,10 @@ static void handle_slave_accel_deadzone(const uint8_t *master_mac,
|
||||
bma456_is_ready() ? "ok" : "not installed");
|
||||
|
||||
bma456_set_accel_deadzone(cfg->deadzone);
|
||||
if (pod_settings_save_accel_deadzone(cfg->deadzone) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "slave deadzone %lu applied but not saved to NVS",
|
||||
(unsigned long)cfg->deadzone);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_client_presence(const alox_EspNowSlavePresence *presence,
|
||||
@ -546,6 +598,12 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
}
|
||||
handle_slave_find_me(info->src_addr, &msg.payload.find_me);
|
||||
break;
|
||||
case alox_EspNowMessage_restart_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
}
|
||||
handle_slave_restart(info->src_addr, &msg.payload.restart);
|
||||
break;
|
||||
case alox_EspNowMessage_ota_start_tag:
|
||||
case alox_EspNowMessage_ota_payload_tag:
|
||||
case alox_EspNowMessage_ota_end_tag:
|
||||
@ -607,17 +665,6 @@ static void master_discover_task(void *param) {
|
||||
}
|
||||
|
||||
static esp_err_t init_wifi_stack(uint8_t channel) {
|
||||
esp_err_t err;
|
||||
|
||||
err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
|
||||
@ -19,6 +19,10 @@ esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
esp_err_t esp_now_comm_send_find_me(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id);
|
||||
|
||||
/** Master: request reboot on one slave. */
|
||||
esp_err_t esp_now_comm_send_restart(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id);
|
||||
|
||||
/** Master → slave OTA (unicast). */
|
||||
esp_err_t esp_now_comm_send_ota_start(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t total_size);
|
||||
|
||||
23
main/pod_reboot.c
Normal file
23
main/pod_reboot.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include "pod_reboot.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
static const char *TAG = "[REBOOT]";
|
||||
|
||||
#define POD_RESTART_DELAY_MS 150
|
||||
|
||||
static void restart_task(void *param) {
|
||||
(void)param;
|
||||
vTaskDelay(pdMS_TO_TICKS(POD_RESTART_DELAY_MS));
|
||||
ESP_LOGI(TAG, "restarting");
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
void pod_schedule_restart(void) {
|
||||
if (xTaskCreate(restart_task, "pod_restart", 2048, NULL, 5, NULL) != pdPASS) {
|
||||
ESP_LOGE(TAG, "failed to create restart task");
|
||||
esp_restart();
|
||||
}
|
||||
}
|
||||
7
main/pod_reboot.h
Normal file
7
main/pod_reboot.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef POD_REBOOT_H
|
||||
#define POD_REBOOT_H
|
||||
|
||||
/** Reboot after a short delay (lets UART / ESP-NOW handlers finish). */
|
||||
void pod_schedule_restart(void);
|
||||
|
||||
#endif
|
||||
110
main/pod_settings.c
Normal file
110
main/pod_settings.c
Normal file
@ -0,0 +1,110 @@
|
||||
#include "pod_settings.h"
|
||||
#include "bosch456.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
static const char *TAG = "[SETTINGS]";
|
||||
static const char *NS = "powerpod";
|
||||
static const char *KEY_ACCEL_DZ = "accel_dz";
|
||||
|
||||
#define ACCEL_DEADZONE_MAX 4095u
|
||||
|
||||
static bool s_nvs_ready;
|
||||
|
||||
static esp_err_t ensure_nvs(void) {
|
||||
if (s_nvs_ready) {
|
||||
return ESP_OK;
|
||||
}
|
||||
return pod_settings_init();
|
||||
}
|
||||
|
||||
esp_err_t pod_settings_init(void) {
|
||||
if (s_nvs_ready) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_LOGW(TAG, "NVS erase and re-init");
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "nvs_flash_init failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
s_nvs_ready = true;
|
||||
ESP_LOGI(TAG, "NVS ready, accel deadzone %lu LSB (stored)",
|
||||
(unsigned long)pod_settings_load_accel_deadzone());
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint32_t pod_settings_load_accel_deadzone(void) {
|
||||
if (!s_nvs_ready) {
|
||||
return BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
}
|
||||
|
||||
nvs_handle_t handle;
|
||||
esp_err_t err = nvs_open(NS, NVS_READONLY, &handle);
|
||||
if (err != ESP_OK) {
|
||||
return BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
}
|
||||
|
||||
uint32_t value = BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
err = nvs_get_u32(handle, KEY_ACCEL_DZ, &value);
|
||||
nvs_close(handle);
|
||||
|
||||
if (err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
return BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "read accel_dz failed: %s", esp_err_to_name(err));
|
||||
return BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
}
|
||||
if (value > ACCEL_DEADZONE_MAX) {
|
||||
return BMA456_DEFAULT_ACCEL_DEADZONE;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
esp_err_t pod_settings_save_accel_deadzone(uint32_t deadzone_lsb) {
|
||||
if (deadzone_lsb > ACCEL_DEADZONE_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
esp_err_t err = ensure_nvs();
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
nvs_handle_t handle;
|
||||
err = nvs_open(NS, NVS_READWRITE, &handle);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "nvs_open failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
err = nvs_set_u32(handle, KEY_ACCEL_DZ, deadzone_lsb);
|
||||
if (err == ESP_OK) {
|
||||
err = nvs_commit(handle);
|
||||
}
|
||||
nvs_close(handle);
|
||||
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "save accel_dz failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "saved accel deadzone %lu LSB", (unsigned long)deadzone_lsb);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void pod_settings_apply_accel_deadzone(void) {
|
||||
uint32_t deadzone = pod_settings_load_accel_deadzone();
|
||||
if (bma456_is_ready()) {
|
||||
bma456_set_accel_deadzone(deadzone);
|
||||
}
|
||||
}
|
||||
19
main/pod_settings.h
Normal file
19
main/pod_settings.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef POD_SETTINGS_H
|
||||
#define POD_SETTINGS_H
|
||||
|
||||
#include "esp_err.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/** Initialize NVS (idempotent) and log stored settings. Call once early in app_main. */
|
||||
esp_err_t pod_settings_init(void);
|
||||
|
||||
/** Persist local accelerometer deadzone (LSB per axis). */
|
||||
esp_err_t pod_settings_save_accel_deadzone(uint32_t deadzone_lsb);
|
||||
|
||||
/** Load deadzone from NVS, or BMA456_DEFAULT_ACCEL_DEADZONE if unset. */
|
||||
uint32_t pod_settings_load_accel_deadzone(void);
|
||||
|
||||
/** Apply NVS deadzone to BMA456 when the sensor is present. */
|
||||
void pod_settings_apply_accel_deadzone(void);
|
||||
|
||||
#endif
|
||||
@ -3,6 +3,7 @@
|
||||
#include "cmd_accel_deadzone.h"
|
||||
#include "cmd_espnow_unicast_test.h"
|
||||
#include "cmd_espnow_find_me.h"
|
||||
#include "cmd_restart.h"
|
||||
#include "cmd_client_info.h"
|
||||
#include "cmd_version.h"
|
||||
#include "cmd_ota.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#include "board_input.h"
|
||||
#include "bosch456.h"
|
||||
#include "led_ring.h"
|
||||
#include "pod_settings.h"
|
||||
#include "uart.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@ -66,6 +68,10 @@ uint8_t reverse_high_nibble_lut(uint8_t n) {
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
if (pod_settings_init() != ESP_OK) {
|
||||
ESP_LOGW(TAG, "settings NVS init failed; using defaults");
|
||||
}
|
||||
|
||||
// Get Master Mode Pin
|
||||
gpio_reset_pin(DIP_MASTER);
|
||||
gpio_set_direction(DIP_MASTER, GPIO_MODE_INPUT);
|
||||
@ -125,6 +131,8 @@ void app_main(void) {
|
||||
esp_err_t bma_err = init_bma456(bus_handle);
|
||||
if (bma_err != ESP_OK) {
|
||||
ESP_LOGI(TAG, "BMA456 init skipped: %s", esp_err_to_name(bma_err));
|
||||
} else {
|
||||
pod_settings_apply_accel_deadzone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +179,7 @@ void app_main(void) {
|
||||
cmd_accel_deadzone_register();
|
||||
cmd_espnow_unicast_test_register();
|
||||
cmd_espnow_find_me_register();
|
||||
cmd_restart_register();
|
||||
cmd_led_ring_register();
|
||||
cmd_ota_register();
|
||||
cmd_ota_slave_progress_register();
|
||||
|
||||
@ -12,6 +12,9 @@ PB_BIND(alox_EspNowUnicastTest, alox_EspNowUnicastTest, AUTO)
|
||||
PB_BIND(alox_EspNowFindMe, alox_EspNowFindMe, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowRestart, alox_EspNowRestart, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowDiscover, alox_EspNowDiscover, AUTO)
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,8 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_OTA_PAYLOAD = 7,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_END = 8,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_STATUS = 9,
|
||||
alox_EspNowMessageType_ESPNOW_FIND_ME = 10
|
||||
alox_EspNowMessageType_ESPNOW_FIND_ME = 10,
|
||||
alox_EspNowMessageType_ESPNOW_RESTART = 11
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@ -35,6 +36,11 @@ typedef struct _alox_EspNowFindMe {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowFindMe;
|
||||
|
||||
/* * Master → slave: reboot after short delay. */
|
||||
typedef struct _alox_EspNowRestart {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowRestart;
|
||||
|
||||
typedef struct _alox_EspNowDiscover {
|
||||
uint32_t network;
|
||||
} alox_EspNowDiscover;
|
||||
@ -91,6 +97,7 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowOtaEnd ota_end;
|
||||
alox_EspNowOtaStatus ota_status;
|
||||
alox_EspNowFindMe find_me;
|
||||
alox_EspNowRestart restart;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@ -101,8 +108,9 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_FIND_ME
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_FIND_ME+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_RESTART
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_RESTART+1))
|
||||
|
||||
|
||||
|
||||
|
||||
@ -119,6 +127,7 @@ extern "C" {
|
||||
/* Initializer values for message structs */
|
||||
#define alox_EspNowUnicastTest_init_default {0}
|
||||
#define alox_EspNowFindMe_init_default {0}
|
||||
#define alox_EspNowRestart_init_default {0}
|
||||
#define alox_EspNowDiscover_init_default {0}
|
||||
#define alox_EspNowSlavePresence_init_default {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_default {0, 0}
|
||||
@ -129,6 +138,7 @@ extern "C" {
|
||||
#define alox_EspNowMessage_init_default {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_default}}
|
||||
#define alox_EspNowUnicastTest_init_zero {0}
|
||||
#define alox_EspNowFindMe_init_zero {0}
|
||||
#define alox_EspNowRestart_init_zero {0}
|
||||
#define alox_EspNowDiscover_init_zero {0}
|
||||
#define alox_EspNowSlavePresence_init_zero {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
|
||||
@ -141,6 +151,7 @@ extern "C" {
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define alox_EspNowUnicastTest_seq_tag 1
|
||||
#define alox_EspNowFindMe_client_id_tag 1
|
||||
#define alox_EspNowRestart_client_id_tag 1
|
||||
#define alox_EspNowDiscover_network_tag 1
|
||||
#define alox_EspNowSlavePresence_network_tag 1
|
||||
#define alox_EspNowSlavePresence_mac_tag 2
|
||||
@ -167,6 +178,7 @@ extern "C" {
|
||||
#define alox_EspNowMessage_ota_end_tag 9
|
||||
#define alox_EspNowMessage_ota_status_tag 10
|
||||
#define alox_EspNowMessage_find_me_tag 11
|
||||
#define alox_EspNowMessage_restart_tag 12
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@ -179,6 +191,11 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowFindMe_CALLBACK NULL
|
||||
#define alox_EspNowFindMe_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowRestart_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowRestart_CALLBACK NULL
|
||||
#define alox_EspNowRestart_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowDiscover_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, network, 1)
|
||||
#define alox_EspNowDiscover_CALLBACK NULL
|
||||
@ -234,7 +251,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_start,payload.ota_start), 7) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_payload,payload.ota_payload), 8) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_end,payload.ota_end), 9) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@ -247,9 +265,11 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11)
|
||||
#define alox_EspNowMessage_payload_ota_end_MSGTYPE alox_EspNowOtaEnd
|
||||
#define alox_EspNowMessage_payload_ota_status_MSGTYPE alox_EspNowOtaStatus
|
||||
#define alox_EspNowMessage_payload_find_me_MSGTYPE alox_EspNowFindMe
|
||||
#define alox_EspNowMessage_payload_restart_MSGTYPE alox_EspNowRestart
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowRestart_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowDiscover_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowSlavePresence_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelDeadzone_msg;
|
||||
@ -262,6 +282,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||
#define alox_EspNowUnicastTest_fields &alox_EspNowUnicastTest_msg
|
||||
#define alox_EspNowFindMe_fields &alox_EspNowFindMe_msg
|
||||
#define alox_EspNowRestart_fields &alox_EspNowRestart_msg
|
||||
#define alox_EspNowDiscover_fields &alox_EspNowDiscover_msg
|
||||
#define alox_EspNowSlavePresence_fields &alox_EspNowSlavePresence_msg
|
||||
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
|
||||
@ -282,6 +303,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowOtaPayload_size 209
|
||||
#define alox_EspNowOtaStart_size 6
|
||||
#define alox_EspNowOtaStatus_size 18
|
||||
#define alox_EspNowRestart_size 6
|
||||
#define alox_EspNowUnicastTest_size 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -16,6 +16,7 @@ enum EspNowMessageType {
|
||||
ESPNOW_OTA_END = 8;
|
||||
ESPNOW_OTA_STATUS = 9;
|
||||
ESPNOW_FIND_ME = 10;
|
||||
ESPNOW_RESTART = 11;
|
||||
}
|
||||
|
||||
message EspNowUnicastTest {
|
||||
@ -28,6 +29,11 @@ message EspNowFindMe {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
/** Master → slave: reboot after short delay. */
|
||||
message EspNowRestart {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
message EspNowDiscover {
|
||||
uint32 network = 1;
|
||||
}
|
||||
@ -80,5 +86,6 @@ message EspNowMessage {
|
||||
EspNowOtaEnd ota_end = 9;
|
||||
EspNowOtaStatus ota_status = 10;
|
||||
EspNowFindMe find_me = 11;
|
||||
EspNowRestart restart = 12;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,12 @@ PB_BIND(alox_EspNowFindMeRequest, alox_EspNowFindMeRequest, AUTO)
|
||||
PB_BIND(alox_EspNowFindMeResponse, alox_EspNowFindMeResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_RestartRequest, alox_RestartRequest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_RestartResponse, alox_RestartResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_OtaStartPayload, alox_OtaStartPayload, AUTO)
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,8 @@ typedef enum _alox_MessageType {
|
||||
alox_MessageType_OTA_STATUS = 19,
|
||||
alox_MessageType_OTA_START_ESPNOW = 20,
|
||||
alox_MessageType_OTA_SLAVE_PROGRESS = 21,
|
||||
alox_MessageType_FIND_ME = 22
|
||||
alox_MessageType_FIND_ME = 22,
|
||||
alox_MessageType_RESTART = 23
|
||||
} alox_MessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@ -133,6 +134,16 @@ typedef struct _alox_EspNowFindMeResponse {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowFindMeResponse;
|
||||
|
||||
/* * Host → master: restart local node (client_id=0) or ESP-NOW unicast to one slave. */
|
||||
typedef struct _alox_RestartRequest {
|
||||
uint32_t client_id;
|
||||
} alox_RestartRequest;
|
||||
|
||||
typedef struct _alox_RestartResponse {
|
||||
bool success;
|
||||
uint32_t client_id;
|
||||
} alox_RestartResponse;
|
||||
|
||||
/* Host → device: begin UART OTA (erase inactive OTA slot; device replies OTA_STATUS). */
|
||||
typedef struct _alox_OtaStartPayload {
|
||||
uint32_t total_size;
|
||||
@ -205,6 +216,8 @@ typedef struct _alox_UartMessage {
|
||||
alox_LedRingProgressResponse led_ring_progress_response;
|
||||
alox_EspNowFindMeRequest espnow_find_me_request;
|
||||
alox_EspNowFindMeResponse espnow_find_me_response;
|
||||
alox_RestartRequest restart_request;
|
||||
alox_RestartResponse restart_response;
|
||||
} payload;
|
||||
} alox_UartMessage;
|
||||
|
||||
@ -215,8 +228,8 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
|
||||
#define _alox_MessageType_MAX alox_MessageType_FIND_ME
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_FIND_ME+1))
|
||||
#define _alox_MessageType_MAX alox_MessageType_RESTART
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_RESTART+1))
|
||||
|
||||
#define alox_UartMessage_type_ENUMTYPE alox_MessageType
|
||||
|
||||
@ -240,6 +253,8 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -260,6 +275,8 @@ extern "C" {
|
||||
#define alox_LedRingProgressResponse_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowFindMeRequest_init_default {0}
|
||||
#define alox_EspNowFindMeResponse_init_default {0, 0}
|
||||
#define alox_RestartRequest_init_default {0}
|
||||
#define alox_RestartResponse_init_default {0, 0}
|
||||
#define alox_OtaStartPayload_init_default {0}
|
||||
#define alox_OtaPayload_init_default {0, {0, {0}}}
|
||||
#define alox_OtaEndPayload_init_default {0}
|
||||
@ -283,6 +300,8 @@ extern "C" {
|
||||
#define alox_LedRingProgressResponse_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowFindMeRequest_init_zero {0}
|
||||
#define alox_EspNowFindMeResponse_init_zero {0, 0}
|
||||
#define alox_RestartRequest_init_zero {0}
|
||||
#define alox_RestartResponse_init_zero {0, 0}
|
||||
#define alox_OtaStartPayload_init_zero {0}
|
||||
#define alox_OtaPayload_init_zero {0, {0, {0}}}
|
||||
#define alox_OtaEndPayload_init_zero {0}
|
||||
@ -337,6 +356,9 @@ extern "C" {
|
||||
#define alox_EspNowFindMeRequest_client_id_tag 1
|
||||
#define alox_EspNowFindMeResponse_success_tag 1
|
||||
#define alox_EspNowFindMeResponse_client_id_tag 2
|
||||
#define alox_RestartRequest_client_id_tag 1
|
||||
#define alox_RestartResponse_success_tag 1
|
||||
#define alox_RestartResponse_client_id_tag 2
|
||||
#define alox_OtaStartPayload_total_size_tag 1
|
||||
#define alox_OtaPayload_seq_tag 1
|
||||
#define alox_OtaPayload_data_tag 2
|
||||
@ -375,6 +397,8 @@ extern "C" {
|
||||
#define alox_UartMessage_led_ring_progress_response_tag 18
|
||||
#define alox_UartMessage_espnow_find_me_request_tag 19
|
||||
#define alox_UartMessage_espnow_find_me_response_tag 20
|
||||
#define alox_UartMessage_restart_request_tag 21
|
||||
#define alox_UartMessage_restart_response_tag 22
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_UartMessage_FIELDLIST(X, a) \
|
||||
@ -397,7 +421,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_slave_progress_response,payload.
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_request,payload.led_ring_progress_request), 17) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_response,payload.led_ring_progress_response), 18) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_request,payload.espnow_find_me_request), 19) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_response,payload.espnow_find_me_response), 20)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_response,payload.espnow_find_me_response), 20) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart_request,payload.restart_request), 21) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart_response,payload.restart_response), 22)
|
||||
#define alox_UartMessage_CALLBACK NULL
|
||||
#define alox_UartMessage_DEFAULT NULL
|
||||
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
|
||||
@ -419,6 +445,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_response,payload.espn
|
||||
#define alox_UartMessage_payload_led_ring_progress_response_MSGTYPE alox_LedRingProgressResponse
|
||||
#define alox_UartMessage_payload_espnow_find_me_request_MSGTYPE alox_EspNowFindMeRequest
|
||||
#define alox_UartMessage_payload_espnow_find_me_response_MSGTYPE alox_EspNowFindMeResponse
|
||||
#define alox_UartMessage_payload_restart_request_MSGTYPE alox_RestartRequest
|
||||
#define alox_UartMessage_payload_restart_response_MSGTYPE alox_RestartResponse
|
||||
|
||||
#define alox_Ack_FIELDLIST(X, a) \
|
||||
|
||||
@ -528,6 +556,17 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 2)
|
||||
#define alox_EspNowFindMeResponse_CALLBACK NULL
|
||||
#define alox_EspNowFindMeResponse_DEFAULT NULL
|
||||
|
||||
#define alox_RestartRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_RestartRequest_CALLBACK NULL
|
||||
#define alox_RestartRequest_DEFAULT NULL
|
||||
|
||||
#define alox_RestartResponse_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, success, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 2)
|
||||
#define alox_RestartResponse_CALLBACK NULL
|
||||
#define alox_RestartResponse_DEFAULT NULL
|
||||
|
||||
#define alox_OtaStartPayload_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, total_size, 1)
|
||||
#define alox_OtaStartPayload_CALLBACK NULL
|
||||
@ -592,6 +631,8 @@ extern const pb_msgdesc_t alox_LedRingProgressRequest_msg;
|
||||
extern const pb_msgdesc_t alox_LedRingProgressResponse_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMeRequest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMeResponse_msg;
|
||||
extern const pb_msgdesc_t alox_RestartRequest_msg;
|
||||
extern const pb_msgdesc_t alox_RestartResponse_msg;
|
||||
extern const pb_msgdesc_t alox_OtaStartPayload_msg;
|
||||
extern const pb_msgdesc_t alox_OtaPayload_msg;
|
||||
extern const pb_msgdesc_t alox_OtaEndPayload_msg;
|
||||
@ -617,6 +658,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_LedRingProgressResponse_fields &alox_LedRingProgressResponse_msg
|
||||
#define alox_EspNowFindMeRequest_fields &alox_EspNowFindMeRequest_msg
|
||||
#define alox_EspNowFindMeResponse_fields &alox_EspNowFindMeResponse_msg
|
||||
#define alox_RestartRequest_fields &alox_RestartRequest_msg
|
||||
#define alox_RestartResponse_fields &alox_RestartResponse_msg
|
||||
#define alox_OtaStartPayload_fields &alox_OtaStartPayload_msg
|
||||
#define alox_OtaPayload_fields &alox_OtaPayload_msg
|
||||
#define alox_OtaEndPayload_fields &alox_OtaEndPayload_msg
|
||||
@ -650,6 +693,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_OtaSlaveProgressResponse_size 532
|
||||
#define alox_OtaStartPayload_size 6
|
||||
#define alox_OtaStatusPayload_size 24
|
||||
#define alox_RestartRequest_size 6
|
||||
#define alox_RestartResponse_size 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@ -21,6 +21,7 @@ enum MessageType {
|
||||
OTA_START_ESPNOW = 20;
|
||||
OTA_SLAVE_PROGRESS = 21;
|
||||
FIND_ME = 22;
|
||||
RESTART = 23;
|
||||
}
|
||||
|
||||
message UartMessage {
|
||||
@ -45,6 +46,8 @@ message UartMessage {
|
||||
LedRingProgressResponse led_ring_progress_response = 18;
|
||||
EspNowFindMeRequest espnow_find_me_request = 19;
|
||||
EspNowFindMeResponse espnow_find_me_response = 20;
|
||||
RestartRequest restart_request = 21;
|
||||
RestartResponse restart_response = 22;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,6 +152,16 @@ message EspNowFindMeResponse {
|
||||
uint32 client_id = 2;
|
||||
}
|
||||
|
||||
/** Host → master: restart local node (client_id=0) or ESP-NOW unicast to one slave. */
|
||||
message RestartRequest {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
message RestartResponse {
|
||||
bool success = 1;
|
||||
uint32 client_id = 2;
|
||||
}
|
||||
|
||||
// Host → device: begin UART OTA (erase inactive OTA slot; device replies OTA_STATUS).
|
||||
message OtaStartPayload {
|
||||
uint32 total_size = 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user