Repeater: the stats request also carries the node's sensors (humidity, pressure, external temperature, ...)

Changelog-cs: Repeater: požadavek na statistiky teď vrací i senzory uzlu (vlhkost, tlak, externí teplotu, ...)
Changelog-topic: stats-bundle
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-12-04 03:52:50 +01:00
1 parent 97f52e71b8
commit 2a5c596250
7 files changed
+997 -16

No files matched your search

+51 -12
View File
@@ -5,7 +5,7 @@
> not part of upstream's protocol.
A monitoring scrape used to cost a login (when the session had expired),
`REQ_TYPE_GET_STATUS`, `REQ_TYPE_GET_TELEMETRY_DATA` and, for the filter
`REQ_TYPE_GET_STATUS`, `REQ_TYPE_GET_TELEMETRY_DATA` (the node's sensors) and, for the filter
counters, more CLI round trips -- up to 6 packets over several hops. The
**stats bundle** answers all of it in **one request and one reply**.
@@ -30,8 +30,12 @@ An unknown page gets no reply. A build without the bundle ignores the type
reply to page 0 falls back to `GET_STATUS` + `GET_TELEMETRY_DATA`.
**Who may read what.** An **admin** gets everything. A guest or read-only login
gets exactly what `GET_STATUS` and the base telemetry give it today -- status
and telemetry records (ids 1..21), one page, nothing else.
gets exactly what `GET_STATUS` and the telemetry give it today -- status
and telemetry records (ids 1..21) and the sensor record (id 42, below), nothing
else. Sensors follow the telemetry rules: a **guest** is answered as telemetry
answers a guest (base set, so no sensors and no id 42); any other login gets
all of them, as a `GET_TELEMETRY_DATA` with the default (all permissions) mask
does.
## Reply
@@ -72,7 +76,7 @@ an absent counter is 0. Always sent for an admin: ids 32, 33, 34 (see below).
| 10 / 11 | `recv` / `sent` | packets |
| 12 / 13 | `sent_flood` / `sent_direct` | |
| 14 / 15 | `recv_flood` / `recv_direct` | |
| 16 | `err_events` | error flag bits |
| 16 | `err_events` | the error flag **bits** of `RepeaterStats.err_events` (a bit set, not a count of errors) |
| 17 / 18 | `direct_dups` / `flood_dups` | |
| 19 | `recv_errors` | |
| 20 / 21 | `tx_start_fail` / `tx_timeout` | |
@@ -88,6 +92,7 @@ an absent counter is 0. Always sent for an admin: ids 32, 33, 34 (see below).
| 36 | `n_counters` | number of flow slots with a non-zero counter (see "Pages") |
| 40 (wt 1) | `counters` | a run of triples `slot, dropped, passed`, each a varint |
| 41 (wt 1) | `rule` | one rule, below |
| 42 (wt 1) | `env_lpp` | the node's sensors, below |
`rules_auto` / `rules_static` are the `crc16` values of `filter flow`
(CRC-16/CCITT-FALSE over the canonical serialization, see
@@ -95,6 +100,20 @@ an absent counter is 0. Always sent for an admin: ids 32, 33, 34 (see below).
and `test/vectors/flow_rules_vectors.json`), with the entry count above them.
An empty set is `0x0000FFFF`.
**Sensor record** (id 42): the **CayenneLPP bytes** (`[channel][type][data]`
repeated, the format of a `GET_TELEMETRY_DATA` reply) of the node's sensors
**without channel 1**. Channel 1 is the node itself -- battery and MCU
temperature are already ids 1 and 2 (GPS, where a build reports it, is also on
channel 1 and so not here). It is what a telemetry request would add for the
same login: environment sensors (temperature, humidity, pressure, INA, ...) on
channels 2.., in the order the node initialised them. The record is **omitted**
when there is nothing to send (no sensors, a guest); readings are whole, and
those that would not fit in 128 B (`SB_ENV_MAX`) are left out, never cut. A
reader decodes it like a telemetry reply; types and scaling are in
`lpp_decode()` of the Python reference (e.g. `02 67 00E1` = channel 2,
temperature 22.5 C; `02 68 3C` = humidity 30 %; `02 73 271C` = pressure
1001.2 hPa; 11 B for the three).
**Rule record** (id 41): `slot` (varint) `kind` (1 B, ASCII) `klen` (1 B)
`key` (klen B) `mf` (1 B) then, in this order and only when flagged,
`secs` (varint, mode throttle), `expires` (varint, absolute unix),
@@ -107,14 +126,21 @@ An empty set is `0x0000FFFF`.
`slot_id` is the index in the **sorted** rule table of `filter flow`
((kind, key) order) and **moves on `add` / `del` / expiry**.
* **Page 0** is what is read every scrape: ids 1..21, fairness, ids 32..36 and
as many `(slot, dropped, passed)` as fit in the 150 B -- for every slot with a
non-zero counter, in slot order. A realistic node (2 rules, a few fairness
drops, the full status) needs about 116 B including the rule records; all 16
slots with counters do not fit, so the rest of the triples spills to page 1.
* **Pages 1..** hold, in this order, the **spilled counter triples** (id 40, the
slots that did not fit on page 0, still in slot order) and then the **rule
metadata** (id 41), one record per slot in slot order. A record is never
* **Page 0** is what is read every scrape: ids 1..21, fairness, ids 32..36, the
**sensor record** (id 42) and as many `(slot, dropped, passed)` as fit in the
150 B -- for every slot with a non-zero counter, in slot order -- and, **when
they fit, the rule records (id 41)** after them: a record is never split, and
what does not fit moves to page 1 and on. The rule table holds **24 rules**
(`FLOW_MAX`). A realistic node (2 rules, a few fairness drops, the full
status, 3 sensors) needs 129 B including the rule records; 16 slots with
counters do not fit, so the rest of the triples spills to page 1. The sensor
record comes before the counters and rules, so it takes page 0 ahead of
them; one too big for what is left of page 0 starts page 1 (whole), after
the CRC records.
* **Pages 1..** hold, in this order, a sensor record that did not fit page 0,
the **spilled counter triples** (id 40, the slots that did not fit on page 0,
still in slot order) and then the **rule records** (id 41) that did not fit
page 0, one record per slot in slot order. A record is never
split; a page is closed when the next record does not fit. Every page after
the first starts with the records `rules_auto` and `rules_static` (8 B).
* `n_counters` (id 36) tells how many slots have counters. When the triples on
@@ -235,6 +261,15 @@ test vectors (canonical bytes and CRC for three nodes, one with a denied-flood r
guest and ACL entries, the adaptive battery thresholds (`pwr.*`, their own files) and GPS settings.
Adding a field means a new serialization version byte (and a new vector).
## Version and compatibility
The sensor record is a **new id** (42), not a new meaning of an old one, so the
version byte stays `1`: a reader that does not know id 42 skips it by its length
(`wt 1`), as the format requires of every reader. A reader that knows it and
talks to a node without it (a release from before this record) finds no id 42 --
the same as a node with no sensors; telling the two apart takes the firmware
version, not the bundle.
## Sizes
| case | page 0 |
@@ -242,6 +277,10 @@ Adding a field means a new serialization version byte (and a new vector).
| guest (status + telemetry) | 60 B |
| admin, empty table, short status | 18 B |
| admin, 2 rules, a few fairness drops, full status | 116 B (one page) |
| the same + 3 sensors (temperature, humidity, pressure: 11 B LPP + 2 B header) | 129 B (one page) |
| admin, empty table, full status, 3 sensors | 93 B |
| read-only, full status, 3 sensors | 73 B |
| admin, 2 rules, a 124 B sensor record | 82 B + 145 B + 35 B (3 pages; the sensors on page 1) |
| admin, 16 rules with counters | 149 B + 145 B + 150 B + 70 B (4 pages) |
The boundary cases (149 / 150 B fit, 151 B moves the last record to page 1)
+1 -1
View File
@@ -199,7 +199,7 @@ clock reads before 2026; a clock running ahead makes everything look old.
## Stats bundle -- one request per scrape (repeater)
A binary request (`0xF1`, not a console command) that returns status, telemetry,
A binary request (`0xF1`, not a console command) that returns status, telemetry (with the node's sensors),
FairnessLimiter drops, per-rule `filter flow` counters, the rule CRCs
(`rules_crc16`, auto and static), `prefs_crc16` and the adaptive power save
stage in one reply of at most 150 B, paged when it does not fit. Admin gets