diff --git a/POLLING.md b/POLLING.md index 5ab36add..66de1c20 100644 --- a/POLLING.md +++ b/POLLING.md @@ -70,7 +70,7 @@ One reading per message, published as JSON: {"v":2,"origin":"My Observer","origin_id":"AB12…","timestamp":"2026-11-22T18:04:11.000000+00:00", "plugin":"meshcore.observer_fw/v1.18.0.9", "readings":[{"node_id":"c8c8c858…","battery_mv":4226,"source":"poll","reply_hops":0, - "method":"telemetry","sampled_at":"2026-11-22T18:04:09.000000+00:00","snr":9.25,"temperature_c":21.5, + "method":"telemetry","sampled_at":"2026-11-22T18:04:09.000000+00:00","snr":9.2,"temperature_c":21.5, "lpp":"0174107e…","tag":1763834649,"packet_hash":"9F3C…"}]} ``` diff --git a/POLLING_PROTOCOL.md b/POLLING_PROTOCOL.md index 0116c095..386d4e8b 100644 --- a/POLLING_PROTOCOL.md +++ b/POLLING_PROTOCOL.md @@ -1,6 +1,6 @@ # Repeater Polling Protocol -**Status:** describes observer firmware `feat/repeater-poll` / `observer-firmware-poll` as of 2026-11-28 (commit `14f4fc7d2`). Written from the firmware source, not from the openHop plugin. Section 10 lists where the firmware differs from the plugin it mirrors (CoreScope Observer Plus v0.11.1). +**Status:** describes observer firmware `feat/repeater-poll` / `observer-firmware-poll` as of 2026-11-29 (commit `8c8286c96`), checked line by line against the firmware and plugin sources. Written from the firmware source, not from the openHop plugin. Section 10 lists where the firmware differs from the plugin it mirrors (CoreScope Observer Plus v0.11.1). **Audience:** analyzer implementers (CoreScope, Beacon) and anyone building a compatible poller. @@ -48,18 +48,18 @@ A failed policy fetch keeps the mode in force. Leaving a JSON mode for encrypted |---|---|---| | **Node key** | The repeater's own Ed25519 identity. Public half = `origin_id`. Signs registrations, claims (JSON mode) and MQTT JWTs. Opens password envelopes (§7.3). | Never | | **Own polling key** | A separate Ed25519 identity created on the node for polling only. Logs in to targets as a guest. | Encrypted mode with `poll.consent yes`: private half uploaded to the analyzer (§4.4). Otherwise never. | -| **Shared key** | One keypair the analyzer hands to every observer (§4.5). Encrypted mode only, when registration is unsupported (404) or not consented. | Fetched, never uploaded | +| **Shared key** | One keypair the analyzer hands to every observer (§4.5). Encrypted mode with `poll.consent yes` only, while no registration accepted in the last 24 h exists (unsupported, failed, expired, or not yet registered). | Fetched, never uploaded | -Key in use: JSON and local modes always use the own key. Encrypted mode uses the own key while a registration accepted in the last 24 h exists, else the shared key, else none (no polling). +Key in use: JSON and local modes always use the own key. Encrypted mode needs `poll.consent yes` for any key: then the own key while a registration accepted in the last 24 h exists, else the shared key, else none (no polling). Without consent, encrypted mode polls nothing. Leaving a JSON mode clears the registration; a cached shared key can cover the gap until the own key is registered again. --- ## 3. Radio exchange (observer ↔ target) -Every packet is direct-routed to a direct neighbor. Nothing is ever flooded. +Every packet the observer sends is zero-hop direct to a direct neighbor; it never floods. The target's replies may come back flooded (it has no return route until one is taught) and are accepted. ### 3.1 Target eligibility -- The target MUST be in the node's neighbor table and heard within the last 24 h (zero-hop advert). Relayed targets are never polled. +- The target MUST be in the node's neighbor table and heard within the last 24 h (a zero-hop advert, or a neighbor-discovery answer). Relayed targets are never polled. - Excluded by the policy (`excluded_nodes` or owners `excluded`), admin-stopped (§3.5), or gated (§5.4) targets get no packet. ### 3.2 Packets @@ -67,27 +67,30 @@ Every packet is direct-routed to a direct neighbor. Nothing is ever flooded. | Step | Payload type | Content | |---|---|---| | Login | `ANON_REQ` | `timestamp(4 LE) ‖ password` to the target, from the polling key | -| Route teach | `PATH`, direct | Return path (empty for a direct neighbor), encrypted to the target | -| Request | `REQ` | `tag(4 LE) ‖ req_type`: `0x03` telemetry, or `0x01` status | -| Admin removal | `TXT_MSG`, CLI subtype `0x01` | `setperm 0` | -| Reply | `RESPONSE` (or `RESPONSE` inside `PATH`) | `tag(4 LE) ‖ data` | +| Route teach | `PATH`, direct | `path_len(1) ‖ path ‖ 0xFF ‖ random(4)`; for a direct neighbor `00 FF` + 4 random bytes | +| Request | `REQ` | 13 bytes: `tag(4 LE) ‖ req_type ‖ 00 00 00 00 ‖ random(4)`; `req_type` `0x03` telemetry or `0x01` status (the first zero is the telemetry permission mask) | +| Admin removal | `TXT_MSG` | `timestamp(4 LE) ‖ flags 0x04 ‖ "setperm 0"`; flags = CLI-data text type `1 << 2`, which every repeater release accepts | +| Reply | `RESPONSE` (or `RESPONSE` inside `PATH`) | Payload `dest_hash(1) ‖ src_hash(1) ‖ MAC + ciphertext`; dest = polling key's first byte, src = target's. Plaintext `tag(4 LE) ‖ data`. A `PATH` wrapper holds `path_len ‖ path ‖ type` (low nibble `RESPONSE`) before the inner response | - Status is requested at most every `poll.status` hours (1/3/6/12/24, default 6); otherwise telemetry. +- **Status data:** the target's stats struct, little-endian, battery first; at least 2 bytes (battery mV) to count. **Telemetry data:** Cayenne LPP. Channel 1 type 116 = voltage (u16 BE × 10 mV); channel 1 type 103 = temperature (i16 BE tenths of °C, kept only within −60…125 °C). - A login answer starts with the target's clock, not a tag. It is recognized by shape (`data[0]==0`, `data[2]<=3`, admin iff `data[2]==1`). A reply whose tag is one of the last 16 tags sent to that target is never read as a login. -- Request tags are unique, monotonic sender timestamps; the high-water mark is persisted so they never go backwards across reboots. No polling until NTP has set the clock this boot. +- Request, login and admin-command timestamps are unique and monotonic above a high-water mark. The mark is saved to flash with the poll state (periodically, on other state changes, and on an orderly reboot); an abrupt reset can lose the most recent advance. No polling until NTP has set the clock this boot. ### 3.3 Per-poll sequence -1. **Fast path** (a login was answered before and the 24 h admin recheck is not due): teach the route first if it may be lost (last reply flooded, last result not OK, or route older than 24 h; then 1 s settle), send the request, listen 10 s, resend once after 8 s. On every 3rd consecutive miss, fall through to a login. -2. **Login path**: passwords in order (§3.4), 8 s apart, 10 s listen each. Admin answer → §3.5. Guest answer → if the answer flooded, wait 15 s, teach the route; then send one request. +Listen windows: 10 s for a login; `max(10 s, the radio's response estimate)` for a request. Gaps below start after the listen window ends. Every resend uses a fresh tag. + +1. **Fast path** (a login was answered before and the 24 h admin recheck is not due): teach the route first if it may be lost (last data reply flooded, last result not OK, or route older than 24 h), then 1 s settle; send the request and listen; if unanswered, wait 8 s and send once more. On every 3rd consecutive miss, fall through to a login. +2. **Login path**: when re-checking a target that is already in the ACL, teach the route first. Then passwords in order (§3.4), each followed by its listen window, 8 s between them. Admin answer → §3.5. Guest answer → if the answer flooded, wait 15 s; teach the route if the target was not already known (or the answer flooded), 1 s settle; then send one request. 3. No login answer → no request. ### 3.4 Passwords -- Default (`poll pw auto`): blank, then `hello`. A learned `hello` (or blank under the own key) is tried alone. After 2 consecutive unanswered logins, one password per poll, alternating by UTC day. -- Operator password (`poll pw set `, 1–15 printable characters): the only password tried for that target. Discarded on an admin answer. +- Default (`poll pw auto`): blank, then `hello`. A learned `hello` (or a learned blank under the own key) is tried alone. After 2 consecutive polls whose logins went out unanswered, and with nothing learned or forced, one password per poll, alternating by UTC day. +- Operator password (`poll pw set `, 1–15 characters, ASCII `0x21`–`0x7e`): the only password tried for that target. Discarded on an admin answer. - Requested target (§7.3): the password from its envelope, 1–15 bytes. ### 3.5 Admin answer -If a login under the polling key comes back **admin**: no request is sent, an operator password is discarded, and the node runs the drill: `setperm 0`, wait 10 s, then up to 3 verifying blank logins (8 s apart, 20 s listen). The target is then **admin-stopped**: never polled again until `poll enable `, persisted across reboots and target removal. The claim reports it as `state:"admin_stop"`. A forced login every 24 h catches a grant made after the first contact. +If a login under the polling key comes back **admin**: no request is sent, an operator password is discarded, and the target is **admin-stopped** at once (saved before the drill): never polled again until `poll enable `, across reboots and target removal (a removed target's stop can be evicted only when the state store is full). The node then runs the drill: `setperm 0`, wait 10 s, then up to 3 verifying rounds (route teach + blank login, 20 s listen, 8 s apart). If the `setperm` cannot be transmitted the drill ends. Extended claims (JSON modes) report the target as `state:"admin_stop"`; plain claims have no state field. A forced login every 24 h catches a grant made after the first contact. ### 3.6 Scheduling and limits - Interval per target = `max(poll.interval` (30–1440 min, default 60) `, policy window)`. The policy window is a floor; the local interval can only slow polling. @@ -95,7 +98,7 @@ If a login under the polling key comes back **admin**: no request is sent, an op - One poll at a time; at least 60 s between scheduled polls. - Request cap: at most `max_requests` (policy, 1–3, default 2) polls per target per window. - Backoff: daily after 24 h unheard, daily after 2 consecutive flooded data replies, daily on a 0 mV reading; a quick retry (`min(interval, 20 min)`) only after a miss within 24 h of a success. -- `poll now ` bypasses role, freshness and cap, but honors the gate, policy exclusions, the claim slot, the 60 s gap and the clock. +- `poll now ` bypasses owners roles (including an owners `excluded` entry), freshness and the cap, but honors the gate, the policy's `excluded_nodes`, the claim slot, the clock, and a 60 s per-target cooldown. Manual attempts still count toward the scheduled cap afterwards. --- @@ -103,10 +106,10 @@ If a login under the polling key comes back **admin**: no request is sent, an op ### 4.1 Transport - Base URL `poll.url` (`http://` or `https://`, ≤ 95 bytes, an optional path prefix before `/api`). HTTPS validates against the node's CA bundle; if the bundle is unavailable, no session starts. -- A **control session** is one connection (keep-alive) carrying the calls below in order, with a 25 s budget: connect ≤ 5 s, TLS handshake ≤ 12 s, each response ≤ 5 s. +- A **control session** carries the calls below in order over a keep-alive connection (reconnecting if the server closed it between calls), with a 25 s budget: connect ≤ 5 s, TLS handshake ≤ 12 s, each response ≤ 5 s. - Request headers: `Host`, `User-Agent: meshcore-observer/0.11.1`, `Accept: application/json`, `Connection: keep-alive`, plus `Content-Type: application/json` and `Content-Length` on POST. No auth headers. -- Responses: body ≤ 6144 bytes, header framing ≤ 8192 bytes. `Content-Length` and `Transfer-Encoding: chunked` are accepted. Redirects are not followed. A larger body, a bad JSON object, or a timeout counts as a transport failure. -- At most one session per 600 s, and only when something depends on fresh data: a registration is due, a claim went out since owners last answered, the gate is closed, the startup hold is on, no policy has answered this boot, a target or `poll now` is due, the claim slot is unresolved, or requested targets are held. A request the bridge never answers is abandoned after 180 s. +- Responses: body ≤ 6144 bytes, header framing ≤ 8192 bytes. `Content-Length` and `Transfer-Encoding: chunked` are accepted. Redirects are not followed. A timeout or an oversized 200 body is a transport failure; a non-200 keeps its status code. A 200 whose JSON is unusable counts as a protocol failure for owners, policy and the shared key; for registration it keeps status 200 but is not an acceptance. +- At most one session per 600 s, and only when something depends on fresh data: a registration is due, a claim went out since owners last answered, the gate is closed, the startup hold is on, no policy has answered this boot, a target or `poll now` is due, the claim slot is unresolved (JSON mode, `poll.slot` 0), or requested targets are active. A session the bridge never runs is abandoned after 180 s. ### 4.2 Calls, in session order @@ -117,7 +120,7 @@ If a login under the polling key comes back **admin**: no request is sent, an op | 3 | `POST {base}/api/guest-keys` | Encrypted mode, `poll.consent yes`, registration due | | 4 | `GET {base}/api/shared-guest/key` | Encrypted mode, own key not usable and no shared key under 24 h old; or the registration answered 404 | -Calls 3 and 4 are never made until a policy answer (this session's, or the mode already known) has chosen encrypted mode. +`client_version` is the firmware release, sanitized and at most 23 bytes; omitted if empty. The policy GET is skipped only when the owners reply had a valid `nodes` object **and** a `policy` object. Calls 3 and 4 are planned before the session starts and made only if the mode (this session's policy answer, else the mode already known) is encrypted, so a switch from JSON to encrypted triggers them in the next session. A first registration that fails other than by 404 defers the shared-key fetch to a later session. ### 4.3 Owners and policy @@ -126,10 +129,10 @@ Calls 3 and 4 are never made until a policy answer (this session's, or the mode | Field | Meaning | |---|---| | `role` | `polling`, `independent`, `standby`, `excluded`, `paused`, `disabled`, or absent | -| `mine` | bool; with no role, `mine` → poller, else standby | +| `mine` | truthy value; with no role, `mine` → poller, else standby | | `excluded` | truthy → skip | -| `standby_rank` | integer ≥ 1 (default 1) | -| `owner_hops` | 0/1 | +| `standby_rank` | integer, clamped to 1–255 (default 1) | +| `owner_hops` | parsed (0–255) but not used: the firmware is direct-only | | `latest_ts` | ISO time of the newest reading for that target | | `requested` | literal `true`: an analyzer-requested target (§7.3) | | `pw` | password envelope for a requested target (§7.3) | @@ -154,7 +157,7 @@ Role mapping: community off or no entry → poller. `excluded`/`paused`/`disable | `reading_format` | – | `"json"` or `"telemetry"` selects a JSON mode (§1.1) | | `mqtt_hosts` | [] | Up to 4 broker hostnames; picks the claim/reading slot when `poll.slot` is 0 (§6.1) | -Only a 200 replaces the policy in use. A 404 means "no policy" (defaults, encrypted mode); a failure keeps the last copy and its switches. If a policy was fetched once, later fetches fail, and the copy is over 6 h old, all windows double. If the excluded list or node windows overflowed, a target not covered by the kept entries is treated as excluded / given the maximum window. +Only a 200 replaces the policy in use. A 404 selects encrypted mode and keeps whatever policy and gate were in use (the defaults if none was ever fetched); a failure keeps the last copy and its switches. If a policy was fetched once, the latest attempt failed (not 200 or 404), and the copy is over 6 h old, all windows double. If `excluded_nodes` overflowed, a target that was not among the configured targets when the policy was read is treated as excluded. If `node_windows` overflowed, such a target keeps its window if one was kept, else gets the maximum (86400 s, doubled when stale). ### 4.4 Registration (encrypted mode) @@ -168,11 +171,11 @@ Only a 200 replaces the policy in use. A 404 means "no policy" (defaults, encryp Signed message: `corescope-guest-key/v1|||`. The node verifies its own signature before sending and refuses to upload a key equal to the node key. -Reply: `{"ok":true,…}` = accepted (the key is usable for 24 h). Re-registered every 6 h; after a 404 ("unsupported"), retried after 6 h and the shared key is fetched in the same session; after any other failure, retried after 5 min. +Reply: HTTP 200 with literal `"ok": true` = accepted (the key is usable for 24 h from then). Re-registered every 6 h after the last attempt while an acceptance or an "unsupported" (404) is on record; after a 404 the shared key is fetched in the same session. With neither on record, a failure is retried after 5 min. All attempts also wait for the 600 s session cadence. ### 4.5 Shared key -`GET /api/shared-guest/key` → `{"public_key":"","private_key":"",…}`. Rejected if the halves do not match. Cached 24 h; past that it stays in use only until a renewal fails. The response body is wiped from memory after parsing. +`GET /api/shared-guest/key` → `{"public_key":"","private_key":"",…}`. Rejected if the halves do not match, or if the public key's first byte is `00`, `FF`, or equal to the observer's own first byte (hash-byte collisions). Cached 24 h; past that it stays in use only until a renewal fails. The response body is wiped from memory after parsing. --- @@ -185,12 +188,12 @@ After boot (community on, URL set), scheduled polls wait until a claim has been The owners `latest_ts` stands in for the plugin's per-target battery lookup. Owners answered within 900 s counts as "reachable". - **Poller:** skip while `latest_ts + window` is in the future. Analyzer unreachable → poll anyway (fail open). -- **Standby (rank r):** wait `window + grace_s × r` after `latest_ts`, or after the later of standby start and the last restart/pause when there is no reading. Analyzer unreachable → hold, recheck in 600 s. -- Owners not answered for 1800 s → roles are forgotten and the node polls everything itself. +- **Standby (rank r):** wait `window + grace_s × r` counted from `max(latest_ts, hold_from)` when a reading exists, or from `max(standby_since, hold_from)` when none does. `hold_from` is the later of poller start and the last moment a gate was closed. Analyzer unreachable → hold, recheck in 600 s. +- Owners not answered for more than 1800 s → roles are forgotten and the node polls everything itself. - Community off: no owners calls; the node is always the poller, but freshness, cap, gate and exclusions still apply. ### 5.3 Gate -Blocked outranks version, which outranks pause. Any closed gate stops all polling, including `poll now`. The gate (blocked, version, pause end) is saved to flash and applied after a reboot until a policy 200 changes it; a 404 or failure never clears it. +Blocked outranks version, which outranks pause. A closed gate stops every new poll, including `poll now`; a configured target's exchange already on air finishes, and control sessions, claims and held readings continue. The gate (blocked, version, pause end) is saved to flash and applied after a reboot until a policy 200 changes it; a 404 or failure never clears it. Changing `poll.url` clears it. Local mode has no gate. --- @@ -198,14 +201,16 @@ Blocked outranks version, which outranks pause. Any closed gate stops all pollin ### 6.1 Slot and topics - Claims and readings go out on **one** existing MQTT slot: `poll.slot` if set; otherwise the slot whose broker host matches the policy's `mqtt_hosts`; otherwise none. With an analyzer and no slot, nothing is claimed and nothing is polled ("nothing is polled that cannot be claimed"). The node never adds a broker. -- QoS 1, retain false, over the slot's existing session (no separate connection). +- QoS 1, retain false, over the slot's existing session (no separate connection). "Published" means the bridge queued it on the slot; the firmware does not wait for the PUBACK. +- With several matching slots, the lowest-numbered enabled slot is used, even if its topic layout (MeshRank) carries no polling topics. - Topics, MeshCore layout: `meshcore///`, leaf `polling` (claims), `battery` (`v:1` readings), `telemetry` (`v:2` readings). A custom slot template uses `{type}` = the leaf. MeshRank slots carry none of these. ### 6.2 Claims -Sent every 30 min, at once on a change, retried no sooner than 60 s after a failed attempt. Not sent in local mode. +Sent every 30 min and on a change, but never sooner than 60 s after the previous attempt, successful or not (urgent changes included). Not sent in local mode. - Encrypted mode: claims list targets only while a polling key is in use. A list already published this boot is taken back by one empty claim when the key is lost. -- Community off: one last claim with `"community":false`, then none. +- Community off: one last claim with `"community":false` if a community-on claim was published before (or a retraction is owed), then none. +- Targets that stop being claimable do not by themselves produce an empty claim; the list just shrinks at the next claim, and an empty list with nothing to retract and no request seats is not sent. - In a JSON mode with `poll.requests on`, a claim goes out even with no targets, to advertise free seats. **Plain claim (encrypted mode)**, Python `json.dumps` separators (`", "`, `": "`): @@ -217,7 +222,7 @@ Sent every 30 min, at once on a change, retried no sooner than 60 s after a fail "nodes": [{"node_id": "", "reply_hops": 0, "via": null, "key": "shared", "snr": 6.5}]} ``` -**Extended claim (JSON modes)** adds envelope fields `accepts_requests`, `request_slots` (free seats), `max_slots` (`poll.limit`), `poll_interval` (minutes), `poll_url`, and per node `key` (`own`/`password`), `requested` (when true), `state` (`pending`/`ok`/`no_reply`/`login_failed`/`admin_stop`/`not_direct`), `misses`, `last_attempt`, `last_ok`; and ends with `sig`. Field rules, the signed message and verification are in [POLLING_CLAIMS_SPEC.md](POLLING_CLAIMS_SPEC.md). A change to an urgent state (`login_failed`, `admin_stop`), a key kind, the requested flag, the opt-in, the limit, the interval or the host sends a claim at once. +**Extended claim (JSON modes)** adds envelope fields `accepts_requests`, `request_slots` (free seats), `max_slots` (`poll.limit`), `poll_interval` (minutes), `poll_url`, and per node `key` (`own`/`password`), `requested` (when true), `state` (`pending`/`ok`/`no_reply`/`login_failed`/`admin_stop`/`not_direct`), `misses`, `last_attempt`, `last_ok`; and ends with `sig` whenever `poll_url` is present. If the claim cannot be signed it is not sent (retried after 60 s). Field rules, the signed message and verification are in [POLLING_CLAIMS_SPEC.md](POLLING_CLAIMS_SPEC.md). A change to an urgent state (`login_failed`, `admin_stop`), a key kind, the requested flag, the opt-in, the limit, the interval or the host sends a claim at once. ### 6.3 Readings (local and JSON modes) One reading per message, compact JSON separators: @@ -226,7 +231,7 @@ One reading per message, compact JSON separators: {"v":2,"origin":"","origin_id":"", "timestamp":"","plugin":"meshcore.observer_fw/", "readings":[{"node_id":"","battery_mv":4226,"source":"poll","reply_hops":0, - "method":"telemetry","sampled_at":"","snr":9.25,"temperature_c":21.5, + "method":"telemetry","sampled_at":"","snr":9.2,"temperature_c":21.5, "lpp":"","tag":1763834649,"packet_hash":"<16 hex upper>"}]} ``` @@ -236,16 +241,16 @@ One reading per message, compact JSON separators: | `battery_mv` | Always (0 if none) | Only if the reply had a voltage | | `lpp` | – | Telemetry replies (raw LPP bytes, ≤ 160) | | `stats` | Status replies | Status replies | -| `snr` | Neighbor SNR, dB to 0.01, clamped ±30 | same | +| `snr` | SNR of the received reply packet, clamped ±30 dB, one decimal (Python rounding, ties to even) | same | | `temperature_c` | Channel-1 MCU temperature if present | same | -| `tag`, `packet_hash` | The request tag; 8-byte hash of the reply packet, to cross-check against the packet feed | same | +| `tag`, `packet_hash` | The request tag; first 8 bytes of SHA-256(payload type ‖ payload) of the reply packet (MeshCore's packet hash), to cross-check against the packet feed | same | `stats` carries the status fields present in the reply: `uptime_secs`, `noise_floor`, `last_rssi`, `last_snr`, `tx_queue`, `packets_recv`, `packets_sent`, `recv_flood`, `recv_direct`, `sent_flood`, `sent_direct`, `tx_air_secs`, `rx_air_secs`, `flood_dups`, `direct_dups`, `recv_errors`, `err_events`. -Unpublished readings are held (newest per target, at most 8) and retried every 60 s while the slot is down or its broker changed. +`timestamp` is when the message was built; `sampled_at` is when the reply arrived. Unpublished readings are held (newest per target, at most 8) and retried every 60 s while the slot is down or its broker changed. Held readings are dropped when their target is removed, when `poll.url` or the mode changes, or when polling is turned off. ### 6.4 Packet feed -In every mode, the target's encrypted reply (and the node's other traffic) also travels in the node's normal packet uploads. In encrypted mode this is the only way the reading reaches the analyzer. +The target's encrypted reply is handed to the bridge like any received packet, so it travels in the node's normal packet uploads when those are enabled for the slot (subject to the node's RX/packet-upload settings and filters). In encrypted mode this is the only way the reading reaches the analyzer. --- @@ -256,21 +261,24 @@ A node accepts analyzer-chosen targets only when **all** hold: `poll.requests on ### 7.2 Lifecycle - An owners entry for a key the operator did not configure, with `"requested": true`, offers a target. Configured targets always keep their seats; requested ones fill the rest of `poll.limit` (1–8), best role first (poller, then standby by rank, then parked). -- A requested target is polled only while its owners entry still says `requested: true` and its role is not excluded, paused or disabled. It is dropped when its entry goes away, when owners has not answered for 1800 s, when the URL changes, or when the opt-in or HTTPS condition no longer holds. +- A requested target is polled only while its owners entry still says `requested: true` and its role is not excluded, paused or disabled. It is dropped when its entry goes away, when owners has not answered for more than 1800 s, when the URL changes, or when any §7.1 condition stops holding (opt-in, HTTPS, JSON mode, community, polling on). Ties in seat order go by standby rank, then key bytes. +- An entry without `pw` is polled with the normal guest passwords (§3.4). - The claim reports requested targets with `"requested": true`, the key kind (`password` if it has an envelope password, else `own`) and their state. ### 7.3 Password envelope Owners entry field `pw`: `{"epk":"","ct":"","tag":"","ver":}` (`ver` optional, default 0). ``` -secret = X25519-style MeshCore key exchange (node private key, epk) +secret = MeshCore key exchange: epk is an Ed25519 public key, converted to X25519 and combined + with the node's private key (an all-zero secret is refused) info = "beacon-poll-pw/v1|" + hex(observer_pub) + "|" + hex(target_pub) + "|" + hex(epk) + "|" + decimal(ver) + ; hex is lowercase, no terminating NUL key = HMAC-SHA256(secret, info) ; 32 bytes check = HMAC-SHA256(key[16..32], ct) == tag (full 32-byte compare) plaintext = AES-128-ECB-decrypt(key[0..16], ct) ; password bytes then zero padding, 1..15 bytes ``` -A malformed envelope, a failed tag, or a bad plaintext marks the target unusable until a new envelope arrives. A login that keeps failing under one envelope is reported as `state:"login_failed"` and not retried until `ver` changes. An admin answer stops the target for good (§3.5) and drops the password. +A malformed envelope, a failed tag, or a bad plaintext marks the target unusable until a new envelope arrives. Two consecutive polls with unanswered logins under one envelope latch it as `state:"login_failed"`; it is not retried until an envelope with a different `ver` arrives or the target is dropped. An admin answer stops the target for good (§3.5) and drops the password. --- @@ -278,7 +286,7 @@ A malformed envelope, a failed tag, or a bad plaintext marks the target unusable | Item | Limit | |---|---| -| Targets (configured + requested) | `poll.limit`, 1–8 | +| Targets | 8 in all. Configured targets always keep their seats; requested targets fill up to `poll.limit` (1–8) | | `poll.url` | 95 bytes | | HTTP response body | 6144 bytes | | Claim JSON | 3328 bytes | @@ -286,7 +294,7 @@ A malformed envelope, a failed tag, or a bad plaintext marks the target unusable | Policy `excluded_nodes` / `node_windows` / `mqtt_hosts` | 16 / 8 / 4 | | Control session | 1 per 600 s, 25 s budget | | Poll gap | ≥ 60 s between scheduled polls | -| Owners stale | 1800 s; reachability 900 s | +| Owners stale | more than 1800 s; reachability 900 s | --- @@ -313,17 +321,17 @@ The firmware follows the plugin's guest-key path unless listed here. "Plugin" re ### 10.2 Behaves differently | Area | Plugin | Firmware | |---|---|---| -| Control cadence | Policy every 600 s plus a refresh before any send if older than 60 s; owners every 600 s, invalidated after a claim | One session per 600 s at most, only when something depends on it; owners and policy in one connection, policy skipped when owners embeds it | -| HTTP identity | `plugin_version` only | Adds `client=meshcore.observer_fw&client_version=`; `User-Agent: meshcore-observer/0.11.1` | +| Control cadence | Policy every 600 s, plus a refresh before choosing a poll if older than 60 s; owners every 600 s, invalidated after a claim | One session per 600 s at most, only when something depends on it; owners and policy in one connection, policy skipped when owners embeds it | +| HTTP identity | `observer` and `plugin_version` | Same, plus `client=meshcore.observer_fw&client_version=`; `User-Agent: meshcore-observer/0.11.1` | | Version gate | Compares the plugin's own version | Always presents and compares `0.11.1`, whatever the firmware release | -| MQTT connection | Separate short connection per message, own client id | The slot's existing session | +| MQTT connection | Separate short connection per message, own client id; waits for the PUBACK | The slot's existing session; counts a message as sent once queued | | Claim timestamp | `YYYY-MM-DDTHH:MM:SSZ` | `YYYY-MM-DDTHH:MM:SS.000000+00:00` (same shape as the bridge's other messages) | | Claim `plugin` | `openhop.corescope_observer_plus/0.11.1` | `meshcore.observer_fw/` | | Claim key kind | `shared` / `own` / `password` by path | Encrypted mode: always `shared`. JSON modes: `own` or `password` | | Empty claims | Never sent | One empty claim retracts a published list when the polling key is lost | | Passwords under the polling key | Only `""` or `"hello"`; a real password moves the target to the companion path | Also an operator password (`poll pw set`) or an envelope password, sent under the polling key | | Admin answer | Disables the guest key for that target via a config override | Admin stop: persistent, cleared only by `poll enable`; operator password discarded | -| Admin removal text type | openhop_core CLI command constant | MeshCore CLI subtype `0x01` | +| Admin removal text type | openhop_core `TXT_TYPE_CLI_COMMAND` (numeric value not in the plugin repo) | CLI-data type 1 (flags `0x04`), which older repeaters also accept | | Targets | Larger lists, chosen in a UI | Up to 8, via CLI; `poll.limit` | | Persistence | Full policy, registration acceptance, claim metadata and rich per-node state in `state.json` | Only the items in §9 survive a reboot | @@ -331,7 +339,7 @@ The firmware follows the plugin's guest-key path unless listed here. "Plugin" re | Feature | Where | |---|---| | Local mode (no analyzer, readings to the operator's broker) | §1.1 | -| JSON reading modes (`reading_format`), readings `v:1` on `/battery` and `v:2` on `/telemetry` with `lpp`, `tag`, `packet_hash` | §1.1, §6.3 | +| Policy-selected JSON reading modes (`reading_format`): guest-key readings decoded on the node and published, `v:1` on `/battery` (the envelope the plugin uses only for its companion path, plus `tag`, `packet_hash`) and a new `v:2` on `/telemetry` (adds `lpp`) | §1.1, §6.3 | | Slot selection by policy `mqtt_hosts` | §6.1 | | Requested targets with password envelopes | §7 | | Extended claim fields (`accepts_requests`, `request_slots`, `max_slots`, `poll_interval`, per-node `state`/`misses`/`last_attempt`/`last_ok`/`requested`) | §6.2 |