feat: ping drivers and push groups from the devices modal
POST /devices/ping broadcasts an ESP-NOW PING_REQ, collects the drivers' PING_RSP for timeout_s and registers or renames the ones that answer. A reply also counts as the driver being heard, so group updates go to it again. POST /devices/groups sends every ESP-NOW driver its groups and reports the acks. The devices modal gets the Ping drivers and Update groups buttons from main, with per-driver ping dots. UI files are now served with Cache-Control: no-cache and the firmware build hash as ETag, so a browser picks up a new UI right after an update instead of a day later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e7f238aebc
commit
19fea0b0a1
10 files changed
+559
-29
No files matched your search
@@ -118,3 +118,31 @@ def test_status(c):
|
||||
def test_delete(c, espnow_dev):
|
||||
assert c.delete(f"/devices/{ESPNOW_MAC}").status_code == 200
|
||||
assert c.get(f"/devices/{ESPNOW_MAC}").status_code == 404
|
||||
|
||||
|
||||
def test_ping(c):
|
||||
resp = c.post("/devices/ping", json={"timeout_s": 0.5})
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["ok"] is True
|
||||
assert data["timeout_s"] == 0.5
|
||||
assert isinstance(data["responses"], dict)
|
||||
for mac, info in data["responses"].items():
|
||||
assert info["mac"] == mac and "name" in info and info["rtt_ms"] >= 0
|
||||
assert mac in c.get("/devices").json() # repliers are registered
|
||||
|
||||
|
||||
def test_ping_rejects_bad_timeout(c):
|
||||
assert c.post("/devices/ping", json={"timeout_s": "soon"}).status_code == 400
|
||||
|
||||
|
||||
def test_update_groups(c):
|
||||
resp = c.post("/devices/groups")
|
||||
espnow = [d for d in c.get("/devices").json().values() if d.get("transport") == "espnow"]
|
||||
if not espnow:
|
||||
assert resp.status_code == 400
|
||||
return
|
||||
data = resp.json()
|
||||
assert data["total"] == len(espnow)
|
||||
assert data["sent"] + data["failed"] == data["total"]
|
||||
assert resp.status_code == (200 if data["failed"] == 0 else 503)
|
||||
Reference in new issue
Block a user