Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3135db3aa9 | ||
|
|
b3ff2870b0 | ||
|
|
e2d3c72ba2 | ||
|
|
44da986315 | ||
|
|
e896244524 | ||
|
|
4c51188ee5 | ||
|
|
89a35a6dff | ||
|
|
b452c60434 | ||
|
|
11eab55198 | ||
|
|
7fb9bf0806 | ||
|
|
d31edee091 | ||
|
|
6e5b19eb25 | ||
|
|
ff733ccdee | ||
|
|
1306db07ab | ||
|
|
49ad809016 | ||
|
|
21e22caa61 | ||
|
|
0ec1c208d8 | ||
|
|
cc02dc28e4 | ||
|
|
faa947f3b7 | ||
|
|
a038ccf78a | ||
|
|
d80a7aa71a | ||
|
|
726a618483 | ||
|
|
31ec0825fa | ||
|
|
0143e21875 |
No files matched your search
@@ -18,7 +18,7 @@ jobs:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: gitleaks
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/gitleaks@v11
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/gitleaks@v15
|
||||
with:
|
||||
mode: block
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Trivy config
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v11
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v15
|
||||
with:
|
||||
scan-type: fs
|
||||
scanners: misconfig
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
docker run --rm --platform "linux/${{ matrix.arch }}" "$img" --help | grep -q -- --repeaters
|
||||
|
||||
- name: Trivy gate
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v11
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v15
|
||||
with:
|
||||
image: ${{ env.IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
|
||||
username: ${{ gitea.actor }}
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Dependencies in the tree
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v11
|
||||
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v15
|
||||
with:
|
||||
scan-type: fs
|
||||
mode: warn
|
||||
@@ -11,9 +11,9 @@ README.md has the full reference. This file is the procedure and the rules.
|
||||
`set radio`, `advert`, `reboot`, `erase` or any other CLI command to a
|
||||
node, with meshcli or anything else. A repeater is part of a community
|
||||
network; a wrong setting breaks routing for other people.
|
||||
2. **Keep the default interval (3600 s).** Shorter only if the user explicitly
|
||||
2. **Keep the default interval (28800 s, 8 h).** Shorter only if the user explicitly
|
||||
asks for it and understands it costs shared airtime (point them to
|
||||
https://meshcore.repeater.cz/nastaveni/telemetrie/). Never below 900 (the
|
||||
https://meshcore.repeater.cz/nastaveni/telemetrie/). Never below 3600 (the
|
||||
program refuses).
|
||||
3. **Passwords** go into `stack/.env` or `repeaters.toml` only (both are
|
||||
git-ignored), never into a command you print, a commit, a log or an
|
||||
@@ -35,9 +35,20 @@ README.md has the full reference. This file is the procedure and the rules.
|
||||
README section 3 (a dedicated companion identity over TCP). Changing their
|
||||
openHop config.yaml is a change to their node: show the block, let them
|
||||
apply it.
|
||||
2. USB companion: `ls -l /dev/serial/by-id/`. Use the by-id path, never
|
||||
`/dev/ttyACM0` (it changes after a replug). Its group:
|
||||
`stat -c '%G %g' <that path>`.
|
||||
One companion they also use from a phone app, no openHop: README section 4
|
||||
(coresplitter shares it). It must be built from source; offer it, do not
|
||||
install a Rust toolchain without asking.
|
||||
**Find out the operating system first.** Docker Desktop on macOS and
|
||||
Windows cannot pass a USB device into a container: there, use section 2
|
||||
(pipx) for the exporter, never the Docker stack with a USB board.
|
||||
WSL2 needs the board attached with usbipd-win first.
|
||||
2. USB companion: `meshcore-exporter --list-ports` (any OS; installed with
|
||||
pipx, or `python3 meshcore_exporter.py --list-ports` from the checkout).
|
||||
On Linux use the `/dev/serial/by-id/...` path it prints, never
|
||||
`/dev/ttyACM0` (it changes after a replug); its group:
|
||||
`stat -c '%G %g' <that path>`. macOS: `/dev/cu.usbmodem...`, Windows:
|
||||
`COMn`. Not listed = not plugged in, a charge-only cable, or (VM/WSL) not
|
||||
passed through: say so, do not guess another port.
|
||||
3. Ask for the repeater name exactly as it appears in the MeshCore app, and
|
||||
its admin or guest password (MeshCore uses only the first 15 characters).
|
||||
4. Fill `stack/.env` from `stack/.env.example` (or a `repeaters.toml`).
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM python:3.15-slim@sha256:8c13a3f37a6a5b71498228e902c4b9f51c1f7900d49fabf71f9a650c6120e0d0
|
||||
FROM python:3.15-slim@sha256:65a65fc7b30b06cb6df4930fd4650697cb23f4c2698ab81fc87e4b031bc36928
|
||||
|
||||
# Re-runs the security-update layer once a day despite the layer cache (CI
|
||||
# passes the date).
|
||||
|
||||
@@ -11,18 +11,28 @@ repeater ))) mesh ((( companion rádio ── USB ── meshcore-exporter ─
|
||||

|
||||
|
||||
Companion rádio (libovolná MeshCore deska s companion firmwarem, připojená
|
||||
k počítači) se jednou za hodinu přihlásí na repeater, vyžádá si stav
|
||||
k počítači) se jednou za 8 hodin přihlásí na repeater, vyžádá si stav
|
||||
a telemetrii přímými pakety a exportér to vystaví na `:9200/metrics`.
|
||||
|
||||
> [!WARNING]
|
||||
> **Každé čtení vysílá do sdíleného éteru.** Jedno čtení repeateru zabere
|
||||
> zhruba 0,8 s kanálu, o který se dělí všichni v okolí, a v tu chvíli
|
||||
> nikdo jiný nevysílá. Proto exportér čte jednou za 8 hodin a pod hodinu
|
||||
> nejde. Interval nezkracujte bez opravdového důvodu: baterie, teplota ani
|
||||
> šum se za pár minut nezmění. Víc v sekci [Kolik to stojí éteru](#kolik-to-stojí-éteru).
|
||||
|
||||
*English: a Prometheus exporter that logs in to MeshCore repeaters over the
|
||||
mesh from a companion radio (USB, TCP or BLE) and exports status and
|
||||
telemetry. Docs below are Czech; `meshcore-exporter --help` is English.*
|
||||
telemetry. Every reading costs ~0.8 s of a shared channel, hence one reading
|
||||
per 8 hours by default and never more often than hourly. Docs below are
|
||||
Czech; `meshcore-exporter --help` is English.*
|
||||
|
||||
| Mám… | Čtěte |
|
||||
|---|---|
|
||||
| nic, chci hotovou Grafanu | [1. Kompletní stack (Docker)](#1-kompletní-stack-docker) |
|
||||
| vlastní Prometheus a Grafanu | [2. Jen exportér](#2-jen-exportér) |
|
||||
| openHop (repeater nebo observer) a nechci kvůli tomu obětovat desku | [3. Bez vyhrazené desky: openHop](#3-bez-vyhrazené-desky-openhop) |
|
||||
| jeden companion a chci ho dál používat i z telefonu | [4. Sdílený companion: coresplitter](#4-sdílený-companion-coresplitter) |
|
||||
| AI agenta, který to rozjede za mě | dejte mu tohle repo; pravidla pro něj jsou v [AGENTS.md](AGENTS.md) |
|
||||
|
||||
## Co je potřeba
|
||||
@@ -39,7 +49,25 @@ telemetry. Docs below are Czech; `meshcore-exporter --help` is English.*
|
||||
- **Rádio nesmí mít zároveň připojenou jinou aplikaci** (telefon, Meshy,
|
||||
meshcli). Companion obslouží jen jednoho klienta; vyhrazená deska je
|
||||
nejjednodušší.
|
||||
- Linux (amd64 nebo arm64). Docker pro variantu 1, Python 3.10+ pro variantu 2 (soubor `--config` chce 3.11+).
|
||||
- Počítač, na kterém exportér poběží (cesta podle systému níž).
|
||||
- Python 3.10+ pro variantu 2 (soubor `--config` chce 3.11+).
|
||||
|
||||
### Podle systému
|
||||
|
||||
| systém | doporučená cesta | port companionu |
|
||||
|---|---|---|
|
||||
| Linux, Raspberry Pi (64bit) | [1. Docker stack](#1-kompletní-stack-docker) | `/dev/serial/by-id/usb-…` |
|
||||
| macOS | [2. Jen exportér](#2-jen-exportér) přes `pipx`, Prometheus a Grafana zvlášť | `/dev/cu.usbmodem…` |
|
||||
| Windows | [2. Jen exportér](#2-jen-exportér) přes `pipx`, Prometheus a Grafana zvlášť | `COM3` apod. |
|
||||
| Windows s WSL2 | jako Linux, desku do WSL předejte přes [usbipd-win](https://learn.microsoft.com/windows/wsl/connect-usb) | `/dev/ttyACM0` |
|
||||
| cokoli s openHopem | [3. Bez vyhrazené desky](#3-bez-vyhrazené-desky-openhop) | žádný, TCP |
|
||||
|
||||
**Docker Desktop na macOS a Windows neumí předat USB zařízení do kontejneru**,
|
||||
varianta 1 s deskou na USB tam nepojede. Který port je companion, vypíše na
|
||||
každém systému `meshcore-exporter --list-ports` (popis desky, USB ID, sériové
|
||||
číslo; na Linuxu i trvalé jméno z `/dev/serial/by-id/`, které se po
|
||||
přepojení nezmění, na rozdíl od `/dev/ttyACM0`). Na Linuxu je ověřené vše,
|
||||
na macOS a Windows zatím ne; hlášení, jak to dopadlo, je vítané.
|
||||
|
||||
## 1. Kompletní stack (Docker)
|
||||
|
||||
@@ -53,15 +81,18 @@ docker compose up -d
|
||||
docker compose logs -f exporter # čekejte na "OK bat=…"
|
||||
```
|
||||
|
||||
Jen Linux (včetně Raspberry Pi a WSL2 s usbipd): na macOS a Windows Docker
|
||||
desku do kontejneru nepředá, tam použijte [2.](#2-jen-exportér).
|
||||
|
||||
Grafana poběží na `http://<počítač>:3000` (uživatel `admin`, heslo
|
||||
z `.env`), dashboard **MeshCore — repeater** je domovská stránka. První
|
||||
čísla jsou tam do minuty, grafy rychlostí (duty cycle, trend baterie) se
|
||||
naplní za pár hodin (počítají se z okna 3 h, proměnná dashboardu **Okno**).
|
||||
naplní až za den (počítají se z okna 24 h, proměnná dashboardu **Okno**).
|
||||
|
||||
Data drží Prometheus 400 dní (`PROMETHEUS_RETENTION` v `.env`).
|
||||
Aktualizace: `docker compose pull && docker compose up -d`. Stack jede na
|
||||
`latest`; na konkrétní verzi z [Releases](https://git.rfa.cz/tth-pub/meshcore-exporter/releases)
|
||||
ho připnete řádkem `MC_VERSION=1.0.0` v `.env`.
|
||||
ho připnete řádkem `MC_VERSION=1.0.1` v `.env`.
|
||||
|
||||
## 2. Jen exportér
|
||||
|
||||
@@ -69,10 +100,16 @@ Z Pythonu:
|
||||
|
||||
```bash
|
||||
pipx install git+https://git.rfa.cz/tth-pub/meshcore-exporter
|
||||
meshcore-exporter --list-ports # který port je companion
|
||||
meshcore-exporter --serial /dev/serial/by-id/usb-… --repeaters muj-rpt --password … --check
|
||||
meshcore-exporter --serial /dev/serial/by-id/usb-… --repeaters muj-rpt --password …
|
||||
```
|
||||
|
||||
Na macOS je port `/dev/cu.usbmodem…`, na Windows `COM3` apod. (podle
|
||||
`--list-ports`). Trvale spuštěný exportér tam zajistí `launchd`, resp. Plánovač
|
||||
úloh, nebo služba přes [NSSM](https://nssm.cc/); Prometheus a Grafana mají
|
||||
instalátory pro oba systémy.
|
||||
|
||||
Nebo kontejner (`latest-amd64` / `latest-arm64`, nebo verze z Releases,
|
||||
např. `1.0.0-amd64`; jeden tag = jedna architektura):
|
||||
|
||||
@@ -119,7 +156,7 @@ jedna z nich, rádio sdílí s tím, co na openHopu už běží.
|
||||
node_name: "muj-exporter"
|
||||
tcp_port: 5002
|
||||
bind_address: 127.0.0.1 # companion protokol nemá heslo: jen lokálně
|
||||
tcp_timeout: 0 # exportér drží spojení i hodinu mezi čteními
|
||||
tcp_timeout: 0 # exportér drží spojení i hodiny mezi čteními
|
||||
```
|
||||
|
||||
`tcp_timeout: 0` je nutný: výchozích 120 s by spojení mezi dvěma čteními
|
||||
@@ -134,6 +171,46 @@ jedna z nich, rádio sdílí s tím, co na openHopu už běží.
|
||||
`127.0.0.1`, Grafana na `GRAFANA_PORT` jako jindy. Bez Dockeru stačí
|
||||
exportér podle [2.](#2-jen-exportér) s `--tcp 127.0.0.1:5002`.
|
||||
|
||||
## 4. Sdílený companion: coresplitter
|
||||
|
||||
Companion obslouží jen jednoho klienta, takže bez openHopu je potřeba
|
||||
buď vyhrazená deska, nebo proxy, která jedno rádio rozdělí mezi víc klientů.
|
||||
To umí [coresplitter](https://github.com/ogarcia/coresplitter) (Rust, GPL-3.0):
|
||||
připojí se k rádiu (USB, BLE nebo TCP) a na TCP ho nabídne více klientům
|
||||
najednou. Příkazy řadí do fronty a odpovědi vrací tomu, kdo se ptal; adverty
|
||||
a zprávy posílá všem; kontakty a stav drží v cache.
|
||||
|
||||
```
|
||||
companion ── USB ── coresplitter ──┬── TCP ── meshcore-exporter
|
||||
└── TCP ── aplikace v telefonu (Wi-Fi/TCP připojení)
|
||||
```
|
||||
|
||||
1. coresplitter zatím nevydává hotové binárky ani obrazy, je potřeba si ho
|
||||
přeložit (Rust ≥ 1.85):
|
||||
|
||||
```bash
|
||||
git clone https://github.com/ogarcia/coresplitter.git && cd coresplitter
|
||||
cargo build --release
|
||||
./target/release/coresplitter --serial /dev/serial/by-id/usb-… --tcp-frontend-port 5000
|
||||
```
|
||||
|
||||
Frontend poslouchá výchozí na `0.0.0.0`. Companion protokol nemá heslo,
|
||||
takže kdo se k portu dostane, může přes rádio posílat zprávy: na telefon
|
||||
v domácí síti ho nechte jen tam (firewall), jinak `--tcp-frontend-host 127.0.0.1`.
|
||||
2. Exportér na něj jako na TCP companion:
|
||||
`meshcore-exporter --tcp 127.0.0.1:5000 --repeaters … --password … --check`
|
||||
(ve stacku `MC_TCP=127.0.0.1:5000` a `docker-compose.host.yml` jako u openHopu).
|
||||
|
||||
Ověřeno 2. 11. 2026 přes TCP backend: exportér přečetl repeater, zatímco
|
||||
druhý klient na stejné proxy 90 s bez chyby četl kontakty a stav. S rádiem
|
||||
na USB zatím ne. Dvě věci k vědomí:
|
||||
|
||||
- Když proxy ztratí spojení s rádiem, odpojí všechny klienty a po návratu
|
||||
rádia se připojí znovu. Exportér si to přežije (připojí se znovu za 30 s).
|
||||
- **Na openHop companion coresplitter nedávejte.** openHop pustí jen jednoho
|
||||
klienta na companion a proxy se při znovupřipojení s ostatními přetahuje.
|
||||
Tam stačí přidat další companion identitu ([3.](#3-bez-vyhrazené-desky-openhop)).
|
||||
|
||||
## Nastavení
|
||||
|
||||
Každá volba má tři podoby: přepínač, proměnnou prostředí, klíč v TOML
|
||||
@@ -148,11 +225,12 @@ Přepínač má přednost před proměnnou a ta před souborem.
|
||||
| `--repeaters` | `MC_REPEATERS` | — | `jméno[=pubkey][@cesta]`, víc přes čárku |
|
||||
| `--password` | `MC_PASSWORD` | — | heslo pro `--repeaters` |
|
||||
| `--config` | `MC_CONFIG` | — | TOML s bloky `[[repeater]]` (heslo pro každý zvlášť) |
|
||||
| `--interval` | `MC_INTERVAL` | 3600 | sekundy mezi čteními, minimum 900 |
|
||||
| `--interval` | `MC_INTERVAL` | 28800 | sekundy mezi čteními (8 h), minimum 3600 |
|
||||
| `--path-hash-bytes` | `MC_PATH_HASH_BYTES` | neměnit | šířka hashů cesty companionu; CZ mesh: 2 |
|
||||
| `--rf-timeout` | `MC_RF_TIMEOUT` | 30 | čekání na jednu odpověď |
|
||||
| `--listen`, `--port` | `MC_LISTEN`, `MC_METRICS_PORT` | 0.0.0.0, 9200 | kde vystavit metriky |
|
||||
| `--check` | — | — | přečte každý repeater jednou, vypíše hodnoty a skončí |
|
||||
| `--list-ports` | — | — | vypíše USB sériové porty (Linux, macOS, Windows) a skončí |
|
||||
|
||||
**Jméno** repeateru musí sedět s tím, co rozesílá v advertu. **Pubkey**
|
||||
je potřeba, jen když companion repeater nikdy neslyšel (pak plných 64 hex).
|
||||
@@ -178,9 +256,9 @@ Všechny mají label `node` (jméno repeateru).
|
||||
|
||||
Jedno čtení repeateru (status + telemetrie, tam i zpět) zabere na českém
|
||||
nastavení (SF7/62,5 kHz) zhruba 0,8 s kanálu, který sdílí všichni. Výchozí
|
||||
interval je hodina, tedy necelá sekunda za hodinu na repeater. Kratší interval
|
||||
interval je 8 hodin, tedy necelá sekunda za 8 hodin na repeater. Kratší interval
|
||||
přidá provoz všem okolo a nic užitečného nepřinese: baterie, teplota ani šum
|
||||
se za pár minut nezmění. Exportér pod 15 minut nejde.
|
||||
se za pár minut nezmění. Exportér pod hodinu nejde.
|
||||
|
||||
Než interval zkrátíte, zamyslete se, jak často ta data opravdu potřebujete.
|
||||
Dobře to rozebírá návod [Telemetrie, senzory, GPS](https://meshcore.repeater.cz/nastaveni/telemetrie/)
|
||||
@@ -190,13 +268,13 @@ na meshcore.repeater.cz.
|
||||
|
||||
| příznak | příčina |
|
||||
|---|---|
|
||||
| `the companion does not answer` | špatný port, rádio drží jiná aplikace, nebo na desce není companion firmware |
|
||||
| `the companion does not answer` | špatný port (`--list-ports`), rádio drží jiná aplikace, nebo na desce není companion firmware |
|
||||
| `Permission denied` na portu | uživatel/kontejner není ve skupině portu (`MC_SERIAL_GID`, `dialout`/`uucp`) |
|
||||
| `no contact '…' on the companion` | companion advert repeateru ještě neslyšel: počkejte, nebo dejte plný pubkey |
|
||||
| `login failed` | špatné heslo — **MeshCore bere jen prvních 15 znaků**, delší heslo se tiše usekne —, nebo odpověď nedoletěla |
|
||||
| jednou `login failed` / `no status reply`, pak `retrying … in 180 s` | ztracená odpověď v éteru, nebo repeater krátce po předchozím přihlášení (např. `--check`) nový login zahodil; exportér to sám zkusí znovu za 3 minuty, nic nedělejte |
|
||||
| `no status reply` | spojení jen jedním směrem: zkuste trasu přes jiný repeater (`@cesta`) |
|
||||
| prázdné nebo zubaté grafy rychlostí | počítají se z okna **Okno** (výchozí 3 h): po startu počkejte pár hodin; při jiném intervalu nastavte okno aspoň na 2–3× interval |
|
||||
| prázdné nebo zubaté grafy rychlostí | počítají se z okna **Okno** (výchozí 24 h): po startu počkejte den; při jiném intervalu nastavte okno aspoň na 2–3× interval |
|
||||
|
||||
Podrobný log: `--log-level DEBUG`.
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ panels = [
|
||||
0,
|
||||
"time() - meshcore_last_scrape_success_timestamp{SEL}",
|
||||
"s",
|
||||
steps((None, "green"), (4000, "yellow"), (7500, "red")),
|
||||
"Kdy naposledy uzel odpověděl. Při výchozím intervalu 1 h je normál do ~3600 s.",
|
||||
steps((None, "green"), (30000, "yellow"), (58000, "red")),
|
||||
"Kdy naposledy uzel odpověděl. Při výchozím intervalu 8 h je normál do ~28800 s.",
|
||||
),
|
||||
stat(
|
||||
5, "Fronta TX", 16, 0, "meshcore_queue_length{SEL}", "none", steps((None, "green"), (3, "yellow"), (8, "red"))
|
||||
@@ -346,12 +346,14 @@ dashboard = {
|
||||
"name": "window",
|
||||
"label": "Okno",
|
||||
"type": "custom",
|
||||
"query": "1h,3h,6h,12h",
|
||||
"current": {"text": "3h", "value": "3h"},
|
||||
"options": [{"text": w, "value": w, "selected": w == "3h"} for w in ("1h", "3h", "6h", "12h")],
|
||||
"query": "1h,3h,6h,12h,24h,48h",
|
||||
"current": {"text": "24h", "value": "24h"},
|
||||
"options": [
|
||||
{"text": w, "value": w, "selected": w == "24h"} for w in ("1h", "3h", "6h", "12h", "24h", "48h")
|
||||
],
|
||||
"hide": 0,
|
||||
"description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, "
|
||||
"takže okno má být aspoň 2–3× interval čtení (výchozí 1 h → 3h).",
|
||||
"takže okno má být aspoň 2–3× interval čtení (výchozí 8 h → 24h).",
|
||||
},
|
||||
{
|
||||
"name": "node",
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
"name": "window",
|
||||
"label": "Okno",
|
||||
"type": "custom",
|
||||
"query": "1h,3h,6h,12h",
|
||||
"query": "1h,3h,6h,12h,24h,48h",
|
||||
"current": {
|
||||
"text": "3h",
|
||||
"value": "3h"
|
||||
"text": "24h",
|
||||
"value": "24h"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
@@ -55,7 +55,7 @@
|
||||
{
|
||||
"text": "3h",
|
||||
"value": "3h",
|
||||
"selected": true
|
||||
"selected": false
|
||||
},
|
||||
{
|
||||
"text": "6h",
|
||||
@@ -66,10 +66,20 @@
|
||||
"text": "12h",
|
||||
"value": "12h",
|
||||
"selected": false
|
||||
},
|
||||
{
|
||||
"text": "24h",
|
||||
"value": "24h",
|
||||
"selected": true
|
||||
},
|
||||
{
|
||||
"text": "48h",
|
||||
"value": "48h",
|
||||
"selected": false
|
||||
}
|
||||
],
|
||||
"hide": 0,
|
||||
"description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, takže okno má být aspoň 2–3× interval čtení (výchozí 1 h → 3h)."
|
||||
"description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, takže okno má být aspoň 2–3× interval čtení (výchozí 8 h → 24h)."
|
||||
},
|
||||
{
|
||||
"name": "node",
|
||||
@@ -304,11 +314,11 @@
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 4000
|
||||
"value": 30000
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 7500
|
||||
"value": 58000
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -338,7 +348,7 @@
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"description": "Kdy naposledy uzel odpověděl. Při výchozím intervalu 1 h je normál do ~3600 s."
|
||||
"description": "Kdy naposledy uzel odpověděl. Při výchozím intervalu 8 h je normál do ~28800 s."
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
|
||||
+35
-4
@@ -7,7 +7,7 @@ on http://<listen>:9200/metrics: battery, temperature, noise floor, RSSI/SNR,
|
||||
packet counters, airtime, uptime, TX queue.
|
||||
|
||||
Every reading costs airtime on a shared channel (~0.8 s per repeater on the
|
||||
Czech preset), so the interval defaults to an hour and cannot go below 15 minutes.
|
||||
Czech preset), so the interval defaults to 8 hours and cannot go below an hour.
|
||||
How often do you really need the numbers? See
|
||||
https://meshcore.repeater.cz/nastaveni/telemetrie/
|
||||
|
||||
@@ -33,10 +33,10 @@ import time
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
__version__ = "1.0.0"
|
||||
__version__ = "1.1.0"
|
||||
|
||||
MIN_INTERVAL = 900
|
||||
DEFAULT_INTERVAL = 3600
|
||||
MIN_INTERVAL = 3600
|
||||
DEFAULT_INTERVAL = 28800
|
||||
# A failed repeater is retried once after this, not after the full interval:
|
||||
# a lost reply on air is common, and a repeater also drops a login whose
|
||||
# timestamp is not newer than the last one from the same client (replay
|
||||
@@ -161,6 +161,7 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
p.add_argument(
|
||||
"--check", action="store_true", help="read every repeater once, print the values and exit (0 = all answered)"
|
||||
)
|
||||
p.add_argument("--list-ports", action="store_true", help="list the serial ports of this computer (any OS) and exit")
|
||||
p.add_argument("--log-level", default=env("MC_LOG_LEVEL", "INFO"), help="[MC_LOG_LEVEL]")
|
||||
p.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
||||
return p
|
||||
@@ -546,9 +547,39 @@ def _i(v: float | None) -> str:
|
||||
return "?" if v is None else f"{v:.0f}"
|
||||
|
||||
|
||||
def list_ports() -> int:
|
||||
"""Serial ports with what identifies the board: Linux, macOS and Windows alike.
|
||||
|
||||
On Linux the stable /dev/serial/by-id/ name is shown too: /dev/ttyACM0 may
|
||||
become /dev/ttyACM1 after a replug, the by-id name stays.
|
||||
"""
|
||||
from serial.tools import list_ports as lp
|
||||
|
||||
by_id: dict[str, str] = {}
|
||||
base = "/dev/serial/by-id"
|
||||
if os.path.isdir(base):
|
||||
for name in os.listdir(base):
|
||||
by_id[os.path.realpath(os.path.join(base, name))] = os.path.join(base, name)
|
||||
every = sorted(lp.comports(), key=lambda p: p.device)
|
||||
ports = [p for p in every if p.vid is not None] # USB only: a companion is a USB device
|
||||
if not ports:
|
||||
print("no USB serial ports found -- is the companion plugged in (and, in a VM/WSL, passed through)?")
|
||||
return 1
|
||||
for p in ports:
|
||||
ids = f"{p.vid:04x}:{p.pid:04x}" if p.vid is not None and p.pid is not None else "-"
|
||||
print(f"{p.device}\n {p.description or '-'} [usb {ids}, serial {p.serial_number or '-'}]")
|
||||
if os.path.realpath(p.device) in by_id:
|
||||
print(f" use: {by_id[os.path.realpath(p.device)]}")
|
||||
if len(every) > len(ports):
|
||||
print(f"({len(every) - len(ports)} non-USB serial ports not shown)")
|
||||
return 0
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
args = build_parser().parse_args(argv) # --help / --version exit here, before any import
|
||||
logging.basicConfig(level=args.log_level.upper(), format="%(asctime)s %(levelname)s %(message)s")
|
||||
if args.list_ports:
|
||||
return list_ports()
|
||||
try:
|
||||
s = resolve(args)
|
||||
except (ValueError, OSError) as e:
|
||||
|
||||
@@ -7,7 +7,7 @@ serial = "/dev/serial/by-id/usb-REPLACE_ME-if00" # `ls /dev/serial/by-id/`
|
||||
# ble = "AA:BB:CC:DD:EE:FF" # BLE companion
|
||||
# ble_pin = "123456"
|
||||
|
||||
interval = 3600 # seconds between rounds (min 900)
|
||||
interval = 28800 # seconds between rounds (min 3600)
|
||||
# path_hash_bytes = 2 # Czech mesh: 2
|
||||
|
||||
# Default password for the blocks below that have none. Admin or guest:
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
# Exact versions for the container image; pyproject.toml has the ranges.
|
||||
meshcore==2.3.17
|
||||
meshcore==2.3.19
|
||||
prometheus_client==0.26.0
|
||||
+3
-3
@@ -23,10 +23,10 @@ MC_VERSION=latest
|
||||
MC_REPEATERS=REPLACE_ME
|
||||
# Admin or guest password of the repeater(s). Guest: all but external sensors.
|
||||
MC_PASSWORD=REPLACE_ME
|
||||
# Seconds between readings (min 900). Each reading takes ~1 s of a channel
|
||||
# everyone shares. A battery does not change in minutes: an hour is plenty;
|
||||
# Seconds between readings (min 3600). Each reading takes ~1 s of a channel
|
||||
# everyone shares. A battery does not change in minutes: 8 hours is plenty;
|
||||
# https://meshcore.repeater.cz/nastaveni/telemetrie/
|
||||
MC_INTERVAL=3600
|
||||
MC_INTERVAL=28800
|
||||
# Czech mesh: 2 (width of route hashes in packets this radio sends)
|
||||
MC_PATH_HASH_BYTES=2
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ services:
|
||||
# - ./repeaters.toml:/config/repeaters.toml:ro
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
|
||||
image: prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
@@ -40,7 +40,7 @@ services:
|
||||
- prometheus:/prometheus
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:13.3.0@sha256:488984b716c0862639f91a698adbe2862677a5a07bad42da5f03f3030883b205
|
||||
image: grafana/grafana:13.3.1@sha256:0615ec4fbd4072004b7d86b46ded63013a74b7d6eb1119273dd89e8fa25c13cf
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${GRAFANA_PORT:-3000}:3000"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
global:
|
||||
# The exporter reads the mesh every 15 min; scraping its page more often
|
||||
# The exporter reads the mesh every few hours; scraping its page more often
|
||||
# costs nothing on air and just repeats the last values.
|
||||
scrape_interval: 60s
|
||||
|
||||
|
||||
+23
-6
@@ -38,9 +38,9 @@ def test_cli_minimal(monkeypatch):
|
||||
|
||||
def test_env_twins(monkeypatch):
|
||||
s = settings(
|
||||
[], monkeypatch, {"MC_TCP": "h:5000", "MC_REPEATERS": "rpt", "MC_INTERVAL": "1800", "MC_PATH_HASH_BYTES": "2"}
|
||||
[], monkeypatch, {"MC_TCP": "h:5000", "MC_REPEATERS": "rpt", "MC_INTERVAL": "7200", "MC_PATH_HASH_BYTES": "2"}
|
||||
)
|
||||
assert s.tcp == "h:5000" and s.interval == 1800 and s.path_hash_bytes == 2
|
||||
assert s.tcp == "h:5000" and s.interval == 7200 and s.path_hash_bytes == 2
|
||||
|
||||
|
||||
def test_interval_floor(monkeypatch):
|
||||
@@ -64,16 +64,16 @@ def test_bad_setup(argv, monkeypatch):
|
||||
def test_toml(tmp_path, monkeypatch):
|
||||
f = tmp_path / "r.toml"
|
||||
f.write_text(
|
||||
'serial = "/dev/y"\ninterval = 1800\npassword = "common"\n'
|
||||
'serial = "/dev/y"\ninterval = 7200\npassword = "common"\n'
|
||||
'[[repeater]]\nname = "one"\n'
|
||||
'[[repeater]]\nname = "two"\npassword = "own"\npath = "5361"\n'
|
||||
)
|
||||
s = settings(["--config", str(f)], monkeypatch)
|
||||
assert s.serial == "/dev/y" and s.interval == 1800
|
||||
assert s.serial == "/dev/y" and s.interval == 7200
|
||||
assert [(t.name, t.password, t.path) for t in s.targets] == [("one", "common", ""), ("two", "own", "5361")]
|
||||
# the command line wins over the file
|
||||
s = settings(["--config", str(f), "--interval", "2400"], monkeypatch)
|
||||
assert s.interval == 2400
|
||||
s = settings(["--config", str(f), "--interval", "10800"], monkeypatch)
|
||||
assert s.interval == 10800
|
||||
|
||||
|
||||
def test_example_toml_loads(monkeypatch):
|
||||
@@ -144,3 +144,20 @@ def test_contacts_fetched_once_per_round(monkeypatch):
|
||||
for t in s.targets:
|
||||
assert asyncio.run(ex.contact(mc, t))["adv_name"] == t.name
|
||||
assert calls == [mx.CONTACTS_TIMEOUT]
|
||||
|
||||
|
||||
def test_list_ports_skips_non_usb(monkeypatch, capsys):
|
||||
from types import SimpleNamespace
|
||||
|
||||
pytest.importorskip("serial")
|
||||
from serial.tools import list_ports
|
||||
|
||||
fake = [
|
||||
SimpleNamespace(device="/dev/ttyS0", description="n/a", vid=None, pid=None, serial_number=None),
|
||||
SimpleNamespace(device="COM7", description="XIAO nRF52840", vid=0x2886, pid=0x8044, serial_number="AB12"),
|
||||
]
|
||||
monkeypatch.setattr(list_ports, "comports", lambda: fake)
|
||||
assert mx.list_ports() == 0
|
||||
out = capsys.readouterr().out
|
||||
assert "COM7" in out and "2886:8044" in out and "AB12" in out and "/dev/ttyS0" not in out
|
||||
assert "1 non-USB" in out
|
||||
Reference in new issue
Block a user