meshcore_prefs: a spec per known key -- range and step checked before sending, the value read out of replies that are not bare; gps and powersaving
ci / test (push) Failing after 1m29s

The prefs were a free dict compared as text with the `get` reply, so lint and
sanity could not see that several keys never converge:
- `get radio.silence` -> '30 min (now x1), quiet ...', `get batt.icon` ->
  'on (level 3/5, ...)', `get dutycycle` -> '50.0%': a change on every run,
  then a failure after the `set`;
- `advert.interval` is stored halved (25 reads back as 24, and the node takes
  only 0 or 60-240), `agc.reset.interval` in steps of 4;
- `set repeat <anything but off>` means ON, so `repeat: 0` turned it on;
- lat/lon compared to 1e-3 (~100 m), so a smaller move never went out;
- errors like 'ERR - ...', 'unknown config: ...', 'Invalid ...' did not match
  the expected reply and ended as a timeout after five resends.

module_utils/meshcore_prefspec.py now holds kind, range, step, tolerance and a
reply parser for every pref of the meshcore-tth CLI (CommonCLI.cpp,
CommonRadioPrefs.cpp, NodeMaintenance.cpp, CommonGpsPrefs.cpp); the module
refuses a value the node would refuse or alter before it sends anything, in
check mode too. Unknown keys still go, compared as before, with a warning.
radio.txstall (RAM only) and radio.rxps (compound) are refused with a reason.

New keys that are plain commands in the firmware: gps (off/on/duty),
gps.period, gps.firstfix and powersaving; gps.period goes first and conflicts
with gps off/duty.

Tests: replies as the firmware prints them and as a bench board and three
repeaters answered; with MESHCORE_TTH_SRC set, a drift check that every key is
still in the CLI sources.
This commit is contained in:
tth committed 2026-11-15 14:03:11 +01:00
1 parent 4dfe998409
commit 8306d91b48
5 files changed
+511 -38

No files matched your search

+14 -4
View File
@@ -43,7 +43,7 @@ z AUR, jinde venv a `ansible_python_interpreter` na něj.
| modul | co spravuje | firmware |
|---|---|---|
| `meshcore_acl` | admini repeateru (`setperm`), čte skutečné ACL binárním dotazem | MeshCore |
| `meshcore_prefs` | `get`/`set` klíčů; `freq`, `radio`, hesla a klíč odmítne | MeshCore |
| `meshcore_prefs` | `get`/`set` klíčů, typ, rozsah a krok známých klíčů ověří před odesláním; navíc `gps` (off/on/duty), `gps.period`, `gps.firstfix`, `powersaving`. `freq`, `radio`, hesla, klíč a ne-trvalé klíče odmítne | MeshCore (`gps duty`, `radio.silence`: meshcore-tth) |
| `meshcore_region` | strom regionů, domovský region, default scope, `region save` | MeshCore 1.10+ |
| `meshcore_fw_facts` | jen čte: verze z `ver` a odchylka hodin uzlu | MeshCore |
| `meshcore_companion_acl` | "remote CLI" příznak kontaktů na companionu, přes jeho BLE | MeshCore 1.18+ |
@@ -118,9 +118,19 @@ Admin heslo patří do ansible-vault (`vault_meshcore_admin_password`).
- **Uložené prefs přebíjejí výchozí hodnoty buildu.** Jiný uzel z téže várky
může mít jiné admin heslo; login pak projde jen jako host.
- **Jednotky advert intervalů:** `advert.interval` je v **minutách**,
`flood.advert.interval` v **hodinách** (3–168). Hodnotu mimo rozsah uzel
odmítne a modul selže — nikdy po něm nezůstane tiché `OK`.
- **Jednotky advert intervalů:** `advert.interval` je v **minutách** (0 nebo
60–240, sudé — uzel ukládá polovinu, 25 by přečetl jako 24),
`flood.advert.interval` v **hodinách** (0 nebo 3–168). `meshcore_prefs`
takovou hodnotu odmítne dřív, než cokoli pošle.
- **Odpověď na `get` není vždycky holá hodnota:** `radio.silence` →
`30 min (now x1), quiet …`, `batt.icon` → `on (level 3/5, …)`, `dutycycle` →
`50.0%`. Známé klíče (`plugins/module_utils/meshcore_prefspec.py`, ze zdrojáků
CLI meshcore-tth) z ní hodnotu vyčtou; neznámý klíč modul porovná jako text
a varuje. `set repeat <cokoli kromě off>` znamená na uzlu ON — modul proto
bere jen on/off/true/false.
- **`lat`/`lon` porovnává modul na ~1 m** (na uzlu jsou `float32`). Dřív to
bylo 0,001° (~100 m) a menší posun se nikdy nepropsal; zaokrouhlená hodnota
v inventáři teď uzel jednou přesune na ni.
- **Heslo nikdy přes heredoc s rourou** (`echo heslo | python - <<EOF`): stdin
je heredoc, roura se zahodí a uzel dostane prázdné heslo.
- **Region bez `region save`** zmizí rebootem; modul ukládá sám. Výpis stromu