Assign sequential pod IDs from the master with NVS-stable bindings.
Replaces MAC-byte self-IDs with master allocation (1–255), slave preferred-ID reconnect, debug reset via UART/UI, and rate-limited ASSIGN to avoid ESP-NOW NO_MEM storms. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,7 +2,7 @@ package autotest
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewBenchClientIDFromMAC(t *testing.T) {
|
||||
func TestNewBenchNoDefaultClientIDFromMAC(t *testing.T) {
|
||||
cfg := Config{
|
||||
ID: "t",
|
||||
Network: 1,
|
||||
@@ -20,8 +20,39 @@ func TestNewBenchClientIDFromMAC(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s, _ := b.Slave("pod")
|
||||
if *s.ClientID != 16 {
|
||||
t.Fatalf("client_id=%d want 16", *s.ClientID)
|
||||
if s.ClientID != nil {
|
||||
t.Fatalf("client_id should be unset, got %d", *s.ClientID)
|
||||
}
|
||||
if _, err := b.ResolveClientID("pod"); err == nil {
|
||||
t.Fatal("ResolveClientID should fail without client_id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewBenchExplicitClientID(t *testing.T) {
|
||||
id := uint(3)
|
||||
cfg := Config{
|
||||
ID: "t",
|
||||
Network: 1,
|
||||
MasterMAC: "aa:bb:cc:dd:ee:ff",
|
||||
UART: UARTConfig{
|
||||
Master: "/dev/ttyUSB0",
|
||||
},
|
||||
Slaves: []SlaveNode{{
|
||||
ID: "pod",
|
||||
MAC: "50:78:7d:18:01:10",
|
||||
ClientID: &id,
|
||||
}},
|
||||
}
|
||||
b, err := NewBench(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := b.ResolveClientID("pod")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != 3 {
|
||||
t.Fatalf("client_id=%d want 3", got)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user