Files
meshcore-tth/docs/tth-commands.md
T
tthandClaude Opus 5.5 b984310572 Repeater, room server, sensor: an INA226 in the battery line counts the charge drawn and charged (sensor set ina.coulomb 1)
Changelog-cs: Repeater, room server, sensor: INA226 v přívodu baterie umí počítat náboj z baterie a do ní (`sensor set ina.coulomb 1`)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 18:37:42 +01:00

357 lines
23 KiB
Markdown

# Console commands of this fork (meshcore-tth)
> [!WARNING]
> Part of an experimental fork, not meant for regular users: its releases are
> a rolling release on MeshCore `dev` (see the [README](../README.md)).
Everything this fork adds to the text console of a node, on top of upstream's
[cli_commands.md](cli_commands.md). Where a command is described there too
(the watchdogs, `rxps`, `batt.icon`, `gps duty`, `dfu`, `get boot`), this page
gives the short form and points to it.
**How commands are written** (as in cli_commands.md): `<value>` is required,
`[value]` optional, `<on|off>` one of the listed words. One command per line;
ranges, units and defaults are in the description.
**Where a command exists** depends on the role and on build flags:
| mark | builds |
|---|---|
| all | repeater, room server and sensor -- every build with a text console |
| repeater | `simple_repeater` builds |
| observer | the `*-observer` variants of the nRF52 repeaters in the releases (`MAX_HEARD_NODES`, `RXLOG_SIZE`, `PKTFEED_SIZE`, `BLE_PIN_CODE`) |
| own build | only with the named flag -- not in the releases |
**Where it can be sent from:** the USB console, the BLE console (observer
variants) and the mesh, as admin in the remote CLI of an app -- unless the
entry says *local only*. Replies over the mesh are cut to one packet (~150 B).
## Antispam (repeater)
Forwarding only: what this node hears, logs and feeds to an observer is never
affected. Everything is persisted in prefs, so a reboot keeps it.
### FairnessLimiter -- `fairness`
Token buckets on forwarded floods, keyed on the 1-byte ids already in the
clear: channel hash, sender hash, advert origin. Buckets collide (the hash is
masked), and every key is chosen by the sender: it contains runaway floods,
it is not security. Direct-routed traffic is never limited.
| command | what |
|---|---|
| `fairness` | state, denials per category, caps and refill intervals |
| `fairness <on\|off>` | the buckets on or off. Default: on (`FAIRNESS_ENABLED_DEFAULT`) |
| `fairness cap <group> <sender> <advert>` | burst caps, 0..255 each; `0` = build default (100 / 150 / 30) |
| `fairness refill <group> <sender> <advert>` | one token per interval, seconds, 0..65535 each; `0` = build default (30 / 10 / 600) |
| `fairness grid` | the busiest denied buckets per category -- what is being shed |
| `fairness air` | estimated airtime shed per reason |
| `fairness advert` | the per-origin advert window: hours, held adverts, cache |
| `fairness advert <hours>` | one flood advert per origin per `hours`, 0..720; `0` = off. Default: off |
| `fairness advert clear` | forget the origins seen |
| `fairness dryrun [on\|off]` | count every verdict but forward anyway; without an argument shows the state. Default: off |
The defaults keep about twice the headroom over 30 days of CZ mesh traffic
(the zero-loss frontier was 60 s / cap 60 per channel, 10 s / 60 per sender,
600 s / 12 per advert origin).
### Channel filter -- `filter`
On channels whose key the node knows (`FILTER_CHANNEL_PSKS`; the releases
know Public, `#meshcore` and `#test`) the node decrypts each group text and
refuses to forward listed senders. The sender name is plain text in the
message: anyone can rename around it.
| command | what |
|---|---|
| `filter [list]` | channels known, drops, the deny list |
| `filter add <name>` | deny a sender name: exact, case-insensitive; spaces allowed, commas not |
| `filter del <name>` | remove a name from the deny list |
| `filter clear` | empty the deny list |
### Forward-deny rules -- `filter flow` (every repeater)
One table of keyless rules (max 24) that replaces the former `filter hash` and
`filter path` (both remain as aliases, below). A rule makes this node not
re-air a matching **flood** packet; reception, rxlog and the pktfeed are
unaffected. Match is on what is in the clear:
| kind | key (hex) | matches |
|---|---|---|
| `c` | 1 B channel byte | GRP_TXT / GRP_DATA. One byte is coarse: every other channel hashing to it is hit as well |
| `r` | `dest src` (2 B), optionally + first hop (4 B); or `src first-hop` (3 B), **any destination** | REQ / RESPONSE / TXT_MSG / PATH |
| `n` | `dest` (1 B), optionally + first hop (3 B) | ANON_REQ (login flood) |
| `a` | pubkey prefix, 4-8 B | ADVERT |
| `p` | relay pubkey prefix, 2-4 B | any hop of the path (a hop matches on the shorter of its width and the entry) |
The 3-byte `r` form is `src` (1 B) + first hop (2 B): `payload[1] == src` and the
path's first hop equals the two hop bytes, whatever the destination. One
requester asking many destinations through the same first relay thus takes one
entry instead of one per destination. The 2 B and 4 B forms are unchanged.
"First hop" is the 2-byte hash at the start of the path. **0-hop packets and
1-byte hops never match a rule that has it**, and kind `p` never matches a
1-byte hop (one byte is shared by most repeaters of a mesh).
Per entry: a mode, a flag, counters and an optional expiry.
* mode `block` (default), `throttle <s>` (1..65535: one packet per `s`
seconds passes, the rest is dropped; the window is RAM, the first match after
a boot passes) or `dry` (count only, never drops);
* flag `auto`: set by an agent, as opposed to static (inventory / by hand);
`clear` and the CRCs treat the two sets separately;
* counters `dropped` / `passed` (RAM, gone at reboot; `passed` counts throttle
passes, `dropped` of a `dry` entry counts what it WOULD have dropped; of
several matching rules only the first dropping one is charged);
* expiry `ttl <s>` (1..2000000, from now) or `expires <unix>`: an expired
entry is **removed**. The entry carries the absolute time AND the seconds
that were left when it was last written (written only on add/change, never
periodically); after a boot the entry ends at whichever comes first: the
absolute time (only while the node clock reads 2026 or later) or the
countdown of the saved seconds from boot. A cold start without GPS has a
clock behind by the age of the build, so the absolute time alone would
extend a block. `expires` with no valid clock is stored without a countdown
and can then end only by the absolute time.
| command | what |
|---|---|
| `filter flow add <kind> <hex> [block\|throttle <s>\|dry] [auto] [ttl <s>\|expires <unix>]` | add; the same key again changes the entry (counters kept) |
| `filter flow del <kind> <hex>` | remove one entry |
| `filter flow clear auto\|static\|all` | remove a set |
| `filter flow [list [page]]` | paged list |
Entries are kept **sorted by (kind, key)** -- kind as its ASCII letter, key
bytewise, a shorter key before a longer one it prefixes. The index in that
order is the `slot_id` and **moves on add/del/expiry**. A rule is a veto, not a
route: with several matches any dropping rule drops the packet, and a throttle
window is only spent by a packet that nothing else vetoes.
`add`, `del` and `clear` reply (machine format, one line):
OK <add|change|same|del|clear> n=<total> a=<n>:<crc16> s=<n>:<crc16>
`a=` is the number of `auto` entries and the CRC of that set, `s=` the same for
the static set; `crc16` is 4 upper-case hex digits. Errors start with `Err -`.
CRC-16/CCITT-FALSE (poly 0x1021, init 0xFFFF, no reflection, no final XOR)
over the entries of one set in sorted order, each serialized as
`kind(1, ASCII) klen(1) key(klen) mode(1: 0 block, 1 throttle, 2 dry)
throttle_secs(2, big endian, 0 unless throttle) expires(4, big endian, 0 = none)`.
Counters, the remaining seconds and the `auto` flag are not part of it; an
empty set is `FFFF`. Test vectors and a Python reference:
`test/vectors/flow_rules_vectors.json`, `test/vectors/gen_flow_rules_vectors.py`.
`list` replies are at most 149 characters (the RF reply limit is 150 B):
flow <page>/<of> n=<total> a=<n>:<crc16> s=<n>:<crc16> <entry> <entry> ...
<entry> = <kind><hex>,<mode>,<A|S>,<dropped>/<passed>,<left>
<mode> = B | T<secs> | D <left> = seconds to expiry, or -
Entries are separated by a space, fields by a comma. Up to 4 entries a page,
fewer when long keys would not fit; the packing depends only on the rules (it
budgets the counters at their maximum), never on the counters, so `of` stays
put while counters tick. Displayed counters are capped at 99999. An empty
table: `flow 1/1 n=0 a=0:FFFF s=0:FFFF`. A page out of range:
`Err - page 1..<of>`. The reader fetches page 1, then 2..`of`; if `n` or a
CRC differs between pages the table changed meanwhile -- start again.
`filter dryrun on` forces every verdict (flow, age, sender) to count-only.
Persisted in prefs (keys `f_fl0`..`f_fl15`). At the first boot after an update
the old `f_dhash*` / `f_dpath*` entries are moved into the table as static
kind `c` / `p` rules and the old fields are cleared (downgrading afterwards
loses them).
#### Aliases `filter hash` and `filter path`
Kept so existing configuration and the Ansible module `meshcore_filter_hash`
keep working; they act on static kind `c` / `p` entries.
| command | what |
|---|---|
| `filter hash [list]` | `filter hash: dropped N, passed M, deny: 43 2E/60` -- sums of the kind-`c` counters; `43` blocked, `43/60` throttled, `43/dry` dry |
| `filter hash add <hex> [secs]` | `filter flow add c <hex> [throttle <secs>]`; no `secs` / 0 = block; re-adding changes the interval |
| `filter hash del <hex>` / `clear` | remove one byte / all STATIC `c` entries |
| `filter path [list]` | `filter path: dropped N, deny: c420 5f14c420` |
| `filter path add <hex>` | `filter flow add p <hex>` (2-4 bytes = 4-8 hex digits) |
| `filter path del <hex>` / `clear` | remove one entry / all STATIC `p` entries |
The table is shared: 24 entries in all (it was 16 before; prefs records
`f_fl0..f_fl23`), where `filter hash` had 8 and `filter path` 8. The list order is now the sorted order, not the order of adding.
### Message age -- `filter age` (repeater with channel keys)
| command | what |
|---|---|
| `filter age` | the limit and how many were dropped |
| `filter age <minutes>` | do not forward a group text on a decrypted channel whose sender timestamp is older than `minutes` (1..10080) by this node's clock |
| `filter age off` | no age limit. Default: off |
It judges the sender's clock, so a companion that never got a time sync (it
stamps 2024) is dropped too -- keep it in days. Inactive while the node's own
clock reads before 2026; a clock running ahead makes everything look old.
### Dry run -- `filter dryrun`
| command | what |
|---|---|
| `filter dryrun [on\|off]` | count every `filter` verdict (sender, flow, age) but forward anyway -- try a rule on a live node before it bites; without an argument shows the state. Default: off |
## Stats bundle -- one request per scrape (repeater)
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
everything, a guest what `GET_STATUS` gives. Byte format, ids, paging, the
pairing rule for `slot_id` and the `prefs_crc16` field list:
[stats-bundle.md](stats-bundle.md).
## Radio watchdogs and board upkeep (all)
Details: [cli_commands.md](cli_commands.md), "Radio silence watchdog", "TX
stall watchdog", "Reboot into the bootloader" and "Why the board last reset".
| command | what |
|---|---|
| `get radio.silence` | threshold, current multiplier, quiet time, stage |
| `set radio.silence <minutes>` | deaf receiver: re-arm RX, then reboot after `minutes` (1..1440) without a received frame (CRC errors count as heard); each such reboot doubles the threshold for the next boot (up to 16x), the first frame clears it. `0` or `off` = off. Saved. Default: off |
| `get radio.txstall` | threshold, queue, time without TX, stage |
| `set radio.txstall <minutes>` | repeater only: packets queued and nothing sent for `minutes` (1..1440) -> re-arm, then reboot. An empty queue never counts. `0` or `off` = off. Not saved: a reboot returns to the build value. Default: 15 (`RADIO_TXSTALL_MIN`) |
| `get radio.reboots` | reboots done by the watchdogs, survives power loss |
| `get boot` | reset reason and the hardfault record (also printed at boot) |
| `dfu [uf2\|serial\|ota]` | *local only*, nRF52: reboot into the bootloader -- UF2 drive (default), CDC port for `adafruit-nrfutil`, or BLE DFU |
| `fw <subcommand>` | `-ota` images only: admin-pushed firmware update, see [ota.md](ota.md) |
## Number arguments of `set` (all, and the companion's serial CLI)
Upstream parses the value of a `set` with `atoi()`/`atof()`: text became 0,
`300` became 44 in a one-byte setting, and the result was saved with `OK`. This
fork refuses a value that is not a number or lies outside the range and keeps
the old one (`Error, must be ...`). It applies to `set tx` (-9 up to the
board's `MAX_LORA_TX_POWER`, else 30, and saved only if the radio takes it:
SX1262 -9..22), `set radio` and `tempradio` (each field; the timeout 1-10080
min), `set freq`, `set lat`/`set lon`, `set flood.max`, `set
flood.max.unscoped`, `set flood.max.advert` (0-64), `set int.thresh` (0-255),
`set multi.acks` (0-1), `set path.hash.mode` (0-2), `set agc.reset.interval`
(0-1020), `set rxdelay`, `set txdelay`, `set direct.txdelay`, `set
adc.multiplier`, and on the companion `set pin`, `set adc.multiplier`, `set
tz.offset`. No exponent (`1e3`), no `nan`/`inf`.
## Diagnostics
| command | where | what |
|---|---|---|
| `blink [count]` | repeater | flash a spare LED (not the BLE or TX one) `count` times (1..999, default 6); finds a board on a bench or a node on a mast |
| `blink <on\|off>` | repeater | blink until `blink off` (gives up after 10 min) |
| `txpwr` | repeater | the last requested LoRa output power and RadioLib's status |
| `txpwr <dBm>` | repeater | LoRa output power until reboot, -9..30 (SX1262 takes -9..22), with RadioLib's status |
| `i2c` | all | scan the I2C bus |
| `get chip` | nRF52 (repeater, room server, sensor) | the silicon (`nRF52840 AAD0`; variant `xxF0` and later = rev3) and `UICR.APPROTECT`: `open` means SWD can read the whole flash, keys included |
| `dio1` | own build: `PIN_DIAG` | has the SX1262 raise TX_DONE and compares its IRQ register with the level on the DIO1 pin -- which end of a dead IRQ line is broken |
| `radiostat` | own build: `RADIO_DIAG` | receiver state, interrupt and RX counters, without touching the radio |
| `radiokick <rx\|clrirq\|standby\|agc>` | own build: `RADIO_DIAG` | one recovery step, gentlest first: re-arm RX, clear latched IRQs, standby + RX, AGC reset; the first that brings `recv` back names the broken layer |
A board with a dead DIO1 line still runs with `LORA_POLL_IRQ` (own build):
the IRQ status is polled over SPI.
## BLE console (observer)
The text console over BLE (Nordic UART), next to USB. No login of its own:
the BLE PIN is the only lock, and the release PIN is the public placeholder
`123456`. These commands also work as admin over the mesh.
| command | what |
|---|---|
| `ble` | on or off, PIN `own` or `build default`, connected or not -- never the PIN itself |
| `ble <on\|off>` | the BLE console on or off, saved. Default: off (`RPT_BLE_DEFAULT_OFF`); `ble on` is refused while the PIN is the placeholder |
| `ble pin` | whether the PIN is your own or the build default |
| `ble pin <pin>` | set your own PIN, 6 digits (saved, survives a reflash; drops every bond, so paired devices pair again) |
| `blepwr` | TX power of the connection and of advertising |
| `blepwr <dBm>` | TX power of the connection: -40, -20, -16, -12, -8, -4, 0, 2..8; applied to live connections and saved |
| `blepwr default` | back to the build value (0 dBm) |
| `bleconn` | what the central actually agreed to: interval (and what was requested), latency, supervision timeout |
A connected central stops the node advertising: if the BLE console cannot be
found, look for who is connected (`ble` shows it).
## Passive analyzer (observer)
| command | what |
|---|---|
| `nodes [offset]` | heard repeaters and room servers with a key to join several paths, paged from `offset` |
| `rxlog [cursor]` | every frame heard: type, path, SNR, RSSI; `cursor` from the previous page (`0` = all) |
| `pktlog [cursor]` | raw frames heard, for an observer feed ([meshcore-repeater-observer](https://git.rfa.cz/tth-pub/meshcore-repeater-observer)) |
A page is as big as the caller's reply buffer: ~1000 B on the local console,
one packet over the mesh.
## Channel bot (own build: `BOT_CHANNEL_PSK`)
A repeater that answers on one channel without forwarding anything:
`!link`, `!path`, `!snr`, `!heard`, `!noise`, `!ping`, `!help` (narrowed by
`BOT_COMMANDS`), with a per-sender cooldown and an ignore list. `bot` on the
console shows its state.
## Power and clock
| command | where | what |
|---|---|---|
| `get radio.rxps` | all, SX1262 only (`WITH_RX_POWERSAVING`, in the releases) | requested and effective RX duty cycle, window lengths, error counters |
| `set radio.rxps <off\|on\|balanced\|max>` | same | RX duty cycle: the radio sleeps between short listening windows. Presets: `on` = level 3, `balanced` = 6, `max` = 8. Saved. Default: off |
| `set radio.rxps level <level> [preamble <16\|32>]` | same | the same by number, 1..10 (9 and 10 are past the datasheet's timing condition, 10 is known to lose packets) |
| `set radio.rxps <rx_us> <sleep_us>` | same | raw window lengths |
| `get batt.icon` | all | whether the icon is on, and whether the name leaves room for it |
| `set batt.icon <on\|off>` | all | battery level as an icon at the end of the advertised name; with a name too long for it the icon is left out, and the reply says so. Default: off |
| `set batt.icon.lo <mV>` | all | the empty end of the icon's scale, 2500..4500; `0` = build default (3300) |
| `set batt.icon.hi <mV>` | all | the full end, 2500..4500; `0` = build default (4200) |
| `gps duty` | GPS boards | the receiver runs only around a clock sync; `gps on` / `gps off` leave it. See cli_commands.md |
| `get pwr` | all | battery now, adaptive power-save thresholds/state; on `PWRMGT_RUNTIME` boards also bootlock, cutoff, boot voltage and last shutdown reason |
| `set pwr.rxgain <lo> [hi]\|off` | all | disable SX126x RX boosted gain below `lo` mV (3 readings, 1/min), restore at `hi` mV (default `lo + 150`, min hysteresis 50 mV); does not overwrite `radio.rxgain` pref. Saved in `/pwr_save`. Default: off |
| `set pwr.rxps <lo> [hi]\|off` | all (`WITH_RX_POWERSAVING`) | enable RXPS `balanced` below `lo` mV, restore continuous RX at `hi` mV (skipped if `radio.rxps` was enabled manually). Saved in `/pwr_save`. Default: off |
| `set pwr.bootlock <mV>` | SenseCAP Solar repeater (`PWRMGT_RUNTIME`) | do not start below this voltage, 3000..4200 or `off`; saved on the node, see [power.md](power.md) |
| `set pwr.cutoff <mV>` | same | switch a running node off below this voltage, 3000..4200 or `off`. Must stay under the bootlock; neither may be above the battery right now |
| `bench batt [mV\|off\|poll]` | own build (`BENCH_BATT_OVERRIDE`), local only | override battery voltage for adaptive power-save testing (simulates battery without USB; `poll` triggers one sample immediately) |
| `clkreboot` | all | reset the clock to the build epoch and reboot -- the only way to move a clock backwards (`time` and `clock sync` refuse to) |
RX duty cycle: `max` saved ~2.3 mA on the bench, but a mast on the live mesh
lost 16 % of its reception -- see cli_commands.md and [power.md](power.md).
## Sensors
| command | what |
|---|---|
| `sensor read` | the live telemetry decoded into one line (`sensor list` shows only settings) |
| `sensor get ina.shunt` | the shunt the current is computed with |
| `sensor set ina.shunt <mOhm>` | shunt resistance of an INA219, INA226 or INA3221 module (`10` for `R010`), saved; `0` = build default (100). The INA260 has its shunt inside and no setting |
| `sensor set ina.coulomb 1\|0` | an INA226 in the battery line as a charge counter: converts continuously (~8.6 s averages) and counts mAh drawn / charged since boot (stats bundle ids 22/23, exporter `meshcore_battery_charge_{out,in}_mah_total`). Saved; off by default. Costs the INA226's own ~0.33 mA |
## Build flags
The ones that change what a node does; set in `platformio.ini` /
`platformio.local.ini` (`-D NAME=value`, the last `-D` wins).
| flag | default | what |
|---|---|---|
| `FAIRNESS_ENABLED_DEFAULT` | `1` | FairnessLimiter on for a node without prefs |
| `RADIO_SILENCE_MIN_DEFAULT` | `0` | deaf-receiver watchdog for a node without prefs |
| `RADIO_TXSTALL_MIN` | `15` | TX stall watchdog at boot (repeater), `0` = off |
| `FILTER_CHANNEL_PSKS` | releases: Public, `#meshcore`, `#test` | channel keys the filter can decrypt |
| `MAX_HEARD_NODES`, `RXLOG_SIZE`, `PKTFEED_SIZE` | `0` (observer variants: 128 / 512 / 64) | the analyzer rings |
| `BLE_PIN_CODE`, `RPT_BLE_DEFAULT_OFF` | observer variants | BLE console, starting off |
| `BOT_CHANNEL_PSK`, `BOT_COMMANDS` | unset | channel bot |
| `RADIO_DIAG`, `PIN_DIAG`, `LORA_POLL_IRQ` | unset | radio diagnostics, DIO1-less operation |
| `FW_OTA` | `-ota` images | admin-pushed firmware update |
| `PATH_HASH_MODE_DEFAULT` | `1` (2 B per hop) | path hash width for a node without prefs |
| `ACL_TS_MAX_AHEAD` | `86400` (s) | a client timestamp further ahead of the node's clock is not stored as the replay floor |
| `LOCKED_NODE` | unset | a node that keeps its secrets from whoever holds it: `get prv.key`, `get guest.password` and `get bridge.secret` answer `Error: locked build` to everyone (USB and BLE console, an admin over the mesh); a companion serves only paired BLE (USB, UART and WiFi get the device info and nothing else) and its rescue CLI refuses `set pin`. Only half of it: whoever can rewrite the flash (SWD with `APPROTECT` open, an unsigned DFU) still gets the keys -- the other half is a locked bootloader (SWD closed, signed images only), which these builds do not have |
| `LOGIN_FAIL_MAX`, `LOGIN_FAIL_SECS` | `4`, `180` (s) | after that many wrong passwords in the window no password is checked until it ends (an admin already in the ACL always gets in) |
| `NRF52_POWER_MANAGEMENT`, `PWRMGT_RUNTIME` | upstream: off; on in `SenseCap_Solar_repeater` (the masts) | boot protection, and with `PWRMGT_RUNTIME` the runtime `pwr.bootlock` / `pwr.cutoff` above |
| `PWRMGT_BOOTLOCK_DEFAULT`, `PWRMGT_CUTOFF_DEFAULT` | `PWRMGT_VOLTAGE_BOOTLOCK` (SenseCAP 3300), `0` (mV) | thresholds for a node without `/pwr_guard` |
| `NRF52_TICKLESS_MAX_MS` | `50` (ms) | nRF52 with `powersaving on`: the longest the main loop blocks between wake-ups (the DIO1 interrupt wakes it at once); `0` = the old `sd_app_evt_wait()` loop that wakes with every 1024 Hz tick. See [power.md](power.md) |
| `BENCH_BATT_OVERRIDE` | unset | bench only: `bench batt <mV|off|poll>` overrides the battery reading of the adaptive power saving (`pwr.rxgain` / `pwr.rxps`; not `pwr.cutoff`) |
| `PWR_DUTY_INSTRUMENT` | unset | bench only, nRF52: every ~10 s a `PWRDUTY` line on the USB console with the time the MCU was awake and asleep, its wakes, and the CPU time spent on received packets. See [power.md](power.md#cpu-time-per-received-packet-pwr_duty_instrument) |
Prefs saved on the node override the build defaults: a reflash keeps what a
node already has; only a new node or one after `erase` takes them.