meshcore_fw_ota: the transfer as an Ansible-free engine shared with meshcore-tth's tools, plus a side channel via tempradio
ci / test (push) Failing after 15s
ci / test (push) Failing after 15s
module_utils/meshcore_ota_engine.py now holds the whole transfer (Console, Radio, binary and text rounds, update()); the module only maps its parameters. tools/ota_mesh_push.py and tools/ota_push.py of meshcore-tth import the same code, so the protocol lives in one place. New: - side/window: the node goes to another preset by `tempradio`, the companion is retuned (checked -- an openHop virtual companion acks set_radio as a no-op and is refused), a fresh login goes zero-hop and the delta follows; the window is renewed, and the node and companion come back at the end (or the node by its own timer). - SerialConsole: the node's USB console, the same calls as BleConsole. - `fw base` when `fw status` shows no base (failed/ready/rx): a node left after a refused package was taken for "not an -ota build", i.e. a full DFU, and `resume` could never pick its package. - asyncio.TimeoutError caught too: on Python 3.10 (dopey) a lost bitmap reply ended the whole transfer. - text: text chunks only; update(force=...) for `fw apply force`. Bench 16. 11. 2026 (x3 companion -> x1 -ota repeater, 866.5 -> side 866.0/SF7): the module from dopey (py3.10), the firmware role's ota.yml with mc_fw_ota_side, ota_mesh_push.py and ota_push.py over USB -- each applied a 2.7 kB delta, ~20 s airtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8306d91b48
commit
185470de08
7 files changed
+922
-375
No files matched your search
@@ -2,7 +2,8 @@
|
||||
|
||||
Kept apart from meshcore_fw_ota so they can be unit-tested: which package fits
|
||||
the node, the chunk framing, and what a transfer costs on air. The protocol
|
||||
itself is the reference client's, tools/ota_mesh_push.py of meshcore-tth.
|
||||
itself is in meshcore_ota_engine, which tools/ota_mesh_push.py of meshcore-tth
|
||||
uses too.
|
||||
|
||||
A package (`.mcfw`, tools/ota_pack.py) is a 256 B manifest and a payload:
|
||||
0 magic "MCFW" | 4 format 1 (full image) or 2 (delta) | 5 layout
|
||||
@@ -52,6 +53,14 @@ def parse_status(text):
|
||||
return (int(m.group(1)), m.group(2)) if m else None
|
||||
|
||||
|
||||
def parse_base(text):
|
||||
"""`fw base` -> (None, sha256 prefix) or None. It answers in any state of a
|
||||
transfer ('> <64 hex>', on the local console a fresh hash after it), where
|
||||
`fw status` shows the base only when idle."""
|
||||
m = re.match(r">\s*([0-9a-f]{64})", text or "")
|
||||
return (None, m.group(1)[:8]) if m else None
|
||||
|
||||
|
||||
def pick(packages, base, full_ok):
|
||||
"""('current', pkg) | ('delta', pkg) | ('full', pkg) | ('none', None).
|
||||
|
||||
@@ -169,3 +178,43 @@ class Bucket:
|
||||
self.used += secs
|
||||
return 0.0
|
||||
return (secs - self.level) / self.rate
|
||||
|
||||
|
||||
# ── side channel (tempradio) ────────────────────────────────────────────────
|
||||
|
||||
|
||||
def parse_preset(text):
|
||||
"""'869.525,62.5,7,5' (freq MHz, bw kHz, sf, cr) -> tuple, in the ranges `tempradio` takes."""
|
||||
try:
|
||||
f, bw, sf, cr = str(text).split(",")
|
||||
p = (float(f), float(bw), int(sf), int(cr))
|
||||
except ValueError:
|
||||
raise ValueError(f"side preset {text!r}: freq,bw,sf,cr (e.g. 869.525,62.5,7,5)") from None
|
||||
if not (150 <= p[0] <= 2500 and 7 <= p[1] <= 500 and 5 <= p[2] <= 12 and 5 <= p[3] <= 8):
|
||||
raise ValueError(f"side preset {text!r}: out of range (freq MHz, bw kHz, sf 5-12, cr 5-8)")
|
||||
return p
|
||||
|
||||
|
||||
def fmt_preset(p):
|
||||
return f"{p[0]:g},{p[1]:g},{p[2]},{p[3]}"
|
||||
|
||||
|
||||
def parse_radio(reply):
|
||||
"""`get radio` ('> 869.432,62.5,7,5') -> preset tuple, or None."""
|
||||
m = re.fullmatch(r">\s*([\d.]+),([\d.]+),(\d+),(\d+)", (reply or "").strip())
|
||||
return parse_preset(",".join(m.groups())) if m else None
|
||||
|
||||
|
||||
def same_preset(self_info, p):
|
||||
"""Does a companion's self_info run preset p?"""
|
||||
return (
|
||||
abs(float(self_info.get("radio_freq") or 0) - p[0]) < 0.001
|
||||
and abs(float(self_info.get("radio_bw") or 0) - p[1]) < 0.01
|
||||
and int(self_info.get("radio_sf") or 0) == p[2]
|
||||
and int(self_info.get("radio_cr") or 0) == p[3]
|
||||
)
|
||||
|
||||
|
||||
def lora_params(p):
|
||||
"""Preset -> the (sf, bw, cr 1..4) lora_airtime takes."""
|
||||
return p[2], p[1], p[3] - 4
|
||||
Reference in new issue
Block a user