Two captures from hardware, anonymized and committed as fixtures: a Heltec
V4 on stock companion-v1.18.0 and a RAK4631 on offband-v1.5.0-beta7. A fake
seeded from each gives every reply the radio gave, byte for byte, and the
pinned profile must be the firmware the radio reports.
- anonymize_trace.py: replaces the radio's key, name and position, every
contact's key, name, path and position, and every channel's name and
secret with numbered stand-ins; drops pushes. Checked: none of the 1385+
real values survive in either fixture, and the same search finds all of
them in the raw capture.
- Stock profile re-pinned from companion-v1.17.1 to v1.18.0 (code 14),
the firmware the real stock radio runs. 1.18.0 adds CMD_RUN_CLI_COMMAND
and RESP_CODE_CLI_REPLY; the client uses neither.
- Seeding from a trace: firmware sends only contacts with lastmod > since
while CONTACTS_START counts all, so the RAK4631 announced 350 and sent
348. The seed now adds a hidden stand-in for each one never sent.
- Stock remote nodes print the frequency with ftoa (float32, 7 decimals:
910.5250244), not ftoa3. Ported and checked against the firmware
function compiled with g++.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dart run tool/fake_radio.dart --profile offband|stock --port 5000
[--seed file] serves the fake on TCP so the desktop app can connect
with no hardware. Its clock follows real time, so ACKs and remote
replies arrive. Console: dm, chan, drop, status, quit. --seed takes an
offband-fake-radio-seed file (contacts with types and routes, channels
with secrets, remote nodes with passwords and firmware flavor) or a
captured trace. Format and the capture/manifest tools documented in
tool/fake_radio/README.md.
The TCP server moves to its own pure-Dart file (fake_radio_tcp.dart)
so dart run can load it; fake_radio_adapters re-exports it. Tests: the
README's example seed parses (docs can't drift), bad seeds are refused,
a trace works as a seed, the real connector connects and a console dm
lands, and the actual dart run process serves a client and quits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FakeRadioAppServices wires the app's services and providers as
main.dart does (minus map tiles, background service, notifications and
file logging, which no screen under test needs). The real ChatScreen
and ChannelChatScreen run attached in-process to the fake:
- a DM typed and sent reaches the radio, shows in the conversation, and
shows acked (MessageStatusIcon.isAcked) once the ACK lands
- a channel message reaches the radio on its slot and shows
Two things learned and encoded: the retry service and screens schedule
on the widget test's fake clock while the database answers in real
time, so waits move both; and without tracing the bubble marks a
message acked only when it was delivered over a known path, so the test
contact has a learned route.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app's real MeshCoreConnector, MessageRetryService and
RepeaterCommandService, in-process against the fake, under the Offband
and stock profiles:
- connect: identity, channels, and the firmware the client concludes
(Offband caps present; on stock none, and no Offband command sent)
- DM sent then delivered on the ACK; a lost ACK retried then delivered
- channel send reaches the radio
- Companion preset (#647): radio params, TX power, path hash mode, as
settings_screen applies them, reported back through SELF_INFO and
DEVICE_INFO
- remote preset on a repeater, room server and sensor, built and
ordered as repeater_settings_screen does: saved (reboot to apply) and
temporary (tempradio last, path hash held back #735, applies 2 s
later); a refused value comes back as the firmware error, a good save
carries none (#748)
Test harness notes: replies reach the command service through the
receivedFrames listener the settings screen uses, and in-memory
databases stay open until the file ends because the connector's
startup reload isn't awaited. 126 fake-radio tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Repeater, room server and sensor firmware skip leading spaces and echo
an optional "XX|" prefix at the start of the reply (simple_repeater
MyMesh.cpp:1249-1255; simple_room_server :937; SensorMesh.cpp:385).
The app's RepeaterCommandService matches replies by that prefix, so
the fake must echo it too. Found while planning C1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tool/fake_radio/capture_trace.py records a real radio over USB serial:
the same read-only requests a client sends on connect, plus the
Offband extensions, each request with its exact reply frames. Nothing
is set or sent over the air; draining the message queue is opt-in
because it removes messages from the radio. RTS stays low and
--no-dtr keeps DTR low for ESP32 USB-Serial/JTAG boards (#244).
FakeRadioTrace loads a trace, builds the seed, profile and block list
the recorded radio held, and replays every request into a fake seeded
from it, reporting each reply that differs by step. Channel names are
compared up to their NUL (firmware fills that field with strcpy).
FakeRadioProfile.deviceInfoTailBytes lets older Offband builds with a
shorter DEVICE_INFO tail replay. The app's frame log wasn't usable: it
keeps 500 entries and truncates long frames.
Round trips exact under both profiles and for a v16-style short tail;
a doctored or missing reply is reported. 87 fake-radio tests.
Real-radio traces are captured at D1 (#783).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
failNext(code) answers the next N commands with an ERR and does
nothing; delayNext(code, d) holds the reply for d on the fake clock;
acksToDrop loses that many ACKs; cutContactsAfter sends START and N
contacts, no END, then drops the link. A drop ends the transport in
both adapters: the TCP server flushes and closes its sockets, and the
in-process link calls disconnect(manual: false) as connectTcp's onDone
does. Through the real connector, a cut contact sync leaves it
disconnected over TCP and in-process. 80 fake-radio tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FakeRemoteNode plays a repeater, room server or sensor. CMD_SEND_LOGIN
answers RESP_CODE_SENT tagged with the key prefix, then the node's
new-format LOGIN_SUCCESS (admin or guest) on the fake clock; a wrong
password gets no answer, as simple_repeater handleLoginReq returns 0.
Only an admin session runs CLI (the repeater's isAdmin gate); replies
come back as TXT_TYPE_CLI_DATA messages. Commands and replies copied
from CommonCLI: get radio/tx/path.hash.mode (ftoa3 formatting), set
radio ("OK - reboot to apply"), tempradio (applies 2 s after the reply,
reverts after its minutes), set path.hash.mode 0-2, set tx, ver,
version, Unknown command.
Stock vs Offband, from source: Offband rejects a fifth set radio part
(#299), stock ignores it; stock has no `version` and answers it as
`ver`. 74 tests, driven by the client's own login and CLI builders.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SET_RADIO_PARAMS validates like firmware (150-2500 MHz in kHz, 7-500 kHz
bandwidth in Hz, SF 5-12, CR 5-8) and allows client repeat only on the
default repeat frequencies (433.000, 869.495, 918.000); SET_TX_POWER
takes -9 to max; SET_PATH_HASH_MODE takes modes 0-2 and only with a
zero second byte. SELF_INFO reports frequency and bandwidth through the
firmware's float round trip. The client's own frame builders drive the
tests under both profiles (stock matches Offband here). 62 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CMD_SEND_TXT_MSG answers RESP_CODE_SENT with the flood flag, the
expected ACK (composeMsgPacket's SHA-256, matched against the client's
own MessageRetryService prediction) and a timeout; the ACK arrives as
PUSH_CODE_SEND_CONFIRMED on the fake clock. CLI commands expect no ACK.
CMD_SEND_CHANNEL_TXT_MSG is OK/NOT_FOUND; Offband keeps the 8-slot
packet-hash ring and answers 0xC6 with it (unknown sub-codes are
MALFORMED, per firmware). receiveDirect/receiveChannel queue V3 (or
legacy, below protocol 3) frames and tickle PUSH_CODE_MSG_WAITING;
Offband drops DMs from blocked senders, stock delivers them.
Connector check: an incoming DM lands in the real connector's
conversation over the in-process adapter. 50 fake-radio tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tool/fake_radio/gen_protocol_manifest.py reads companion firmware
source at a git ref and emits the manifest format proposed in
OffbandMesh/meshcore-firmware#1318. Pinned copies, verified identical
to the generator's output:
- offband-v1.5.0-beta7 (53951759): code 22, MeshCore base v1.17.0
- companion-v1.17.1 (stock, d9296435): code 13
FakeRadioProfile.fromManifest takes codes, bits and the DEVICE_INFO
version string (offbandClientVersion() derivation) from the manifest;
naming a bit the manifest lacks throws instead of reading 0. Offband
answers GPS status, the block list (BlockStore dedup/swap-remove
semantics) and the packet-hash query; stock rejects every Offband
command as unsupported.
Found writing it: the A2 default had OFFBAND_CAP_CAPLOG as 0x08 (it is
0x20) and the version string as 1.5.0-1.17.1 (beta7 is on v1.17.0).
Both now come from the manifest. 27 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FakeRadioTcpServer serves the fake on a loopback port with the
companion serial framing (0x3c app->radio, 0x3e radio->app), written
independently of the client codec. FakeRadioInProcess plugs the fake
into sendFrameOverrideForTest/handleFrameForTest with no socket.
lib change, test seam only: connectTcp's post-transport handshake moves
into _runConnectedHandshake (same statements, same order, same
try/catch), and connectInProcessForTest runs it for the in-process
path. A1 (#767) now passes on both adapters and asserts the handshake
commands reached the fake. analyze clean; connector + TCP tests green
(271).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A MeshCore companion radio in software under test/support/fake_radio.
handle() answers the handshake set the client sends (DEVICE_QUERY,
APP_START, GET_CONTACTS with 'since', GET_CHANNEL, SYNC_NEXT_MESSAGE,
time, battery, custom vars, auto-add, other params, advert name); every
reply cites the firmware function it copies. Unknown commands get
ERR_CODE_UNSUPPORTED_CMD, as MyMesh.cpp:3561 does.
Codes are copied from firmware, not imported from the client, so A5
can catch client drift. Stock and Offband differ already: the
DEVICE_INFO tail (82 vs 87 bytes) and set-time (stock refuses going
backwards; Offband #607 accepts). All delays run on FakeClock, never
wall time. 14 unit tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>