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:
jimmyandClaude Opus 5.5 committed 2026-11-03 17:53:56 +13:00
1 parent e7f238aebc
commit 19fea0b0a1
10 files changed
+559 -29

No files matched your search

+24 -1
View File
@@ -23,6 +23,7 @@
#define M_RESYNC 0x23
#define M_ECHO 0x24
#define M_OTA_STATUS 0x26
#define M_PING_RSP 0x06
#define F_ACK 1
#define F_COMMIT 2
#define HDR 9
@@ -279,6 +280,13 @@ void rel_set_ota_status_cb(rel_ota_status_cb_t cb)
s_ota_status_cb = cb;
}
static rel_ping_cb_t s_ping_cb;
void rel_set_ping_cb(rel_ping_cb_t cb)
{
s_ping_cb = cb;
}
void rel_set_announce_cb(rel_announce_cb_t cb)
{
s_announce_cb = cb;
@@ -294,7 +302,8 @@ static void recv_cb(const esp_now_recv_info_t *info, const uint8_t *data, int le
// care about is a link reply inside 0x4C
bool announce = (data[0] == WIRE_MAGIC && data[1] == M_ANNOUNCE) || data[0] == '{';
bool reply = data[0] == WIRE_MAGIC &&
(data[1] == M_ACK || data[1] == M_RESYNC || data[1] == M_ECHO || data[1] == M_OTA_STATUS);
(data[1] == M_ACK || data[1] == M_RESYNC || data[1] == M_ECHO || data[1] == M_OTA_STATUS ||
data[1] == M_PING_RSP);
if (!announce && !reply) {
return;
}
@@ -332,6 +341,20 @@ static void handle_rx(const rx_t *rx)
}
return;
}
if (rx->data[1] == M_PING_RSP) {
// The driver is there: count it as heard, so group updates go to it again
xSemaphoreTake(s_lock, portMAX_DELAY);
peer_t *pe = peer_get(rx->mac, true);
if (pe) {
pe->last_ack_us = esp_timer_get_time();
pe->fails = 0;
}
xSemaphoreGive(s_lock);
if (s_ping_cb) {
s_ping_cb(rx->mac, rx->data, rx->len);
}
return;
}
if (rx->len < 10) { // [4C][21][0][seq u16][cnt][mask u32]
return;
}