Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c097b08b62 | ||
|
|
c935ddf930 | ||
|
|
713b2f8815 | ||
|
|
5f31fc8e50 | ||
|
|
0dcc9c6e06 | ||
|
|
5a83c230cd | ||
|
|
e9501d0437 | ||
|
|
7dafdf239a | ||
|
|
c36ac45865 | ||
|
|
108245e55b | ||
|
|
976038717f | ||
|
|
36ffbe86f2 | ||
|
|
39fa6597c6 | ||
|
|
16a68f218a | ||
|
|
96db79dbc0 | ||
|
|
39da9ce46e | ||
|
|
5a86072ec6 |
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# The docs website of this fork (https://tth-pub.pages.rfa.cz/meshcore-tth/):
|
||||
# mkdocs (theme mkdocs-terminal) over docs/, in English: the English half of
|
||||
# the fork's README is the home page, the Czech half one page (cs.md); the
|
||||
# fork's own docs first, upstream's below.
|
||||
#
|
||||
# Usage: .github/docs-site.sh <out dir> (run from the repo root)
|
||||
# Needs mkdocs-terminal and markdown-callouts, e.g.
|
||||
# uvx --with mkdocs-terminal --with markdown-callouts mkdocs --version
|
||||
# The script stages a copy of docs/ (README split into index.md / cs.md,
|
||||
# links that leave docs/ pointed at the repo) and builds it with
|
||||
# mkdocs.tth.yml. Upstream's mkdocs.yml (Material) stays as it is (no
|
||||
# conflicts in upstream-sync merges).
|
||||
# Build only from the PUBLIC tree (tth-pub): the export leaves our operations
|
||||
# docs out, a build of the private repo would publish them.
|
||||
set -euo pipefail
|
||||
case "${1:-}" in -h | --help | "")
|
||||
sed -n '2,/^[^#]/{/^#/s/^# \{0,1\}//p}' "$0"
|
||||
[ -n "${1:-}" ] || exit 2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
out=$(realpath -m "$1")
|
||||
repo=https://git.rfa.cz/tth-pub/meshcore-tth
|
||||
src="$repo/src/branch/main"
|
||||
stage=$(mktemp -d)
|
||||
trap 'rm -rf "$stage"' EXIT
|
||||
|
||||
cp -r docs "$stage/docs"
|
||||
# upstream's own introduction gets a page of its own; ours is the home page
|
||||
mv "$stage/docs/index.md" "$stage/docs/meshcore.md"
|
||||
rm -f "$stage/docs/docs.md" # how to build upstream's site, not for readers
|
||||
|
||||
# README of the fork: "## O tomto forku" .. "## About this fork" = Czech,
|
||||
# from there to "## About MeshCore" = English. One heading level up, links
|
||||
# into docs/ made site-relative, any other repo path absolute.
|
||||
readme_part() {
|
||||
sed -n "/^## $1/,/^## $2/p" README.md | sed '$d' |
|
||||
sed -E 's/^#(#+) /\1 /' |
|
||||
sed -E 's#\]\((\./)?docs/([^)]+)\)#](\2)#g' |
|
||||
sed -E "s#\\]\\((\\./)?([a-zA-Z][^):]*)\\)#](${src//#/\\#}/\\2)#g"
|
||||
}
|
||||
readme_part 'About this fork' 'About MeshCore' >"$stage/docs/index.md"
|
||||
readme_part 'O tomto forku' 'About this fork' >"$stage/docs/cs.md"
|
||||
if ! grep -q . "$stage/docs/index.md" || ! grep -q . "$stage/docs/cs.md"; then
|
||||
echo "docs-site: README sections not found (headings changed?)" >&2
|
||||
exit 1
|
||||
fi
|
||||
# the two languages link to each other by anchor, and "above"/"below"
|
||||
# is a separate page here
|
||||
sed -i -E 's#Česká verze \[výše\]#[Česká verze]#' "$stage/docs/index.md"
|
||||
sed -i -E 's#English version \[below\]#[English version]#' "$stage/docs/cs.md"
|
||||
sed -i -E 's#\]\(\#about-this-fork[^)]*\)#](index.md)#g' "$stage/docs/cs.md"
|
||||
sed -i -E 's#\]\(\#o-tomto-forku[^)]*\)#](cs.md)#g' "$stage/docs/index.md"
|
||||
# GFM (Gitea) needs `\|` for a pipe in code inside a table cell; Python-
|
||||
# Markdown keeps the backslash and does not split cells on a pipe in code
|
||||
perl -0pi -e 's/(`[^`\n]*`)/ (my $c = $1) =~ s#\\\|#|#g; $c /ge' "$stage"/docs/*.md
|
||||
# our docs link back to ../README.md
|
||||
sed -i -E 's#\]\(\.\./README\.md#](index.md#g' "$stage"/docs/*.md
|
||||
|
||||
cp mkdocs.tth.yml "$stage/"
|
||||
cd "$stage"
|
||||
mkdocs build --strict -f mkdocs.tth.yml -d "$out"
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env bash
|
||||
# The changes part of a public release's notes (pub-release.yml): our commits
|
||||
# since BASE, one computed line for the build dependencies that moved, and
|
||||
# upstream's merged PRs. Prints Markdown to stdout.
|
||||
#
|
||||
# Usage: .github/release-notes.sh <base> <sha> <web url of this repo>
|
||||
# Preview: in a clone of tth-pub/meshcore-tth checked out at <sha> (the
|
||||
# library line compares platformio.lock in the working tree with <base>).
|
||||
#
|
||||
# What a commit puts into the notes (body lines, AGENTS.md "Commit = řádek
|
||||
# veřejného changelogu"; .tth/tools/git-hooks/commit-msg enforces them):
|
||||
# Changelog: <English line> replaces the subject; "Changelog: -" = left out
|
||||
# Changelog-cs: <Czech line> the notes show "<cs> · *<en>*"
|
||||
# Changelog-topic: <slug> commits with the same topic in one release are
|
||||
# ONE item: the newest one's text, all links --
|
||||
# a fix of a fix, a pin moved twice, a
|
||||
# superseded step no longer show up as two items
|
||||
# Commits that touch the firmware (paths in $fwre) come first, the rest is
|
||||
# folded. Build dependencies are not taken from commit messages but diffed:
|
||||
# the nRF52 platform and toolchain pins in platformio.ini and every library in
|
||||
# platformio.lock (tools/pio_lock.py moved), so the daily lock refresh and
|
||||
# Renovate commits carry "Changelog: -" and a release still says what moved.
|
||||
set -euo pipefail
|
||||
case "${1:-}" in -h | --help)
|
||||
sed -n '2,/^[^#]/{/^#/s/^# \{0,1\}//p}' "$0"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
[ $# -eq 3 ] || {
|
||||
echo "usage: $0 <base> <sha> <web url>" >&2
|
||||
exit 2
|
||||
}
|
||||
base=$1 sha=$2 web=$3
|
||||
gh=https://github.com/meshcore-dev/MeshCore
|
||||
max=60
|
||||
fwre='^(src|examples|variants|lib|boards|arch)/|^platformio\.(ini|lock)$'
|
||||
|
||||
trailer() { git log -1 --format=%b "$1" | sed -n "s/^$2: *//p" | head -1; }
|
||||
|
||||
# ours: commits on our main itself (first parent); a merge of one of our own
|
||||
# branches (feat/...) is unfolded into the branch's commits, an upstream merge
|
||||
# is left to the upstream list below
|
||||
ourc=()
|
||||
for c in $(git log --first-parent --format=%H "$base..$sha"); do
|
||||
if git rev-parse -q --verify "$c^2" >/dev/null; then
|
||||
git log -1 --format=%s "$c" | grep -q '^Merge upstream' && continue
|
||||
# ^base: a merge of main into a branch carries what is released already
|
||||
mapfile -t -O "${#ourc[@]}" ourc < <(git log --no-merges --format=%H "$c^1..$c^2" "^$base")
|
||||
else
|
||||
ourc+=("$c")
|
||||
fi
|
||||
done
|
||||
|
||||
# items, newest first; a topic seen before only adds its link
|
||||
declare -A text=() links=() isfw=()
|
||||
keys=()
|
||||
for c in "${ourc[@]}"; do
|
||||
en=$(trailer "$c" Changelog)
|
||||
[ "$en" = "-" ] && continue
|
||||
[ -n "$en" ] || en=$(git log -1 --format=%s "$c")
|
||||
cs=$(trailer "$c" Changelog-cs)
|
||||
key=$(trailer "$c" Changelog-topic)
|
||||
key=${key:-$c}
|
||||
link="[${c:0:8}]($web/commit/$c)"
|
||||
if [ -z "${text[$key]+x}" ]; then
|
||||
keys+=("$key")
|
||||
if [ -n "$cs" ]; then text[$key]="$cs · *$en*"; else text[$key]=$en; fi
|
||||
links[$key]=$link
|
||||
else
|
||||
links[$key]+=", $link"
|
||||
fi
|
||||
git diff-tree --no-commit-id --name-only -r "$c" | grep -qE "$fwre" && isfw[$key]=1
|
||||
done
|
||||
|
||||
# build dependencies that moved between base and sha
|
||||
deps=()
|
||||
pin() { git show "$1:platformio.ini" 2>/dev/null | grep -m1 -oE "$2@[0-9][^[:space:]]*" | cut -d@ -f2 || true; }
|
||||
for p in nordicnrf52 toolchain-gccarmnoneeabi; do
|
||||
o=$(pin "$base" "platformio/$p") n=$(pin "$sha" "platformio/$p")
|
||||
[ "$o" = "$n" ] || deps+=("$p ${o:-unpinned} → ${n:-unpinned}")
|
||||
done
|
||||
if git cat-file -e "$base:platformio.lock" 2>/dev/null && [ -f platformio.lock ]; then
|
||||
if [ "$(git rev-parse HEAD)" = "$(git rev-parse "$sha^{commit}")" ]; then
|
||||
while IFS= read -r l; do
|
||||
[ -n "$l" ] && deps+=("${l/ -> / → }")
|
||||
done < <(python3 tools/pio_lock.py moved --base "$base")
|
||||
else
|
||||
echo "release-notes: checkout is not $sha, libraries left out" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
fw="" other="" nother=0
|
||||
for k in "${keys[@]}"; do
|
||||
line="- ${text[$k]} (${links[$k]})"
|
||||
if [ -n "${isfw[$k]:-}" ]; then
|
||||
fw+="$line"$'\n'
|
||||
else
|
||||
other+="$line"$'\n'
|
||||
nother=$((nother + 1))
|
||||
fi
|
||||
done
|
||||
if [ "${#deps[@]}" -gt 0 ]; then
|
||||
d=$(printf '%s, ' "${deps[@]}")
|
||||
fw+="- Závislosti buildu · *build dependencies*: ${d%, }"$'\n'
|
||||
fi
|
||||
fw=${fw%$'\n'} other=${other%$'\n'}
|
||||
|
||||
# upstream: the first-parent line of each merged upstream branch, PR merges as
|
||||
# their title, direct commits as their subject. A direct upstream commit (no
|
||||
# PR) links to GitHub by its ORIGINAL id: the public export (filter-repo)
|
||||
# gives every upstream commit a new one, which GitHub does not know
|
||||
# (30. 11. 2026: "* sec patch" linked to a 404). Author email + author time
|
||||
# survive the rewrite.
|
||||
declare -A seen=() upid=()
|
||||
if git fetch -q --no-tags "$gh.git" '+refs/heads/main:refs/upstream/main' '+refs/heads/dev:refs/upstream/dev'; then
|
||||
while read -r h k; do upid[$k]=$h; done < <(git log --format='%H %ae/%at' refs/upstream/main refs/upstream/dev)
|
||||
fi
|
||||
ups=()
|
||||
for m in $(git log --first-parent --merges --grep='^Merge upstream' --format=%H "$base..$sha"); do
|
||||
for c in $(git log --first-parent --format=%H "$m^1..$m^2"); do
|
||||
s=$(git log -1 --format=%s "$c")
|
||||
if [[ $s =~ ^Merge\ pull\ request\ \#([0-9]+)\ from\ ([^/]+)/(.*)$ ]]; then
|
||||
pr=${BASH_REMATCH[1]}
|
||||
[ -z "${seen[$pr]:-}" ] || continue
|
||||
seen[$pr]=1
|
||||
t=$(git log -1 --format=%b "$c" | sed -n '/./{p;q}')
|
||||
ups+=("- ${t:-${BASH_REMATCH[3]}} ([#$pr]($gh/pull/$pr), ${BASH_REMATCH[2]})")
|
||||
elif [[ $s != Merge* ]]; then
|
||||
[ -z "${seen[$c]:-}" ] || continue
|
||||
seen[$c]=1
|
||||
u=${upid[$(git log -1 --format='%ae/%at' "$c")]:-}
|
||||
if [ -n "$u" ]; then
|
||||
ups+=("- $s ([${u:0:7}]($gh/commit/$u))")
|
||||
else
|
||||
ups+=("- $s ([${c:0:7}]($web/commit/$c))")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
n=${#ups[@]}
|
||||
|
||||
echo "### Změny firmwaru · firmware changes"
|
||||
echo "${fw:-- žádné · none}"
|
||||
echo
|
||||
if [ "$nother" -gt 0 ]; then
|
||||
echo "<details><summary>Dokumentace, nástroje, CI · docs, tools, CI ($nother)</summary>"
|
||||
echo
|
||||
echo "$other"
|
||||
echo
|
||||
echo "</details>"
|
||||
echo
|
||||
fi
|
||||
echo "### Z upstreamu MeshCore · from upstream ($n)"
|
||||
if [ "$n" -gt 0 ]; then printf '%s\n' "${ups[@]:0:$max}"; else echo "- žádné · none"; fi
|
||||
[ "$n" -le "$max" ] || echo "- … a dalších $((n - max)) · and $((n - max)) more"
|
||||
@@ -11,6 +11,9 @@ permissions:
|
||||
|
||||
jobs:
|
||||
github-pages:
|
||||
# CUSTOM (TeTeHacko): upstream's site only; this fork publishes its own
|
||||
# (tth-docs.yml), and here the job only filled an unread gh-pages branch
|
||||
if: github.repository == 'meshcore-dev/MeshCore'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
# the newest KEEP releases stay, older ones are deleted. The body is a
|
||||
# changelog since the previous release: our own firmware commits, our docs /
|
||||
# tools / CI commits folded, then the upstream PRs the upstream merges brought
|
||||
# in. A "Changelog: <text>" line in a commit body replaces its subject there.
|
||||
# in, generated by .github/release-notes.sh (preview it locally; its header
|
||||
# lists the commit trailers: Changelog, Changelog-cs, Changelog-topic) with
|
||||
# one computed line for the build dependencies that moved.
|
||||
# nRF52: .uf2 (drag onto the bootloader drive) and .zip (DFU over BLE or
|
||||
# serial); ESP32: -merged.bin (fresh install at 0x0) and .bin (update).
|
||||
#
|
||||
@@ -451,8 +453,6 @@ jobs:
|
||||
EOF
|
||||
)
|
||||
web="$GITEA/$GITHUB_REPOSITORY"
|
||||
gh=https://github.com/meshcore-dev/MeshCore
|
||||
max=60
|
||||
# changelog against the newest older release that HEAD descends from
|
||||
prev="" base=""
|
||||
while read -r t c; do
|
||||
@@ -470,73 +470,9 @@ jobs:
|
||||
| sort_by(.created_at) | reverse | .[] | "\(.tag_name) \(.target_commitish)"')
|
||||
# no older release: the last 20 commits of our own line
|
||||
[ -n "$base" ] || base=$(git rev-list --first-parent --max-count=21 "$SHA" | tail -1)
|
||||
# ours: commits on our main itself (first parent); a merge of one of
|
||||
# our own branches (feat/...) is unfolded into the branch's commits,
|
||||
# an upstream merge is left to the upstream list below
|
||||
ourc=()
|
||||
for c in $(git log --first-parent --format=%H "$base..$SHA"); do
|
||||
if git rev-parse -q --verify "$c^2" >/dev/null; then
|
||||
git log -1 --format=%s "$c" | grep -q '^Merge upstream' && continue
|
||||
# ^base: a merge of main into a branch carries what is released already
|
||||
mapfile -t -O "${#ourc[@]}" ourc < <(git log --no-merges --format=%H "$c^1..$c^2" "^$base")
|
||||
else
|
||||
ourc+=("$c")
|
||||
fi
|
||||
done
|
||||
# Firmware changes first; docs, CI, tools and tests folded away. Sorted
|
||||
# by the files a commit touches, so it holds even for a poor subject.
|
||||
# A "Changelog: <text>" line in the body replaces the subject in the
|
||||
# notes ("Changelog: -" leaves the commit out), so the subject can stay
|
||||
# technical while the notes say what changes for the node.
|
||||
fw="" other="" nother=0
|
||||
for c in "${ourc[@]}"; do
|
||||
line=$(git log -1 --format=%b "$c" | sed -n 's/^Changelog: *//p' | head -1)
|
||||
[ "$line" = "-" ] && continue
|
||||
[ -n "$line" ] || line=$(git log -1 --format=%s "$c")
|
||||
line="- $line ([${c:0:8}]($web/commit/$c))"
|
||||
if git diff-tree --no-commit-id --name-only -r "$c" |
|
||||
grep -qE '^(src|examples|variants|lib|boards|arch)/|^platformio\.ini$'; then
|
||||
fw+="$line"$'\n'
|
||||
else
|
||||
other+="$line"$'\n'
|
||||
nother=$((nother + 1))
|
||||
fi
|
||||
done
|
||||
fw=${fw%$'\n'} other=${other%$'\n'}
|
||||
# upstream: the first-parent line of each merged upstream branch,
|
||||
# PR merges as their title, direct commits as their subject
|
||||
declare -A seen=()
|
||||
# A direct upstream commit (no PR) links to GitHub by its ORIGINAL
|
||||
# id: the public export (filter-repo) gives every upstream commit a
|
||||
# new one, which GitHub does not know (30. 11. 2026: "* sec patch"
|
||||
# linked to a 404). Author email + author time survive the rewrite.
|
||||
declare -A upid=()
|
||||
if git fetch -q --no-tags "$gh.git" '+refs/heads/main:refs/upstream/main' '+refs/heads/dev:refs/upstream/dev'; then
|
||||
while read -r h k; do upid[$k]=$h; done < <(git log --format='%H %ae/%at' refs/upstream/main refs/upstream/dev)
|
||||
fi
|
||||
ups=()
|
||||
for m in $(git log --first-parent --merges --grep='^Merge upstream' --format=%H "$base..$SHA"); do
|
||||
for c in $(git log --first-parent --format=%H "$m^1..$m^2"); do
|
||||
s=$(git log -1 --format=%s "$c")
|
||||
if [[ $s =~ ^Merge\ pull\ request\ \#([0-9]+)\ from\ ([^/]+)/(.*)$ ]]; then
|
||||
pr=${BASH_REMATCH[1]}
|
||||
[ -z "${seen[$pr]:-}" ] || continue
|
||||
seen[$pr]=1
|
||||
t=$(git log -1 --format=%b "$c" | sed -n '/./{p;q}')
|
||||
ups+=("- ${t:-${BASH_REMATCH[3]}} ([#$pr]($gh/pull/$pr), ${BASH_REMATCH[2]})")
|
||||
elif [[ $s != Merge* ]]; then
|
||||
[ -z "${seen[$c]:-}" ] || continue
|
||||
seen[$c]=1
|
||||
u=${upid[$(git log -1 --format='%ae/%at' "$c")]:-}
|
||||
if [ -n "$u" ]; then
|
||||
ups+=("- $s ([${u:0:7}]($gh/commit/$u))")
|
||||
else
|
||||
ups+=("- $s ([${c:0:7}]($web/commit/$c))")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
n=${#ups[@]}
|
||||
# our commits, moved build dependencies, upstream PRs -- the
|
||||
# generator is a script so the notes can be previewed locally
|
||||
changes=$(bash .github/release-notes.sh "$base" "$SHA" "$web")
|
||||
body=$(
|
||||
echo "$TITLE"
|
||||
echo
|
||||
@@ -546,20 +482,7 @@ jobs:
|
||||
echo "Od předchozího vydání · since [$prev]($web/releases/tag/$(jq -rn --arg s "$prev" '$s|@uri'))"
|
||||
echo
|
||||
fi
|
||||
echo "### Změny firmwaru · firmware changes"
|
||||
echo "${fw:-- žádné · none}"
|
||||
echo
|
||||
if [ "$nother" -gt 0 ]; then
|
||||
echo "<details><summary>Dokumentace, nástroje, CI · docs, tools, CI ($nother)</summary>"
|
||||
echo
|
||||
echo "$other"
|
||||
echo
|
||||
echo "</details>"
|
||||
echo
|
||||
fi
|
||||
echo "### Z upstreamu MeshCore · from upstream ($n)"
|
||||
[ "$n" -gt 0 ] && printf '%s\n' "${ups[@]:0:$max}" || echo "- žádné · none"
|
||||
[ "$n" -le "$max" ] || echo "- … a dalších $((n - max)) · and $((n - max)) more"
|
||||
echo "$changes"
|
||||
echo
|
||||
echo "### Po flashi · after flashing"
|
||||
echo
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
# Docs website of this fork: https://tth-pub.pages.rfa.cz/meshcore-tth/
|
||||
#
|
||||
# Runs only in the published repo (tth-pub/meshcore-tth), after a push to main
|
||||
# that touches the docs: .github/docs-site.sh builds the site (mkdocs, theme
|
||||
# mkdocs-terminal, mkdocs.tth.yml) from the public tree -- the export leaves
|
||||
# our operations docs out, so nothing private can end up on it -- and the
|
||||
# result is force-pushed as the only commit of the branch `pages`. A webhook
|
||||
# of the repo (push, branch filter `pages`) tells git-pages on pages.rfa.cz,
|
||||
# which clones the branch anonymously: no token outside this repo's own.
|
||||
# git-pages: roles/git_pages in the proxmox.rfa.cz repo.
|
||||
name: tth-docs
|
||||
|
||||
"on":
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
- "mkdocs.tth.yml"
|
||||
- ".github/docs-site.sh"
|
||||
- ".github/workflows/tth-docs.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: tth-docs
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
MKDOCS_VERSION: "1.6.1"
|
||||
MKDOCS_TERMINAL_VERSION: "4.8.0"
|
||||
MARKDOWN_CALLOUTS_VERSION: "0.4.0"
|
||||
PYMDOWN_EXTENSIONS_VERSION: "13.1.2"
|
||||
|
||||
jobs:
|
||||
site:
|
||||
if: github.repository == 'tth-pub/meshcore-tth'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# No actions/setup-python: its builds need x86-64-v3, the runner has v2
|
||||
# (see tth-tools-lint.yml). mkdocs goes into a venv of the image's python3.
|
||||
- name: Install mkdocs
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SUDO="$(command -v sudo || true)"
|
||||
if ! python3 -m venv "$RUNNER_TEMP/docs"; then
|
||||
$SUDO apt-get update -qq
|
||||
$SUDO apt-get install -y -qq python3 python3-venv
|
||||
python3 -m venv --clear "$RUNNER_TEMP/docs"
|
||||
fi
|
||||
"$RUNNER_TEMP/docs/bin/pip" install --quiet \
|
||||
"mkdocs==$MKDOCS_VERSION" "mkdocs-terminal==$MKDOCS_TERMINAL_VERSION" \
|
||||
"markdown-callouts==$MARKDOWN_CALLOUTS_VERSION" \
|
||||
"pymdown-extensions==$PYMDOWN_EXTENSIONS_VERSION"
|
||||
echo "$RUNNER_TEMP/docs/bin" >>"$GITHUB_PATH"
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
NO_MKDOCS_2_WARNING: "1"
|
||||
run: bash .github/docs-site.sh "$RUNNER_TEMP/site"
|
||||
|
||||
# A worktree shares the checkout's credentials (github.token); the
|
||||
# branch keeps one commit, the site of the newest main.
|
||||
- name: Publish to the pages branch
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config --global user.name "tth-docs"
|
||||
git config --global user.email "tth-docs@localhost"
|
||||
wt="$RUNNER_TEMP/pages"
|
||||
git worktree add -q --detach "$wt"
|
||||
cd "$wt"
|
||||
git checkout -q --orphan pages-build
|
||||
git rm -rqf .
|
||||
cp -r "$RUNNER_TEMP/site/." .
|
||||
git add -A
|
||||
git commit -q -m "docs site from main ${GITHUB_SHA:0:8}"
|
||||
git push -q -f origin HEAD:refs/heads/pages
|
||||
echo "published ${GITHUB_SHA:0:8} to pages"
|
||||
@@ -18,6 +18,9 @@ meshi (869,432 MHz). Upstreamové větve `main` a `dev` se slučují automaticky
|
||||
dvakrát denně; všechno níže je navíc nad nimi. Náš kód je ve zdrojácích
|
||||
označený `CUSTOM (TeTeHacko)`. Nic z toho nemění protokol na rádiu.
|
||||
|
||||
Dokumentace forku i upstreamu jako web (anglicky, tahle část česky):
|
||||
https://tth-pub.pages.rfa.cz/meshcore-tth/
|
||||
|
||||
### Repeater: antispam (všechno vypínatelné, nic z toho není v upstreamu)
|
||||
|
||||
**Po nahrání je zapnutý jen FairnessLimiter**, s limity se zhruba
|
||||
@@ -32,22 +35,22 @@ vypnuté, dokud je nezapnete.
|
||||
hash odesílatele, původce advertu). Port návrhu Beanowa
|
||||
[#1502](https://github.com/meshcore-dev/MeshCore/pull/1502), limity
|
||||
přepočítané z 30 dní skutečného provozu CZ meshe.
|
||||
`fairness [on|off|grid|cap|refill]`; přímo směrovaný provoz se neomezuje nikdy.
|
||||
`fairness <on|off>`, `fairness cap`, `fairness refill`, `fairness grid`; přímo směrovaný provoz se neomezuje nikdy.
|
||||
* **Okno na adverty podle původce** – flood advert každého uzlu se přepošle
|
||||
nejvýš jednou za N hodin (`fairness advert <h>|clear`), převzato
|
||||
nejvýš jednou za N hodin (`fairness advert <hours>`, `fairness advert clear`), převzato
|
||||
z AdvertLimiteru [DutchMeshCore](https://github.com/Dutch-MeshCore/MeshCore).
|
||||
Míří na uzly, které advertují každou minutu.
|
||||
* **Dry-run** – `fairness dryrun on` započítá každý verdikt, ale přepošle
|
||||
i tak; `fairness air` ukáže ušetřený (nebo ušetřitelný) airtime podle důvodu.
|
||||
* **Filtr kanálů** – na kanálech, jejichž klíč repeater zná (Public
|
||||
a `#hashtag` kanály), přestane přeposílat zprávy uvedených jmen odesílatelů
|
||||
(`filter add|del|list`). Jméno se dá podvrhnout: je to brzda na utrženého
|
||||
(`filter add <name>`, `filter del <name>`, `filter list`). Jméno se dá podvrhnout: je to brzda na utrženého
|
||||
bota, ne bezpečnost.
|
||||
* **Blokace přeposílání podle hashe kanálu** – `filter hash add <hex> [s]`:
|
||||
* **Blokace přeposílání podle hashe kanálu** – `filter hash add <hex> [secs]`:
|
||||
bez klíče, takže funguje i na soukromých kanálech; příjem se nemění, jen
|
||||
přeposílání. S `s` se kanál neodřízne, ale přiškrtí (jeden paket za `s`
|
||||
sekund).
|
||||
* **Limit stáří zprávy** – `filter age <min>|off` (volitelné, 1–10080 min):
|
||||
* **Limit stáří zprávy** – `filter age <minutes>` / `filter age off` (volitelné, 1–10080 min):
|
||||
nepřeposílá skupinové zprávy na dešifrovaných kanálech, jejichž čas od
|
||||
odesílatele je starší; bez nastavených hodin repeateru neplatí. Posuzuje
|
||||
hodiny odesílatele, takže zahodí i companiony bez synchronizace času –
|
||||
@@ -86,7 +89,7 @@ Repeater navíc:
|
||||
(vysílací výkon do restartu, s verdiktem RadioLibu), čítače chyb vysílání
|
||||
ve stavové odpovědi.
|
||||
* Jen observer varianty (`*-observer`): textová konzole přes BLE vedle USB,
|
||||
`ble on|off` uložené přes reboot (`RPT_BLE_DEFAULT_OFF`: startuje vypnuté),
|
||||
`ble <on|off>` uložené přes reboot (`RPT_BLE_DEFAULT_OFF`: startuje vypnuté),
|
||||
vlastní BLE PIN (`ble pin`), uložený vysílací výkon spojení (`blepwr`),
|
||||
`bleconn`, neblokující BLE vysílání a parametry spojení, které vydrží i na
|
||||
slabém linku.
|
||||
@@ -99,7 +102,7 @@ Repeater navíc:
|
||||
`!noise`, `!ping`, `!help`, výběr přes `BOT_COMMANDS`, cooldown na
|
||||
odesílatele, ignore list) – odpovídá, aniž by přeposílal;
|
||||
* `RADIO_DIAG`: `radiostat` (stav přijímače SX1262 bez zásahu) a
|
||||
`radiokick rx|clrirq|standby|agc` (jeden krok obnovy, od nejjemnějšího –
|
||||
`radiokick <rx|clrirq|standby|agc>` (jeden krok obnovy, od nejjemnějšího –
|
||||
první, který pomůže, ukáže rozbitou vrstvu);
|
||||
* `PIN_DIAG`: `dio1` (stav přerušení v čipu proti úrovni na pinu – který
|
||||
konec mrtvé linky DIO1 je přerušený);
|
||||
@@ -144,10 +147,10 @@ Repeater navíc:
|
||||
a záznam o hardfaultu přežijí teplý reset (`.noinit`); `clkreboot`.
|
||||
* Na solárních uzlech žádná blikající LED a pomalejší BLE advertising.
|
||||
* Stav baterie jako ikona na konci advertovaného jména: `set batt.icon on`,
|
||||
prahy `set batt.icon.lo|hi <mV>` (výchozí vypnuté; dlouhé jméno ikonu
|
||||
prahy `set batt.icon.lo <mV>` a `set batt.icon.hi <mV>` (výchozí vypnuté; dlouhé jméno ikonu
|
||||
nepojme a příkaz na to upozorní).
|
||||
* Volitelný RX duty cycle (`set radio.rxps off|on|balanced|max`, jemněji
|
||||
`level <1-10>`; port PowerSaving z EasySkyMesh): SX1262 mezi krátkými okny
|
||||
* Volitelný RX duty cycle (`set radio.rxps <off|on|balanced|max>`, jemněji
|
||||
`set radio.rxps level <level>` 1–10; port PowerSaving z EasySkyMesh): SX1262 mezi krátkými okny
|
||||
poslechu spí. Ve veřejných buildech je zabudovaný a **vypnutý**; `max` na
|
||||
lavici ušetřil ~2,3 mA bez ztráty paketů ([docs/power.md](docs/power.md)),
|
||||
na ostrém meshi ale jeden náš stožár ztratil 16 % příjmu – zapínat s rozmyslem. Jen
|
||||
@@ -161,8 +164,8 @@ Repeater navíc:
|
||||
([#2088](https://github.com/meshcore-dev/MeshCore/pull/2088)). Výjimkou je
|
||||
`SenseCap_Solar_repeater` (Li-ion, naše stožáry): pojistka je zapnutá
|
||||
a oba prahy jdou nastavit za běhu, i přes mesh jako admin –
|
||||
`set pwr.bootlock <mV>|off` (výchozí 3300, pod ním uzel nenaběhne a spí,
|
||||
dokud se článek nezotaví) a `set pwr.cutoff <mV>|off` (výchozí vypnuto,
|
||||
`set pwr.bootlock <mV>` nebo `off` (výchozí 3300, pod ním uzel nenaběhne a spí,
|
||||
dokud se článek nezotaví) a `set pwr.cutoff <mV>` nebo `off` (výchozí vypnuto,
|
||||
pod ním se běžící uzel vypne); `get pwr` ([docs/power.md](docs/power.md)).
|
||||
|
||||
### Senzory a companiony
|
||||
@@ -172,8 +175,8 @@ Repeater navíc:
|
||||
* Senzory, které jinak měří nepřetržitě (INA219, INA226, INA260, INA3221,
|
||||
BMP280), mezi čteními telemetrie spí a měří jen na vyžádání (nápad a první
|
||||
patch pro INA219: Alkel Brostl). Čipy INA se rozlišují podle ID, takže
|
||||
INA226 už se nedetekuje jako INA219. Odpor bočníku se nastavuje za běhu
|
||||
a ukládá se: `sensor set ina.shunt <mΩ>`.
|
||||
INA226 už se nedetekuje jako INA219. Odpor bočníku (INA219, INA226, INA3221; INA260 ho má uvnitř) se
|
||||
nastavuje za běhu a ukládá se: `sensor set ina.shunt <mOhm>`.
|
||||
* Companion: `gps duty` přežije reboot, kopie data sestavení má hlídanou
|
||||
délku. Export privátního klíče, čtení BLE PINu a jeho změna (i přes CLI
|
||||
`set pin`) jdou jen přes spárované BLE, ne přes USB, UART ani WiFi/TCP,
|
||||
@@ -343,6 +346,9 @@ the CZ mesh (869.432 MHz). Upstream `main` and `dev` are merged automatically
|
||||
twice a day; everything below is on top of that. Our code is marked
|
||||
`CUSTOM (TeTeHacko)` in the source. Nothing here changes the wire protocol.
|
||||
|
||||
The fork's and upstream's docs as a website:
|
||||
https://tth-pub.pages.rfa.cz/meshcore-tth/
|
||||
|
||||
### Repeater: antispam (all of it off-switchable, none of it upstream)
|
||||
|
||||
**After flashing only the FairnessLimiter is on**, with limits about twice
|
||||
@@ -356,21 +362,21 @@ off until you turn them on.
|
||||
ids already in the clear (channel hash, sender hash, advert origin). Port of
|
||||
Beanow's proposal [#1502](https://github.com/meshcore-dev/MeshCore/pull/1502),
|
||||
limits re-sized from 30 days of real CZ traffic.
|
||||
`fairness [on|off|grid|cap|refill]`; direct-routed traffic is never limited.
|
||||
`fairness <on|off>`, `fairness cap`, `fairness refill`, `fairness grid`; direct-routed traffic is never limited.
|
||||
* **Per-origin advert window** -- each node's flood advert forwarded at most
|
||||
once per N hours (`fairness advert <h>|clear`), ported from
|
||||
once per N hours (`fairness advert <hours>`, `fairness advert clear`), ported from
|
||||
[DutchMeshCore](https://github.com/Dutch-MeshCore/MeshCore)'s AdvertLimiter.
|
||||
Aimed at nodes that re-advertise every minute.
|
||||
* **Dry-run** -- `fairness dryrun on` counts every verdict but forwards anyway;
|
||||
`fairness air` reports the airtime shed (or that would be) per reason.
|
||||
* **Channel filter** -- on channels whose key the repeater knows (Public and
|
||||
`#hashtag` channels), stop forwarding messages of listed sender names
|
||||
(`filter add|del|list`). Names are spoofable: it contains a runaway bot,
|
||||
(`filter add <name>`, `filter del <name>`, `filter list`). Names are spoofable: it contains a runaway bot,
|
||||
it is not security.
|
||||
* **Channel-hash deny-forward** -- `filter hash add <hex> [secs]`: keyless,
|
||||
works on private channels too; reception is unaffected, only forwarding.
|
||||
With `secs` the channel is throttled (one packet per `secs`) instead of cut.
|
||||
* **Message age limit** -- `filter age <min>|off` (opt-in, 1-10080 min): do not
|
||||
* **Message age limit** -- `filter age <minutes>` / `filter age off` (opt-in, 1-10080 min): do not
|
||||
forward group texts on the decrypted channels whose sender timestamp is
|
||||
older; inactive while the repeater clock is unset. It judges the sender's
|
||||
clock, so companions without a time sync are dropped too -- keep it in days.
|
||||
@@ -409,7 +415,7 @@ The repeater also has:
|
||||
`txpwr` (TX power until reboot, with RadioLib's verdict), TX-failure
|
||||
counters in the status reply.
|
||||
* Observer variants only (`*-observer`): text console over BLE next to USB,
|
||||
`ble on|off` saved across reboots (`RPT_BLE_DEFAULT_OFF`: starts off), own
|
||||
`ble <on|off>` saved across reboots (`RPT_BLE_DEFAULT_OFF`: starts off), own
|
||||
BLE PIN (`ble pin`), persisted connection TX power (`blepwr`), `bleconn`, a
|
||||
non-blocking BLE TX pump and connection parameters that hold on a weak
|
||||
link.
|
||||
@@ -422,7 +428,7 @@ The repeater also has:
|
||||
`!noise`, `!ping`, `!help`, narrowed by `BOT_COMMANDS`, per-sender
|
||||
cooldown, ignore list) -- answers without repeating;
|
||||
* `RADIO_DIAG`: `radiostat` (SX1262 receiver state, hands off) and
|
||||
`radiokick rx|clrirq|standby|agc` (one recovery step at a time, gentlest
|
||||
`radiokick <rx|clrirq|standby|agc>` (one recovery step at a time, gentlest
|
||||
first -- the first that helps names the broken layer);
|
||||
* `PIN_DIAG`: `dio1` (the chip's IRQ status against the level on the pin --
|
||||
which end of a dead DIO1 line is broken);
|
||||
@@ -467,10 +473,10 @@ The repeater also has:
|
||||
hardfault record survive a warm reset (`.noinit`); `clkreboot`.
|
||||
* No blinking LED and slower BLE advertising on solar nodes.
|
||||
* Battery level as an icon at the end of the advertised name: `set batt.icon
|
||||
on`, thresholds `set batt.icon.lo|hi <mV>` (off by default; a long name has
|
||||
on`, thresholds `set batt.icon.lo <mV>` and `set batt.icon.hi <mV>` (off by default; a long name has
|
||||
no room for it and the command says so).
|
||||
* Optional RX duty cycle (`set radio.rxps off|on|balanced|max`, finer
|
||||
`level <1-10>`; ported from EasySkyMesh PowerSaving): the SX1262 sleeps
|
||||
* Optional RX duty cycle (`set radio.rxps <off|on|balanced|max>`, finer
|
||||
`set radio.rxps level <level>` 1-10; ported from EasySkyMesh PowerSaving): the SX1262 sleeps
|
||||
between short listening windows. Built into the public releases and
|
||||
**off**; `max` saved ~2.3 mA on the bench with no packet loss
|
||||
([docs/power.md](docs/power.md)), but on the live mesh one of our masts lost
|
||||
@@ -485,8 +491,8 @@ The repeater also has:
|
||||
for upstream ([#2088](https://github.com/meshcore-dev/MeshCore/pull/2088)). The exception
|
||||
is `SenseCap_Solar_repeater` (Li-ion, our masts): the lock is on and both
|
||||
thresholds are settable at runtime, also as an admin over the mesh --
|
||||
`set pwr.bootlock <mV>|off` (default 3300; below it the node does not start
|
||||
and sleeps until the cell recovers) and `set pwr.cutoff <mV>|off` (default
|
||||
`set pwr.bootlock <mV>` or `off` (default 3300; below it the node does not start
|
||||
and sleeps until the cell recovers) and `set pwr.cutoff <mV>` or `off` (default
|
||||
off; below it a running node switches off); `get pwr`
|
||||
([docs/power.md](docs/power.md)).
|
||||
|
||||
@@ -497,8 +503,9 @@ The repeater also has:
|
||||
* Sensors that would otherwise convert continuously (INA219, INA226, INA260,
|
||||
INA3221, BMP280) sleep between telemetry reads and measure on demand (idea
|
||||
and first INA219 patch: Alkel Brostl). INA chips are told apart by their ID,
|
||||
so an INA226 is no longer taken for an INA219. The shunt is set at runtime
|
||||
and saved: `sensor set ina.shunt <mOhm>`.
|
||||
so an INA226 is no longer taken for an INA219. The shunt (INA219, INA226,
|
||||
INA3221; the INA260 has it inside) is set at runtime and saved:
|
||||
`sensor set ina.shunt <mOhm>`.
|
||||
* Companion: `gps duty` persists, bounded build-date copy. Private key
|
||||
export, reading the BLE PIN and changing it (CLI `set pin` included) work
|
||||
only over paired BLE, never over USB, a UART or WiFi/TCP, and the reply that
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* Docs site of the meshcore-tth fork (mkdocs.tth.yml, theme mkdocs-terminal,
|
||||
palette "dark"): only what the palette lacks. Green instead of its blue,
|
||||
and the GitHub callouts (> [!WARNING]) the theme does not style. */
|
||||
:root {
|
||||
--primary-color: #5fd38d;
|
||||
--progress-bar-fill: #5fd38d;
|
||||
/* plain black; the palette's 60em column was a thin noodle on a wide
|
||||
screen (user, 2. 12. 2026) */
|
||||
--background-color: #000;
|
||||
--invert-font-color: #000;
|
||||
--code-bg-color: #161616;
|
||||
--page-width: min(110em, 94vw);
|
||||
}
|
||||
|
||||
.admonition {
|
||||
border: 1px solid var(--secondary-color);
|
||||
padding: 0.2em 1em;
|
||||
margin: var(--global-line-height) 0;
|
||||
}
|
||||
.admonition-title {
|
||||
font-weight: bold;
|
||||
margin: 0.4em 0 0;
|
||||
}
|
||||
.admonition.warning, .admonition.caution, .admonition.danger {
|
||||
border-color: #e5a50a;
|
||||
}
|
||||
.admonition.warning > .admonition-title,
|
||||
.admonition.caution > .admonition-title,
|
||||
.admonition.danger > .admonition-title {
|
||||
color: #e5a50a;
|
||||
}
|
||||
.admonition.note > .admonition-title,
|
||||
.admonition.tip > .admonition-title,
|
||||
.admonition.important > .admonition-title {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ know whether a change like `f6e9aeca` (widening the requested interval to
|
||||
from the last one; before any client has ever connected it answers
|
||||
`nothing seen yet`.
|
||||
|
||||
### `blepwr [dBm]` — connection TX power, saved
|
||||
### `blepwr [dBm|default]` — connection TX power, saved
|
||||
|
||||
```
|
||||
blepwr # report: BLE conn tx: 0 dBm, adv tx: 8 dBm
|
||||
|
||||
+27
-9
@@ -44,6 +44,8 @@ This document provides an overview of CLI commands that can be sent to MeshCore
|
||||
---
|
||||
|
||||
### Reset the clock and reboot
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `clkreboot`
|
||||
|
||||
@@ -74,7 +76,7 @@ locally.
|
||||
|
||||
**Reply:** `HH:MM - D/M/YYYY UTC (epoch <seconds>)`
|
||||
|
||||
The epoch is a TeTeHacko addition. The human part is minutes only, so a host
|
||||
The epoch is a meshcore-tth addition. The human part is minutes only, so a host
|
||||
comparing clocks cannot see a difference smaller than a minute and has to leave
|
||||
a deadband of over 59 s; the epoch makes the comparison exact. It is appended,
|
||||
so anything that only prints the reply is unaffected.
|
||||
@@ -398,13 +400,13 @@ Refer to the node's manual for the correct settings to use.
|
||||
|
||||
#### Show battery state as an icon on the advertised name
|
||||
|
||||
*(TeTeHacko fork)* Appends a solar marker and a charge level to the name
|
||||
*meshcore-tth addition.* Appends a solar marker and a charge level to the name
|
||||
carried in adverts, so anyone who hears the node can see its state without
|
||||
logging in for telemetry. Off by default.
|
||||
|
||||
**Usage:**
|
||||
- `get batt.icon`
|
||||
- `set batt.icon on|off`
|
||||
- `set batt.icon <on|off>`
|
||||
|
||||
**Default:** `off`
|
||||
|
||||
@@ -431,6 +433,8 @@ changes roughly once a week.
|
||||
---
|
||||
|
||||
#### Battery scale for the name icon
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `get batt.icon.lo` / `set batt.icon.lo <millivolts>`
|
||||
- `get batt.icon.hi` / `set batt.icon.hi <millivolts>`
|
||||
@@ -581,12 +585,16 @@ so the icon and the Grafana percentage tell one story.
|
||||
|
||||
---
|
||||
|
||||
#### View or change the RX duty cycle (rxps) -- CUSTOM (TeTeHacko)
|
||||
#### View or change the RX duty cycle (rxps)
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `get radio.rxps`
|
||||
- `set radio.rxps off|on|balanced|max`
|
||||
- `set radio.rxps level <1-10> [preamble <16|32>]`
|
||||
- `set radio.rxps max preamble <16|32>`
|
||||
- `set radio.rxps <off|on|balanced|max|overdrive|riskyWorkingMax>`
|
||||
- `set radio.rxps <max|overdrive|riskyWorkingMax> preamble <16|32>`
|
||||
- `set radio.rxps level <level> [preamble <16|32>]`
|
||||
- `set radio.rxps <level>`
|
||||
- `set radio.rxps <rx_us> <sleep_us>`
|
||||
|
||||
The SX1262 sleeps between short listening windows (`SetRxDutyCycle`) instead
|
||||
of listening all the time, and stays awake through a packet once it hears a
|
||||
@@ -600,7 +608,7 @@ off until you set it; the setting is saved.
|
||||
higher the level, the longer the sleep. The named presets assume senders
|
||||
with a 16-symbol preamble (the MeshCore default), so they are safe on a
|
||||
mixed mesh.
|
||||
- `level <n>`: the same scale by number; without `preamble` it follows the SF.
|
||||
- `level`: the same scale by number, 1..10; without `preamble` it follows the SF.
|
||||
9 (`overdrive`) and 10 (`riskyWorkingMax`) are past the datasheet's timing
|
||||
condition -- 10 is known to lose packets.
|
||||
- `<rx_us> <sleep_us>`: raw window lengths.
|
||||
@@ -797,6 +805,8 @@ also runs in continuous RX.
|
||||
---
|
||||
|
||||
#### Radio silence watchdog (repeater, sensor, room server)
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `get radio.silence`
|
||||
- `set radio.silence <minutes>`
|
||||
@@ -814,6 +824,8 @@ To keep a quiet site out of a reboot loop, each such reboot doubles the threshol
|
||||
---
|
||||
|
||||
#### TX stall watchdog (repeater)
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `get radio.txstall`
|
||||
- `set radio.txstall <minutes>`
|
||||
@@ -828,6 +840,8 @@ To keep a quiet site out of a reboot loop, each such reboot doubles the threshol
|
||||
---
|
||||
|
||||
#### Reboot into the bootloader (repeater, sensor, room server; nRF52, local console only)
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `dfu [uf2|serial|ota]`
|
||||
|
||||
@@ -836,6 +850,8 @@ To keep a quiet site out of a reboot loop, each such reboot doubles the threshol
|
||||
---
|
||||
|
||||
#### Why the board last reset (repeater, sensor, room server)
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `get boot`
|
||||
|
||||
@@ -1227,7 +1243,7 @@ region save
|
||||
|
||||
**Note:** In duty-cycle mode `gps` answers `duty, {awake|asleep}, {fix|no fix}, {sat count} sats`.
|
||||
|
||||
`gps duty` powers the receiver only around a clock sync and cuts it in between.
|
||||
*meshcore-tth addition:* `gps duty` powers the receiver only around a clock sync and cuts it in between.
|
||||
It is meant for a node that runs GPS purely to keep its (volatile) RTC set — a
|
||||
mast or solar repeater — where a receiver drawing tens of mA continuously
|
||||
dwarfs the rest of the power budget. Unlike `gps period`, every attempt is
|
||||
@@ -1378,6 +1394,8 @@ Covers serial NMEA receivers (`MicroNMEALocationProvider`).
|
||||
---
|
||||
|
||||
#### Set the INA current sensor's shunt resistor
|
||||
*meshcore-tth addition.*
|
||||
|
||||
**Usage:**
|
||||
- `sensor get ina.shunt`
|
||||
- `sensor set ina.shunt <mOhm>`
|
||||
|
||||
@@ -22,6 +22,7 @@ Once you have a working app/project, you need to be able to demonstrate it exist
|
||||
| 0140 | Nelos | support@nelos.app — https://nelos.app |
|
||||
| 0150 | Road Events | juraj@bednar.io — https://github.com/jooray/roadbeacon/blob/main/nips/road-events.md |
|
||||
| 0160 | Knit | jeff@getknit.app — https://getknit.app |
|
||||
| 0170 | MeshTrax | venahamtrack@gmail.com — https://github.com/venamartin/meshtrax |
|
||||
| FF00 - FFFF | -reserved for testing/dev- | |
|
||||
|
||||
(add rows, inside the range 0100 - FEFF for custom apps)
|
||||
+3
-3
@@ -212,10 +212,10 @@ wired in `variants/sensecap_solar`) and `PWRMGT_RUNTIME` (ours), which gives
|
||||
two thresholds, both saved on the node and settable from the console or as an
|
||||
admin over the mesh:
|
||||
|
||||
| | default | |
|
||||
| command | default | what |
|
||||
|---|---|---|
|
||||
| `set pwr.bootlock <mV>\|off` | 3300 mV (`variant.h`) | at boot, below it the node goes to SYSTEMOFF and the LPCOMP wakes it when the battery recovers |
|
||||
| `set pwr.cutoff <mV>\|off` | off | while running, three readings in a row (one a minute) below it switch the node off into the same SYSTEMOFF |
|
||||
| `set pwr.bootlock <mV>` | 3300 mV (`variant.h`) | 3000..4200 or `off`; at boot, below it the node goes to SYSTEMOFF and the LPCOMP wakes it when the battery recovers |
|
||||
| `set pwr.cutoff <mV>` | off | 3000..4200 or `off`; while running, three readings in a row (one a minute) below it switch the node off into the same SYSTEMOFF |
|
||||
| `get pwr` | | both, the battery now and at boot, USB, the reason of the last switch-off |
|
||||
|
||||
The cutoff must stay below the bootlock -- a node switched off at the cutoff
|
||||
|
||||
+80
-50
@@ -9,6 +9,10 @@ Everything this fork adds to the text console of a node, on top of upstream's
|
||||
(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 |
|
||||
@@ -33,18 +37,19 @@ 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.
|
||||
**On after flashing** (`FAIRNESS_ENABLED_DEFAULT`).
|
||||
|
||||
| command | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `fairness` | state, denials per category, caps and refill intervals |
|
||||
| `fairness on\|off` | the buckets on/off |
|
||||
| `fairness cap <group> <sender> <advert>` | burst caps 0..255, `0` = build default (100 / 150 / 30) |
|
||||
| `fairness refill <group_s> <sender_s> <advert_s>` | one token per interval, seconds, `0` = default (30 / 10 / 600) |
|
||||
| `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 [<hours>\|clear]` | per-origin advert window: one flood advert per origin per `<hours>` (0..720, `0` = off, default off); `clear` forgets the origins seen |
|
||||
| `fairness dryrun [on\|off]` | count every verdict but forward anyway (default off) |
|
||||
| `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,
|
||||
@@ -57,11 +62,12 @@ 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 | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `filter` / `filter list` | channels known, drops, the deny list |
|
||||
| `filter add <name>` / `filter del <name>` | exact, case-insensitive; spaces allowed, commas not |
|
||||
| `filter clear` | empty the list |
|
||||
| `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 |
|
||||
|
||||
### Channel-hash deny-forward -- `filter hash` (every repeater)
|
||||
|
||||
@@ -70,41 +76,48 @@ so this works on private channels too. One byte is coarse -- every other
|
||||
channel whose key hashes to the same byte is hit as well; check what else
|
||||
lives on it before adding one.
|
||||
|
||||
| command | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `filter hash` | drops, passes by a throttle, the list (`43` blocked, `43/60` throttled) |
|
||||
| `filter hash add <hex> [secs]` | block the byte, or let one packet through per `secs` (1..65535); re-adding changes the interval |
|
||||
| `filter hash del <hex>` / `filter hash clear` | |
|
||||
| `filter hash [list]` | drops, passes by a throttle, the list (`43` blocked, `43/60` throttled) |
|
||||
| `filter hash add <hex> [secs]` | block the byte, or with `secs` (1..65535) let one packet through per `secs`; re-adding changes the interval |
|
||||
| `filter hash del <hex>` | remove one byte |
|
||||
| `filter hash clear` | empty the list |
|
||||
|
||||
A throttle's window lives in RAM: the first match after a boot passes.
|
||||
|
||||
### Message age -- `filter age` (repeater with channel keys)
|
||||
|
||||
`filter age <min>|off` (1..10080, default off): do not forward a group text
|
||||
on a decrypted channel whose sender timestamp is older than `<min>` by this
|
||||
node's clock. 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.
|
||||
| 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 |
|
||||
|
||||
### `filter dryrun [on|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.
|
||||
|
||||
Count every `filter` verdict (sender, hash, age) but forward anyway -- try a
|
||||
rule on a live node before it bites. Default off.
|
||||
### Dry run -- `filter dryrun`
|
||||
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `filter dryrun [on\|off]` | count every `filter` verdict (sender, hash, age) but forward anyway -- try a rule on a live node before it bites; without an argument shows the state. Default: off |
|
||||
|
||||
## 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 | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `set radio.silence <min>\|off` / `get radio.silence` | deaf receiver: re-arm RX, then reboot after `<min>` 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. 1..1440, persisted, **default off** |
|
||||
| `set radio.txstall <min>\|off` / `get radio.txstall` | repeater only: packets queued and nothing sent for `<min>` -> re-arm, then reboot. An empty queue never counts. **On, 15 min** (`RADIO_TXSTALL_MIN`); a change holds until reboot |
|
||||
| `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*: reboot into the bootloader -- UF2 drive (default), CDC port for `adafruit-nrfutil`, or BLE DFU |
|
||||
| `fw ...` | `-ota` images only: admin-pushed firmware update, see [ota.md](ota.md) |
|
||||
| `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)
|
||||
|
||||
@@ -123,15 +136,17 @@ tz.offset`. No exponent (`1e3`), no `nan`/`inf`.
|
||||
|
||||
## Diagnostics
|
||||
|
||||
| command | where | |
|
||||
| command | where | what |
|
||||
|---|---|---|
|
||||
| `blink [n]` / `blink on\|off` | repeater | flash a spare LED (not the BLE or TX one) `n` times (default 6, max 999), or until `blink off` (gives up after 10 min); finds a board on a bench or a node on a mast |
|
||||
| `txpwr [dBm]` | repeater | LoRa output power until reboot, with RadioLib's status; takes -9..30 |
|
||||
| `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 ([locked-bootloader.md](locked-bootloader.md)) |
|
||||
| `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 |
|
||||
| `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.
|
||||
@@ -142,12 +157,15 @@ 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 | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `ble` | on/off, PIN `own` or `build default` -- never the PIN itself |
|
||||
| `ble pin <6 digits>` | set your own PIN (saved, survives a reflash; drops every bond, so paired devices pair again) |
|
||||
| `ble on\|off` | persisted; **off after flashing** (`RPT_BLE_DEFAULT_OFF`), and `ble on` is refused while the PIN is the placeholder |
|
||||
| `blepwr [dBm\|default]` | TX power of the connection (-40, -20, -16, -12, -8, -4, 0, 2..8), applied to live connections and saved; `default` returns to the build value (0 dBm) |
|
||||
| `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
|
||||
@@ -155,9 +173,9 @@ found, look for who is connected (`ble` shows it).
|
||||
|
||||
## Passive analyzer (observer)
|
||||
|
||||
| command | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `nodes [offset]` | heard repeaters and room servers with a key to join several paths, paged |
|
||||
| `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)) |
|
||||
|
||||
@@ -173,27 +191,39 @@ console shows its state.
|
||||
|
||||
## Power and clock
|
||||
|
||||
| command | where | |
|
||||
| command | where | what |
|
||||
|---|---|---|
|
||||
| `set radio.rxps off\|on\|balanced\|max`, `level <1-10> [preamble 16\|32]` / `get radio.rxps` | all, SX1262 only (`WITH_RX_POWERSAVING`, in the releases) | RX duty cycle: the radio sleeps between short listening windows. **Off by default.** `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) |
|
||||
| `set batt.icon on\|off`, `set batt.icon.lo\|hi <mV>` | all | battery level as an icon at the end of the advertised name (off by default; with a name too long for it the icon is left out, and the reply says so) |
|
||||
| `gps duty ...` | GPS boards | the receiver runs only around a clock sync; see cli_commands.md |
|
||||
| `get pwr`, `set pwr.bootlock <mV>\|off`, `set pwr.cutoff <mV>\|off` | SenseCAP Solar repeater (`PWRMGT_RUNTIME`) | battery thresholds: don't start below the bootlock, switch a running node off below the cutoff (cutoff < bootlock, none above the battery right now); saved on the node, see [power.md](power.md) |
|
||||
| `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` | SenseCAP Solar repeater (`PWRMGT_RUNTIME`) | both thresholds, the battery now and at boot, why the node last switched off |
|
||||
| `set pwr.bootlock <mV>` | same | 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 |
|
||||
| `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 | |
|
||||
| command | what |
|
||||
|---|---|
|
||||
| `sensor read` | the live telemetry decoded into one line (`sensor list` shows only settings) |
|
||||
| `sensor set ina.shunt <mOhm>` | shunt resistance of an INA219/226/260/3221, saved across reboots |
|
||||
| `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 |
|
||||
|
||||
## 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 | |
|
||||
| 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 |
|
||||
@@ -206,7 +236,7 @@ The ones that change what a node does; set in `platformio.ini` /
|
||||
| `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: [locked-bootloader.md](locked-bootloader.md) |
|
||||
| `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` |
|
||||
|
||||
@@ -1146,11 +1146,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
text[tlen] = 0; // ensure null
|
||||
|
||||
reply_buf[0] = 0;
|
||||
if (memcmp(text, "set pin ", 8) == 0 && !_serial->isConnectionSecure()) {
|
||||
// CUSTOM (TeTeHacko): the same gate as CMD_SET_DEVICE_PIN -- through the
|
||||
// CLI, USB set the PIN it may not set directly, then paired over BLE
|
||||
strcpy(reply_buf, "Error: set pin only over paired BLE");
|
||||
} else if (!handleCommand(text, 0, reply_buf)) {
|
||||
if (!handleCommand(text, 0, reply_buf)) {
|
||||
strcat(reply_buf, "Unknown command"); // reply_buf may have cmd prefix from 'text'
|
||||
}
|
||||
out_frame[0] = RESP_CODE_CLI_REPLY;
|
||||
@@ -2130,14 +2126,7 @@ void MyMesh::enterCLIRescue() {
|
||||
extern "C" void retainedClockInvalidate() __attribute__((weak)); // NRF52Board.cpp
|
||||
|
||||
bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* reply) {
|
||||
while (*command == ' ') command++; // skip leading spaces
|
||||
|
||||
if (strlen(command) > 4 && command[2] == '|') { // optional prefix (for companion radio CLI)
|
||||
memcpy(reply, command, 3); // reflect the prefix back
|
||||
reply += 3;
|
||||
*reply = 0;
|
||||
command += 3;
|
||||
}
|
||||
cli_args::stripPrefix(command, reply);
|
||||
|
||||
if (_prefs.getRadioPrefs()->handleCommand(command, sender_timestamp, reply)) { // is radio CLI command?
|
||||
if (_prefs.getRadioPrefs()->isDirty()) { savePrefs(); }
|
||||
@@ -2211,6 +2200,17 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
#endif
|
||||
|
||||
if (memcmp(command, "set pin ", 8) == 0) {
|
||||
const char* err = nullptr;
|
||||
#ifdef LOCKED_NODE
|
||||
const bool locked = true;
|
||||
#else
|
||||
const bool locked = false;
|
||||
#endif
|
||||
if (!cli_args::canSetPin(sender_timestamp, _cli_rescue, locked,
|
||||
_serial && _serial->isConnectionSecure(), &err)) {
|
||||
strcpy(reply, err);
|
||||
return true;
|
||||
}
|
||||
long pin; // atoi(): "abc" was PIN 0, i.e. a random one
|
||||
if (!cli_args::parseInt(&command[8], 0, 999999, &pin)) {
|
||||
strcpy(reply, "Error, PIN must be 0-999999");
|
||||
@@ -2495,11 +2495,6 @@ void MyMesh::checkCLIRescueCmd() {
|
||||
cli_command[len - 1] = 0; // replace newline with C string null terminator
|
||||
|
||||
reply_buf[0] = 0;
|
||||
#ifdef LOCKED_NODE
|
||||
if (memcmp(cli_command, "set pin ", 8) == 0) { // CUSTOM (TeTeHacko): a known PIN = pair and read it all
|
||||
Serial.println(" Error: locked build");
|
||||
} else
|
||||
#endif
|
||||
if (handleCommand(cli_command, 0, reply_buf)) {
|
||||
// command was handled, print reply output
|
||||
Serial.print(" "); Serial.print(reply_buf); Serial.println();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "MyMesh.h"
|
||||
#include <algorithm>
|
||||
#include <helpers/CliArgs.h>
|
||||
#include <helpers/sensors/LPPDataHelpers.h>
|
||||
#include <helpers/UTF8Helpers.h>
|
||||
|
||||
@@ -219,9 +220,7 @@ void MyMesh::formatNodesReply(char* reply, int max_len, uint16_t offset) {
|
||||
prefix, (unsigned)n->type, (long)n->lat, (long)n->lon,
|
||||
(int)n->snr, (int)n->rssi, (unsigned long)(now - n->heard_timestamp),
|
||||
(unsigned long)n->pkt_hash, pathhex, n->name);
|
||||
int ll = strlen(line);
|
||||
if (i > offset && (dp - reply) + ll + 24 > max_len) break; // room for trailer; always emit >=1
|
||||
memcpy(dp, line, ll); dp += ll;
|
||||
if (!cli_args::appendLine(dp, reply, max_len, 24, line)) break; // room for trailer; never overflow reply
|
||||
}
|
||||
dp += sprintf(dp, "E,%d,%d", i, total);
|
||||
*dp = 0;
|
||||
@@ -276,9 +275,7 @@ void MyMesh::formatRxLogReply(char* reply, int max_len, uint32_t cursor) {
|
||||
(unsigned long)r->seq, (unsigned long)r->when,
|
||||
(unsigned long)r->pkt_hash, (unsigned)r->header,
|
||||
(int)r->snr, (int)r->rssi, pathhex);
|
||||
int ll = strlen(line);
|
||||
if (i > 0 && (dp - reply) + ll + 40 > max_len) break; // room for trailer; always emit >=1
|
||||
memcpy(dp, line, ll); dp += ll;
|
||||
if (!cli_args::appendLine(dp, reply, max_len, 40, line)) break; // room for trailer; never overflow reply
|
||||
last = r->seq;
|
||||
}
|
||||
dp += sprintf(dp, "E,%lu,%lu,%lu", (unsigned long)last, (unsigned long)oldest, (unsigned long)newest);
|
||||
@@ -1931,11 +1928,9 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strlen(command) > 4 && command[2] == '|') { // optional prefix (for companion radio CLI)
|
||||
memcpy(reply, command, 3); // reflect the prefix back
|
||||
reply += 3;
|
||||
command += 3;
|
||||
}
|
||||
const char* cmd = command;
|
||||
cli_args::stripPrefix(cmd, reply, &reply_max);
|
||||
command = const_cast<char*>(cmd);
|
||||
|
||||
// handle ACL related commands
|
||||
if (memcmp(command, "setperm ", 8) == 0) { // format: setperm {pubkey-hex} {permissions-int8}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Docs website of this fork (https://tth-pub.pages.rfa.cz/meshcore-tth/),
|
||||
# built by .github/docs-site.sh. Its own file, not an INHERIT of upstream's
|
||||
# mkdocs.yml (that one is Material: logo, features, palette): theme
|
||||
# mkdocs-terminal, palette "dark" with docs/_stylesheets/tth.css on top.
|
||||
site_name: MeshCore TTH
|
||||
site_url: https://tth-pub.pages.rfa.cz/meshcore-tth/
|
||||
site_description: MeshCore fork meshcore-tth -- repeater antispam, diagnostics, OTA, Czech mesh defaults
|
||||
repo_name: tth-pub/meshcore-tth
|
||||
repo_url: https://git.rfa.cz/tth-pub/meshcore-tth
|
||||
edit_uri: src/branch/main/docs/
|
||||
|
||||
theme:
|
||||
name: terminal
|
||||
palette: dark
|
||||
features:
|
||||
# no blinking cursor after the site name (user, 2. 12. 2026)
|
||||
- navigation.top.cursor_animation.hide
|
||||
- navigation.side.indexes
|
||||
|
||||
extra_css:
|
||||
- _stylesheets/tth.css
|
||||
|
||||
plugins:
|
||||
- search
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- github-callouts
|
||||
- attr_list
|
||||
- tables
|
||||
- toc
|
||||
- pymdownx.details
|
||||
- pymdownx.superfences
|
||||
|
||||
# One language for the site: English (every doc in docs/ is English); the
|
||||
# Czech half of the README is one page, "Česky", in the top bar. Titles in
|
||||
# both languages side by side were confusing (user, 2. 12. 2026).
|
||||
nav:
|
||||
- About the fork: index.md
|
||||
- Česky: cs.md
|
||||
- Fork meshcore-tth:
|
||||
- Console commands: tth-commands.md
|
||||
- Firmware update by the admin (OTA): ota.md
|
||||
- Power saving: power.md
|
||||
- Budka as a sensor: budka-sensor.md
|
||||
- BLE/LoRa coexistence: ble-lora-coexistence.md
|
||||
- MeshCore (upstream):
|
||||
- Introduction: meshcore.md
|
||||
- FAQ: faq.md
|
||||
- CLI commands: cli_commands.md
|
||||
- Companion CLI: companion_cli.md
|
||||
- Companion protocol: companion_protocol.md
|
||||
- Terminal chat CLI: terminal_chat_cli.md
|
||||
- KISS modem protocol: kiss_modem_protocol.md
|
||||
- Packet format: packet_format.md
|
||||
- Payloads: payloads.md
|
||||
- Stats binary frames: stats_binary_frames.md
|
||||
- Number allocations: number_allocations.md
|
||||
- QR codes: qr_codes.md
|
||||
- Radio presets: radio_presets.md
|
||||
- nRF52 power management: nrf52_power_management.md
|
||||
@@ -11,7 +11,9 @@
|
||||
// float a '.' and fraction. No exponent, no hex, no trailing text.
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace cli_args {
|
||||
|
||||
@@ -53,4 +55,45 @@ inline bool parseFloat(const char* s, float lo, float hi, float* out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Strips leading spaces and an optional 3-byte "XX|" prefix (reflected into
|
||||
// `reply`, deducting 3 from `*reply_max` when provided).
|
||||
inline void stripPrefix(const char*& command, char*& reply, int* reply_max = nullptr) {
|
||||
while (*command == ' ') command++;
|
||||
if (strlen(command) > 4 && command[2] == '|') {
|
||||
if (!reply_max || *reply_max >= 3) {
|
||||
memcpy(reply, command, 3);
|
||||
reply += 3;
|
||||
*reply = 0;
|
||||
if (reply_max) *reply_max -= 3;
|
||||
}
|
||||
command += 3;
|
||||
while (*command == ' ') command++;
|
||||
}
|
||||
}
|
||||
|
||||
// Security gate for companion `set pin`: blocked in locked CLI rescue and over
|
||||
// unencrypted local transports (USB), allowed over paired BLE or remote ACL.
|
||||
inline bool canSetPin(uint32_t sender_timestamp, bool cli_rescue, bool locked_node,
|
||||
bool serial_secure, const char** err_out = nullptr) {
|
||||
if (locked_node && cli_rescue) {
|
||||
if (err_out) *err_out = "Error: locked build";
|
||||
return false;
|
||||
}
|
||||
if (sender_timestamp == 0 && !cli_rescue && !serial_secure) {
|
||||
if (err_out) *err_out = "Error: set pin only over paired BLE";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Appends `line` to a paged CLI reply only if it fits with `trailer_reserve`
|
||||
// bytes left for the end marker; returns false when the page is full.
|
||||
inline bool appendLine(char*& dp, const char* reply, int max_len, int trailer_reserve, const char* line) {
|
||||
int ll = (int)strlen(line);
|
||||
if ((dp - reply) + ll + trailer_reserve > max_len) return false;
|
||||
memcpy(dp, line, ll);
|
||||
dp += ll;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace cli_args
|
||||
@@ -63,9 +63,10 @@ void ClientACL::load(FILESYSTEM* fs, const mesh::LocalIdentity& self_id) {
|
||||
#define ACL_TS_RECORD (ACL_TS_PREFIX + 4)
|
||||
|
||||
static const char* tsFilename(uint8_t slot) { return slot ? "/s_acl_ts1" : "/s_acl_ts0"; }
|
||||
static uint8_t s_ts_buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
|
||||
|
||||
void ClientACL::loadTimestamps() {
|
||||
static uint8_t buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
|
||||
uint8_t* buf = s_ts_buf;
|
||||
_num_ts_orphans = 0;
|
||||
_ts_seq = 0;
|
||||
_ts_slot = 0;
|
||||
@@ -78,7 +79,7 @@ void ClientACL::loadTimestamps() {
|
||||
File file = _fs->open(tsFilename(slot));
|
||||
#endif
|
||||
if (!file) continue;
|
||||
int len = file.read(buf, sizeof(buf));
|
||||
int len = file.read(buf, sizeof(s_ts_buf));
|
||||
file.close();
|
||||
if (len < 8 || (len - 8) % ACL_TS_RECORD != 0) continue;
|
||||
|
||||
@@ -121,7 +122,7 @@ void ClientACL::loadTimestamps() {
|
||||
|
||||
void ClientACL::saveTimestamps() {
|
||||
if (!_fs) return;
|
||||
static uint8_t buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
|
||||
uint8_t* buf = s_ts_buf;
|
||||
int len = 0;
|
||||
for (int i = 0; i < num_clients; i++) {
|
||||
if (clients[i].saved_timestamp == 0) continue;
|
||||
@@ -142,10 +143,10 @@ void ClientACL::saveTimestamps() {
|
||||
|
||||
File file = openWrite(_fs, tsFilename(_ts_slot));
|
||||
if (file) {
|
||||
file.write(buf, len);
|
||||
size_t written = file.write(buf, len);
|
||||
file.close();
|
||||
if (written == (size_t)len) _ts_slot ^= 1;
|
||||
}
|
||||
_ts_slot ^= 1;
|
||||
}
|
||||
|
||||
void ClientACL::orphanTimestamp(const ClientInfo* c) {
|
||||
|
||||
@@ -62,7 +62,7 @@ static int in_shift_phase(void) {
|
||||
static int cb_read(void *arg, void *dst, uintptr_t src, size_t size) {
|
||||
fwp_job *j = (fwp_job *)arg;
|
||||
uint8_t *d = (uint8_t *)dst;
|
||||
if (src + size > j->mem_size) return j->err = FWP_ERR_ARGS;
|
||||
if (src > j->mem_size || size > j->mem_size - src) return j->err = FWP_ERR_ARGS;
|
||||
if (!in_shift_phase() && src < j->written_end) return j->err = FWP_ERR_OVERREAD;
|
||||
while (size > 0) {
|
||||
uintptr_t a = src;
|
||||
@@ -106,7 +106,7 @@ static int cb_erase(void *arg, uintptr_t addr, size_t size) {
|
||||
|
||||
static int cb_write(void *arg, uintptr_t dst, void *src, size_t size) {
|
||||
fwp_job *j = (fwp_job *)arg;
|
||||
if (j->page_addr == NO_PAGE || dst < j->page_addr || dst + size > j->page_addr + FWP_PAGE)
|
||||
if (j->page_addr == NO_PAGE || dst < j->page_addr || size > FWP_PAGE - (dst - j->page_addr))
|
||||
return j->err = FWP_ERR_ORDER;
|
||||
fwp_copy(&g_page[dst - j->page_addr], (const uint8_t *)src, (uint32_t)size);
|
||||
if (j->dry && !in_shift_phase()) j->sink(j->sink_ctx, (const uint8_t *)src, (uint32_t)size);
|
||||
|
||||
@@ -743,9 +743,9 @@ void FwUpdate::cmdBegin(uint32_t sender_timestamp, const char *arg, char *reply)
|
||||
strcpy(reply, "ERR: fw begin <bytes>");
|
||||
return;
|
||||
}
|
||||
if (stage + total > FW_OTA_STAGE_END) {
|
||||
if (stage >= FW_OTA_STAGE_END || total > FW_OTA_STAGE_END - stage) {
|
||||
sprintf(reply, "ERR: %lu B does not fit, %lu free", (unsigned long)total,
|
||||
(unsigned long)(FW_OTA_STAGE_END - stage));
|
||||
(unsigned long)(stage < FW_OTA_STAGE_END ? FW_OTA_STAGE_END - stage : 0));
|
||||
return;
|
||||
}
|
||||
_stage = stage;
|
||||
@@ -975,6 +975,7 @@ void FwUpdate::cmdApply(uint32_t sender_timestamp, const char *arg, char *reply)
|
||||
_apply_force = force;
|
||||
_apply_err[0] = 0;
|
||||
_apply_at = millis() + 2000; // let the reply go out first
|
||||
if (_apply_at == 0) _apply_at = 1;
|
||||
sprintf(reply, "OK applying %s in 2 s (batt %umV%s), back in ~20 s", _version, mv,
|
||||
_board.isExternalPowered() ? ", USB" : "");
|
||||
}
|
||||
|
||||
@@ -323,6 +323,7 @@ bool NodeMaintenance::dfuCommand(uint32_t sender_timestamp, const char* command,
|
||||
return true;
|
||||
}
|
||||
_dfu_at = millis() + 700;
|
||||
if (_dfu_at == 0) _dfu_at = 1;
|
||||
_dfu_mode = (strcmp(arg, "serial") == 0) ? 1 : (strcmp(arg, "ota") == 0 ? 2 : 0);
|
||||
#else
|
||||
strcpy(reply, "ERR: not an nRF52 board");
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
// first accepted sync), so a spoofer cannot walk the clock away.
|
||||
// A trusted fix that keeps disagreeing with the clock by the same offset raises an alert;
|
||||
// the operator can then accept that GPS time (acceptAlertedTime()).
|
||||
//
|
||||
// epochFromFields() is always available, with or without GPS_GUARD: the location providers use it
|
||||
// to turn the receiver's date and time into an epoch.
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
@@ -106,6 +109,20 @@ class GpsGuard {
|
||||
}
|
||||
|
||||
public:
|
||||
// UTC date and time fields as reported by a receiver -> Unix epoch, or 0 if any field is out of
|
||||
// range. Receivers (and their libraries) hand these over unchecked: MicroNMEA turns any two
|
||||
// characters into a value 0..255, and both RTClib's DateTime and SparkFun's getUnixEpoch() index
|
||||
// their days-per-month tables with the month without a range check.
|
||||
static uint32_t epochFromFields(uint16_t year, uint8_t month, uint8_t day,
|
||||
uint8_t hour, uint8_t minute, uint8_t second) {
|
||||
static const uint8_t days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
if (year < 2020 || year > 2099 || month < 1 || month > 12) return 0;
|
||||
uint8_t mdays = days_in_month[month - 1];
|
||||
if (month == 2 && year % 4 == 0) mdays = 29; // 2020..2099: every fourth year is a leap year
|
||||
if (day < 1 || day > mdays || hour > 23 || minute > 59 || second > 60) return 0; // 60: leap second
|
||||
return DateTime(year, month, day, hour, minute, second).unixtime();
|
||||
}
|
||||
|
||||
// Plausible GPS time window: not before this firmware was built, at most 10 years after.
|
||||
static uint32_t minEpoch() {
|
||||
static const uint32_t min_epoch = DateTime(__DATE__, __TIME__).unixtime() - 86400;
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
#include <MicroNMEA.h>
|
||||
#include <RTClib.h>
|
||||
#include <string.h>
|
||||
#ifdef GPS_GUARD
|
||||
#include "GpsGuard.h"
|
||||
#endif
|
||||
#include "GpsGuard.h" // epochFromFields(); the guard itself only with GPS_GUARD
|
||||
|
||||
#ifndef GPS_PERIODIC_ACQUISITION_TIMEOUT_MS
|
||||
#define GPS_PERIODIC_ACQUISITION_TIMEOUT_MS 300000UL
|
||||
@@ -161,7 +159,7 @@ class MicroNMEALocationProvider : public LocationProvider {
|
||||
(millis() - _last_time_sync) > TIME_SYNC_INTERVAL) {
|
||||
_time_sync_needed = true;
|
||||
}
|
||||
if (_time_sync_needed && time_valid > 2 && _clock != nullptr && timeSyncAllowed()) {
|
||||
if (_time_sync_needed && time_valid > 2 && _clock != nullptr && currentEpoch() != 0 && timeSyncAllowed()) {
|
||||
_clock->setCurrentTime(getTimestamp());
|
||||
_time_sync_needed = false;
|
||||
_last_time_sync = millis();
|
||||
@@ -175,6 +173,12 @@ class MicroNMEALocationProvider : public LocationProvider {
|
||||
return _clock == nullptr || !_time_sync_needed || time_valid > 3;
|
||||
}
|
||||
|
||||
// the receiver's current date and time, or 0 if a field is out of range
|
||||
uint32_t currentEpoch() {
|
||||
return GpsGuard::epochFromFields(nmea.getYear(), nmea.getMonth(), nmea.getDay(),
|
||||
nmea.getHour(), nmea.getMinute(), nmea.getSecond());
|
||||
}
|
||||
|
||||
bool timeSyncAllowed() {
|
||||
#ifdef GPS_GUARD
|
||||
return _guard.acceptTime(getTimestamp(), _clock->getCurrentTime());
|
||||
@@ -299,14 +303,14 @@ public:
|
||||
|
||||
// GPS time minus clock time, from a current fix with a settled time
|
||||
bool getClockOffset(long& offset) override {
|
||||
if (_clock == nullptr || !isValid() || time_valid < 3) return false;
|
||||
if (_clock == nullptr || !isValid() || time_valid < 3 || currentEpoch() == 0) return false;
|
||||
offset = (long)getTimestamp() - (long)_clock->getCurrentTime();
|
||||
return true;
|
||||
}
|
||||
|
||||
// write the current GPS time to the clock now (caller has done its own checks)
|
||||
bool applyTimeNow() override {
|
||||
if (_clock == nullptr || !isValid() || time_valid < 3) return false;
|
||||
if (_clock == nullptr || !isValid() || time_valid < 3 || currentEpoch() == 0) return false;
|
||||
_clock->setCurrentTime(getTimestamp());
|
||||
_time_sync_needed = false;
|
||||
_last_time_sync = millis();
|
||||
@@ -319,9 +323,8 @@ public:
|
||||
|
||||
long getTimestamp() override {
|
||||
if (!nmea.isValid()) return _lastFix.timestamp;
|
||||
DateTime dt(nmea.getYear(), nmea.getMonth(), nmea.getDay(),
|
||||
nmea.getHour(), nmea.getMinute(), nmea.getSecond());
|
||||
return dt.unixtime();
|
||||
uint32_t t = currentEpoch();
|
||||
return t != 0 ? t : _lastFix.timestamp;
|
||||
}
|
||||
|
||||
void drain() override { _driver->drain(); }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GpsDriver.h"
|
||||
|
||||
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
|
||||
#include "GpsGuard.h" // epochFromFields()
|
||||
|
||||
// Driver for the RAK12500 (u-blox, I2C). Serial NMEA modules are handled by NmeaGpsDriver.
|
||||
class RakI2cGpsDriver : public GpsDriver {
|
||||
@@ -11,6 +12,7 @@ class RakI2cGpsDriver : public GpsDriver {
|
||||
uint8_t _powerPin = 0;
|
||||
bool _detected = false;
|
||||
bool _started = false;
|
||||
bool _pvtSeen = false; // a NAV-PVT has been received since boot
|
||||
|
||||
bool probeRak12500(uint8_t powerPin) {
|
||||
#if defined(ETHERNET_ENABLED) && defined(RAK_BOARD)
|
||||
@@ -95,10 +97,24 @@ public:
|
||||
|
||||
bool isDetected() const { return _detected; }
|
||||
|
||||
bool hasFix() { return _started && _gnss.getGnssFixOk(8); }
|
||||
bool hasFix() {
|
||||
if (!_started) return false;
|
||||
// The library allocates its NAV-PVT record without clearing it: until the first reply has
|
||||
// arrived, the fix flag and every other field are whatever was on the heap.
|
||||
if (!_pvtSeen) {
|
||||
if (!_gnss.getPVT(8)) return false;
|
||||
_pvtSeen = true;
|
||||
}
|
||||
return _gnss.getGnssFixOk(8);
|
||||
}
|
||||
long getLatitude() { return _gnss.getLatitude(2) / 10; }
|
||||
long getLongitude() { return _gnss.getLongitude(2) / 10; }
|
||||
long getAltitude() { return _gnss.getAltitude(2); }
|
||||
long getSatellites() { return _gnss.getSIV(2); }
|
||||
long getTimestamp() { return _gnss.getUnixEpoch(2); }
|
||||
// Not getUnixEpoch(): it indexes its day tables with the module's year and month unchecked.
|
||||
// 0 (no time; RakLocationProvider then leaves the clock alone) for a date or time out of range.
|
||||
long getTimestamp() {
|
||||
return GpsGuard::epochFromFields(_gnss.getYear(2), _gnss.getMonth(2), _gnss.getDay(2),
|
||||
_gnss.getHour(2), _gnss.getMinute(2), _gnss.getSecond(2));
|
||||
}
|
||||
};
|
||||
@@ -340,53 +340,104 @@ public:
|
||||
}
|
||||
|
||||
if (_page == HomePage::FIRST) {
|
||||
display.setColor(UIColor::primary_txt);
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
// smaller unread message ui for wifi variants
|
||||
display.setTextSize(1);
|
||||
sprintf(tmp, "Unread Msg: %d", _task->getMsgCount());
|
||||
display.drawTextCentered(display.width() / 2, 22, tmp);
|
||||
#else
|
||||
// larger unread message ui for non wifi variants
|
||||
display.setTextSize(2);
|
||||
sprintf(tmp, "MSG: %d", _task->getMsgCount());
|
||||
display.drawTextCentered(display.width() / 2, 22, tmp);
|
||||
#endif
|
||||
static constexpr uint32_t MIN_VALID_RTC_EPOCH = 1735689600UL; // 2025-01-01 00:00:00 UTC
|
||||
uint32_t raw_now = _rtc->getCurrentTime();
|
||||
bool rtc_valid = (raw_now >= MIN_VALID_RTC_EPOCH);
|
||||
const bool compact_screen = (display.height() < 120);
|
||||
|
||||
char time_str[8] = "--:--";
|
||||
char date_str[12] = "";
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.setTextSize(3);
|
||||
uint32_t now = _rtc->getCurrentTime();
|
||||
now += (int32_t)(_node_prefs->tz_offset * 3600);
|
||||
DateTime dt (now);
|
||||
sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute());
|
||||
display.drawTextCentered(display.width() / 2, 60, tmp);
|
||||
display.setTextSize(1);
|
||||
sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
|
||||
display.drawTextCentered(display.width() / 2, 80, tmp);
|
||||
if (rtc_valid) {
|
||||
uint32_t local_now = (uint32_t)((int64_t)raw_now + (int64_t)(_node_prefs->tz_offset * 3600.0f));
|
||||
DateTime dt (local_now);
|
||||
snprintf(time_str, sizeof(time_str), "%02d:%02d", dt.hour(), dt.minute());
|
||||
if (compact_screen) {
|
||||
snprintf(date_str, sizeof(date_str), "%02d/%02d/%02d", dt.day(), dt.month(), dt.year() % 100);
|
||||
} else {
|
||||
snprintf(date_str, sizeof(date_str), "%02d/%02d/%d", dt.day(), dt.month(), dt.year());
|
||||
}
|
||||
} else {
|
||||
strcpy(date_str, compact_screen ? "--/--/--" : "--/--/----");
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
|
||||
if (_node_prefs->ui_show_clock && compact_screen) {
|
||||
display.setColor(UIColor::primary_txt);
|
||||
display.setTextSize(1);
|
||||
snprintf(tmp, sizeof(tmp), "MSG:%d", _task->getMsgCount());
|
||||
display.drawTextLeftAlign(0, 19, tmp);
|
||||
display.setColor(UIColor::secondary_txt);
|
||||
display.drawTextRightAlign(display.width() - 1, 19, date_str);
|
||||
|
||||
display.setColor(UIColor::primary_txt);
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 29, time_str);
|
||||
IPAddress ip = WiFi.localIP();
|
||||
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 32, tmp);
|
||||
#endif
|
||||
if (_task->hasConnection()) {
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.setTextSize(1);
|
||||
if (_node_prefs->ui_show_clock)
|
||||
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
|
||||
else
|
||||
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
|
||||
// CUSTOM (TeTeHacko): jen kdyz BT opravdu bezi -- jinak displej nabizi PIN
|
||||
// k parovani, ktere neni jak navazat.
|
||||
} else if (_task->getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
|
||||
display.setColor(UIColor::warning_txt);
|
||||
sprintf(tmp, "Pin:%d", _task->getBLEPin());
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.drawTextCentered(display.width() / 2, 40, tmp);
|
||||
#else
|
||||
display.setTextSize(2);
|
||||
display.drawTextCentered(display.width() / 2, 30, time_str);
|
||||
#endif
|
||||
|
||||
if (_task->hasConnection()) {
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 110, tmp);
|
||||
} else {
|
||||
display.setTextSize(2);
|
||||
display.drawTextCentered(display.width() / 2, 43, tmp);
|
||||
display.drawTextCentered(display.width() / 2, 51, "< Connected >");
|
||||
// CUSTOM (TeTeHacko): jen kdyz BT opravdu bezi -- jinak displej nabizi PIN
|
||||
// k parovani, ktere neni jak navazat.
|
||||
} else if (_task->getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.setTextSize(1);
|
||||
snprintf(tmp, sizeof(tmp), "Pin:%lu", (unsigned long)_task->getBLEPin());
|
||||
display.drawTextCentered(display.width() / 2, 51, tmp);
|
||||
}
|
||||
} else {
|
||||
display.setColor(UIColor::primary_txt);
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
// smaller unread message ui for wifi variants
|
||||
display.setTextSize(1);
|
||||
sprintf(tmp, "Unread Msg: %d", _task->getMsgCount());
|
||||
display.drawTextCentered(display.width() / 2, 22, tmp);
|
||||
#else
|
||||
// larger unread message ui for non wifi variants
|
||||
display.setTextSize(2);
|
||||
sprintf(tmp, "MSG: %d", _task->getMsgCount());
|
||||
display.drawTextCentered(display.width() / 2, 22, tmp);
|
||||
#endif
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.setTextSize(3);
|
||||
display.drawTextCentered(display.width() / 2, 60, time_str);
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 80, date_str);
|
||||
}
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
IPAddress ip = WiFi.localIP();
|
||||
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 32, tmp);
|
||||
#endif
|
||||
if (_task->hasConnection()) {
|
||||
display.setColor(UIColor::warning_txt);
|
||||
display.setTextSize(1);
|
||||
if (_node_prefs->ui_show_clock)
|
||||
display.drawTextCentered(display.width() / 2, 110, "< Connected >");
|
||||
else
|
||||
display.drawTextCentered(display.width() / 2, 43, "< Connected >");
|
||||
// CUSTOM (TeTeHacko): jen kdyz BT opravdu bezi -- jinak displej nabizi PIN
|
||||
// k parovani, ktere neni jak navazat.
|
||||
} else if (_task->getBLEPin() != 0 && _task->isBluetoothEnabled()) { // BT pin
|
||||
display.setColor(UIColor::warning_txt);
|
||||
sprintf(tmp, "Pin:%lu", (unsigned long)_task->getBLEPin());
|
||||
if (_node_prefs->ui_show_clock) {
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 110, tmp);
|
||||
} else {
|
||||
display.setTextSize(2);
|
||||
display.drawTextCentered(display.width() / 2, 43, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (_page == HomePage::RECENT) {
|
||||
|
||||
@@ -18,11 +18,12 @@ class File {
|
||||
std::string _name;
|
||||
size_t _pos = 0;
|
||||
bool _write = false;
|
||||
size_t _short_write = 0;
|
||||
|
||||
public:
|
||||
File() = default;
|
||||
File(std::map<std::string, std::string>* files, const std::string& name, bool write)
|
||||
: _files(files), _name(name), _write(write) {
|
||||
File(std::map<std::string, std::string>* files, const std::string& name, bool write, size_t short_write = 0)
|
||||
: _files(files), _name(name), _write(write), _short_write(short_write) {
|
||||
if (write) (*_files)[name] = "";
|
||||
}
|
||||
explicit operator bool() const { return _files != nullptr; }
|
||||
@@ -34,8 +35,9 @@ public:
|
||||
return (int)n;
|
||||
}
|
||||
size_t write(const uint8_t* buf, size_t len) {
|
||||
(*_files)[_name].append((const char*)buf, len);
|
||||
return len;
|
||||
size_t n = (_short_write > 0 && _short_write < len) ? _short_write : len;
|
||||
(*_files)[_name].append((const char*)buf, n);
|
||||
return n;
|
||||
}
|
||||
void close() {}
|
||||
};
|
||||
@@ -46,14 +48,22 @@ class Adafruit_LittleFS {
|
||||
public:
|
||||
std::map<std::string, std::string> files;
|
||||
int writes = 0;
|
||||
bool fail_next_write_open = false;
|
||||
size_t short_next_write = 0;
|
||||
|
||||
bool exists(const char* name) { return files.count(name) > 0; }
|
||||
bool remove(const char* name) { return files.erase(name) > 0; }
|
||||
bool mkdir(const char*) { return true; }
|
||||
Adafruit_LittleFS_Namespace::File open(const char* name, uint8_t mode = FILE_O_READ) {
|
||||
if (mode == FILE_O_WRITE) {
|
||||
if (fail_next_write_open) {
|
||||
fail_next_write_open = false;
|
||||
return Adafruit_LittleFS_Namespace::File();
|
||||
}
|
||||
writes++;
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, true);
|
||||
size_t sw = short_next_write;
|
||||
short_next_write = 0;
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, true, sw);
|
||||
}
|
||||
if (!exists(name)) return Adafruit_LittleFS_Namespace::File();
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, false);
|
||||
|
||||
@@ -187,6 +187,44 @@ TEST(AclReplayFloor, AlternatesSlotsAcrossReboots) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AclReplayFloor, FailedOpenDoesNotRotateSlot) {
|
||||
Node n;
|
||||
ClientInfo* c = n.admin(1);
|
||||
ASSERT_TRUE(n.accept(c, NOW - 30)); // slot 0 -> next slot 1
|
||||
ASSERT_TRUE(n.accept(c, NOW - 20)); // slot 1 -> next slot 0 (oldest)
|
||||
n.acl->save(&n.fs);
|
||||
|
||||
// Open fails on slot 0: must NOT advance to slot 1 (which holds NOW - 20).
|
||||
n.fs.fail_next_write_open = true;
|
||||
ASSERT_TRUE(n.accept(c, NOW - 15));
|
||||
|
||||
// Next write is torn; because slot stayed 0, slot 1 (NOW - 20) stays intact.
|
||||
n.fs.short_next_write = 5;
|
||||
ASSERT_TRUE(n.accept(c, NOW - 10));
|
||||
|
||||
n.boot();
|
||||
c = n.acl->getClient(idFor(1).pub_key, PUB_KEY_SIZE);
|
||||
EXPECT_EQ(c->last_timestamp, NOW - 20);
|
||||
}
|
||||
|
||||
TEST(AclReplayFloor, ShortWriteDoesNotRotateSlot) {
|
||||
Node n;
|
||||
ClientInfo* c = n.admin(1);
|
||||
ASSERT_TRUE(n.accept(c, NOW - 30)); // slot 0
|
||||
ASSERT_TRUE(n.accept(c, NOW - 20)); // slot 1
|
||||
n.acl->save(&n.fs);
|
||||
|
||||
// Two consecutive short writes must both target slot 0 and leave slot 1 intact.
|
||||
n.fs.short_next_write = 4;
|
||||
ASSERT_TRUE(n.accept(c, NOW - 15));
|
||||
n.fs.short_next_write = 4;
|
||||
ASSERT_TRUE(n.accept(c, NOW - 10));
|
||||
|
||||
n.boot();
|
||||
c = n.acl->getClient(idFor(1).pub_key, PUB_KEY_SIZE);
|
||||
EXPECT_EQ(c->last_timestamp, NOW - 20);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
@@ -49,6 +49,88 @@ TEST(CliArgsFloat, RefusesNanInfExponentAndGarbage) {
|
||||
EXPECT_FALSE(parseFloat("91", -90, 90, &f));
|
||||
EXPECT_EQ(f, 1);
|
||||
}
|
||||
|
||||
TEST(CliPrefix, StripsSpacesAndReflectsPrefixWithBudget) {
|
||||
char buf[32] = {};
|
||||
char* reply = buf;
|
||||
int max_len = 150;
|
||||
const char* cmd = " 01| set pin 123456";
|
||||
cli_args::stripPrefix(cmd, reply, &max_len);
|
||||
EXPECT_STREQ(cmd, "set pin 123456");
|
||||
EXPECT_STREQ(buf, "01|");
|
||||
EXPECT_EQ(reply, buf + 3);
|
||||
EXPECT_EQ(max_len, 147);
|
||||
}
|
||||
|
||||
TEST(CliPrefix, LeadingSpacesWithoutPrefix) {
|
||||
char buf[16] = {};
|
||||
char* reply = buf;
|
||||
int max_len = 150;
|
||||
const char* cmd = " set pin 123456";
|
||||
cli_args::stripPrefix(cmd, reply, &max_len);
|
||||
EXPECT_STREQ(cmd, "set pin 123456");
|
||||
EXPECT_STREQ(buf, "");
|
||||
EXPECT_EQ(reply, buf);
|
||||
EXPECT_EQ(max_len, 150);
|
||||
}
|
||||
|
||||
TEST(CliPrefix, TinyBudgetDoesNotOverflowOrGoNegative) {
|
||||
char buf[4] = {'X', 'X', 'X', 0};
|
||||
char* reply = buf;
|
||||
int max_len = 2;
|
||||
const char* cmd = "01|nodes";
|
||||
cli_args::stripPrefix(cmd, reply, &max_len);
|
||||
EXPECT_STREQ(cmd, "nodes");
|
||||
EXPECT_EQ(reply, buf);
|
||||
EXPECT_EQ(max_len, 2);
|
||||
}
|
||||
|
||||
TEST(CliSetPinGate, EnforcesTransportAndLockedBuild) {
|
||||
const char* err = nullptr;
|
||||
// Local USB (unsecured, not rescue) -> blocked
|
||||
EXPECT_FALSE(cli_args::canSetPin(0, false, false, false, &err));
|
||||
EXPECT_STREQ(err, "Error: set pin only over paired BLE");
|
||||
|
||||
// Locked CLI rescue -> blocked
|
||||
EXPECT_FALSE(cli_args::canSetPin(0, true, true, false, &err));
|
||||
EXPECT_STREQ(err, "Error: locked build");
|
||||
|
||||
// Paired BLE -> allowed
|
||||
EXPECT_TRUE(cli_args::canSetPin(0, false, true, true, &err));
|
||||
|
||||
// Unlocked CLI rescue -> allowed
|
||||
EXPECT_TRUE(cli_args::canSetPin(0, true, false, false, &err));
|
||||
|
||||
// Remote ACL admin (sender_timestamp != 0) -> allowed
|
||||
EXPECT_TRUE(cli_args::canSetPin(1763400000u, false, true, false, &err));
|
||||
}
|
||||
|
||||
TEST(CliPagedReply, NeverOverflowsSmallMeshBufferWithPrefix) {
|
||||
// Exact mesh CLI size: 150 B reply buffer, 3 B taken by "01|", leaving 147 B.
|
||||
char buf[150] = {};
|
||||
char* reply = buf;
|
||||
int max_len = (int)sizeof(buf);
|
||||
const char* cmd = "01|nodes";
|
||||
cli_args::stripPrefix(cmd, reply, &max_len);
|
||||
|
||||
char* dp = reply;
|
||||
std::string long_line(140, 'A');
|
||||
long_line.push_back('\n');
|
||||
// 141 B line + 24 B trailer reserve > 147 B -> must refuse even as first line
|
||||
EXPECT_FALSE(cli_args::appendLine(dp, reply, max_len, 24, long_line.c_str()));
|
||||
EXPECT_EQ(dp, reply);
|
||||
|
||||
std::string short_line(50, 'B');
|
||||
short_line.push_back('\n');
|
||||
EXPECT_TRUE(cli_args::appendLine(dp, reply, max_len, 24, short_line.c_str()));
|
||||
EXPECT_TRUE(cli_args::appendLine(dp, reply, max_len, 24, short_line.c_str()));
|
||||
EXPECT_FALSE(cli_args::appendLine(dp, reply, max_len, 24, short_line.c_str()));
|
||||
|
||||
dp += sprintf(dp, "E,2,3");
|
||||
*dp = 0;
|
||||
EXPECT_LT((size_t)(dp - buf), sizeof(buf));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
@@ -223,6 +223,7 @@ build_flags =
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D ENV_INCLUDE_GPS=1 ; enable the GPS page in UI
|
||||
-D UI_SHOW_CLOCK=1 ; show clock and date on home screen by default
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
@@ -245,6 +246,7 @@ build_flags =
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D ENABLE_USB_INTERFACE
|
||||
-D UI_SHOW_CLOCK=1 ; show clock and date on home screen by default
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
|
||||
Reference in new issue
Block a user