From the Gemini adversarial review of Epic A, both checked against the
firmware before fixing:
- The generator reads source with regexes, so a protocol code inside #if
would be taken whichever branch a build uses. It now refuses one (none
exist at the pinned tags; FIRMWARE_VERSION's #ifndef default is not a
protocol code), and refuses a name defined twice with different values.
- The contract test compares names after dropping case and underscores;
it now fails if two names collapse to the same key.
Both pinned manifests regenerate unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found in Epic C verification (#782): a parallel test run failed "stock
over TCP" because SET_DEVICE_TIME hadn't reached the fake yet;
connectTcp's closing syncTime() only queues the frame on the socket.
The test now waits for every handshake command to arrive. Fixed here,
where the test was added, and merged forward through Epics B and C.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
B1-B5 driven by the client's own frame builders under the Offband and
stock companion profiles: DM/ACK, channel send, incoming messages,
radio settings, remote login and CLI, scripted faults, and an exact
trace round trip.
Epic verification: em-dash OK, analyze clean, format clean, full suite
1185 passing (98 fake-radio tests after the prefix fix), Windows and
APK release builds OK.
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>
The connector scenario runs over TCP and in-process under the Offband
and stock profiles: the client's conclusions match the profile (caps
present on Offband, absent on stock, and no Offband command is sent to
stock). Twenty in-process connects from one seed give one outcome. A5
catches a deliberately wrong constant (manifest_contract_test).
Epic verification: em-dash OK, analyze clean, format clean, full suite
1125 passing, Windows and APK release builds OK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reads lib/connector/meshcore_protocol.dart as source and compares every
code and capability bit with the pinned Offband (and stock) manifest:
87 shared names, no mismatches. A doctored constant is caught. The
fake's own code table is checked the same way. The reported version
satisfies every client gate for what the fake advertises (block >= 15,
caplog >= 17, packet hash >= 22), and stock enables none of them.
Finding, documented in the test rather than hidden: the client listens
for pushCodeChannelsChanged (0x91, #429 part A), which no firmware
defines (checked offband-v1.5.0-beta7). cmdGetCustomVar is an alias of
CMD_GET_CUSTOM_VARS (40).
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>
The real MeshCoreConnector over its real TCP path must reach connected
with self info, channels and contacts loaded. The only radio a test can
stand up today never answers: "Timed out waiting for SELF_INFO during
TCP connect". A2/A3 (#601, #768) replace it with the fake radio.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plan grant was refused: a plan's flash term must name one
registered device, and the radio isn't chosen yet. The flash now gets
its own per-device flash grant before D1. Terms checked with the
grant module's parser and validator: no errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner direction 2026-10-02: emulate stock and Offband separately; the
firmware publishes a protocol manifest at every tag and merge
(OffbandMesh/meshcore-firmware#1318) and the fake radio consumes it;
client CI checks its constants against the manifest; real-radio
traces (Offband, and one radio flashed to stock by the owner) check
behavior at D1. 55 points, still four Epics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Dart fake companion radio, in-process and over TCP, so CI can test
connect, sync, messaging and preset flows (including remote nodes)
with no hardware. Four Epics: core and handshake (#756), messaging,
settings, remote nodes and faults (#757), CI suites and a manual
runner (#758), integration testing (#759). Gemini 2.5 review: three
findings, all verified and folded in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the Custom Name override epic and the documentation of what a display name does not prove. Owner approved the plan in chat before this PR was opened, per the review-then-approval-then-execution order in SAFELANE section 3.
Architecture: Contact.name becomes a getter returning customName ?? receivedName, and the constructor takes receivedName. Measured 85 display reads against 22 writes, so renaming the write parameter makes the compiler enumerate every write site while every read stays correct and untouched. The rejected alternative, adding displayName and migrating 85 reads, fails silently when a site is missed.
The field is receivedName rather than advertName because a contact-card name is not advertised. Writing the test matrix caught that; the original naming would have lied for every card-added contact.
One hole the type system cannot see: the five buildUpdateContactPathFrame call sites read .name and would still compile, which would write a private label into the radio's shared contact table. Test T14 reads the source and guards it.
31 automated tests, every behaviour with a positive and a negative. Nine assert absence and exist purely to fail on a future regression.
Adversarially reviewed with Gemini 2.5 Pro. One finding accepted: nothing proved the UI never writes an empty custom name, so T29 and T30 were added. One finding rejected with a citation: the claimed migration crash does not exist because contact_store.dart line 145 already reads json name as String with a fallback to Unknown. Its narrower grain, that the rename could drop that fallback, became T31.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
OUTCOMES.md records what was delivered, the owner's D1 approval, the
evidence, what went wrong and what's left. PLAN.md gains section 10:
Epic A merged before D1 (the plan's gap), and the #748 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every preset test faked the network, so presets missing from
config-profiles main passed them all and reached the owner as
"Couldn't update presets" on a test build twice. The live test
refreshes from the real URLs and fails on any refresh error; a second
live test proves a missing file comes back as HTTP 404. The picker
test now checks that a good refresh shows no error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fl_open started SerialThread and only then called mtx_init. Upstream's
thread locked a mutex only after its first read returned data, so the gap
rarely mattered; #710's room check locks inFifo_mutex on the thread's
first pass, which made the race reachable on every connect.
The mutexes are now initialised right after the FlSerial is allocated,
before open() can throw, so _fl_close_slot also never destroys an
uninitialised mutex after a failed open. Both copies stay identical.
Found by the pre-PR Gemini review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two app-side halves of the #702 fix.
The native USB service read one 8 KB chunk per flserial callback, which
left the rest of a burst waiting in the native ring. It now drains
until the ring is empty, bounded at 32 reads (the ring's 256 KB) so a
stuck read cannot spin.
The frame decoder skipped bytes it could not frame (noise, an oversized
length) without a word, so when bytes were lost upstream, whole frames
vanished with no trace. It now counts them and keeps the first 16; the
native USB, web USB and TCP services log each batch as an error with
the count and a hex sample (SAFELANE 6). The web service shares the
decoder, so it gets the same logging, matching the plan's "all
transports" intent.
Tests cover no report on clean input, noise before a frame, an
oversized header, take-once, the capped sample and reset; with the
count disabled, 4 fail.
Epic #702.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
flserial's reader thread copied every byte into an 8 KB ring that
overwrote the oldest bytes when full, and told Dart about data only
once the port went idle. The RK4 sends its 350-contact list (about
52 KB) in about 0.17 s, so most of it was overwritten before the app
read it: the app saw 106-154 contacts and #660's contacts were lost.
The thread now reads only as much as the ring has room for. When the
ring is full it leaves the bytes in the OS driver, and USB flow control
holds the radio, so nothing is dropped. The ring is 256 KB (the size
the header already declared as MAX_PORT_FIFO_LEN, and a power of two
as the ring's mask needs); the per-read chunk stays 8 KB on the thread
stack. Dart is called back during a burst (4 KB waiting or 10 ms) and
whenever the ring fills, not only when the port goes idle.
Same change in the macOS copy of the source (macos/Classes), which was
identical. (std::min) is parenthesised because the Windows headers
define a min macro.
Verified on the owner's RK4 (read-only harness driving the DLL):
new DLL 350/350 in every mode, including a reader 2 s late, zero bytes
skipped; the old DLL, as the control, got 345 app-like and 54 (8191
bytes, the old ring's capacity) when 300 ms or 2 s late.
Epic #702.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whitespace only, from dart format, so CI's repo-wide format check
passes. Same step #696 took for the vendored Android BLE plugin.
Epic #702.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pristine import of MeshEnvy/flserial at
48216310061efc8d5d217cc18014fc2cb501646e (MIT, Grzegorz Lesniak), the
exact commit the app already pinned, into packages/flserial, with the
dependency switched from git to a path. Mirrors the #695/#686 vendor
pattern.
Vendored with git itself (fetch of that commit, read-tree --prefix), so
every file is the upstream blob: all 70 files verified blob-for-blob
against the commit. Left out, as #695 did: example/, .github/ and
.vscode/.
No behaviour change. The Windows release build compiles the plugin from
the vendored path and produces a flserial.dll of the same size as the
installed one. pubspec.lock also picks up flutter_blue_plus_android
8.2.2+offband.1, the version dev's own vendored package already
declares.
The fix for the 8 KB ring that overwrote contact-sync bytes (#704)
follows in #710.
Epic #702.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 30 s staleness rule only ran when a later getContacts call checked it.
If the radio drops END (firmware #1283 can refuse it like any frame) and
nothing else asks for contacts, the request stayed in flight: the loading
state stuck and a queued refresh never ran.
A watchdog now fires at the stale mark, re-arms if frames are still
arriving, and otherwise ends the request and runs the queued one. It never
prunes: an unfinished stream is not a complete sync.
Found by the pre-PR Gemini review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The banner sits in MaterialApp.builder, above the Navigator, where
there is no Overlay. Its close IconButton had a tooltip, and a Tooltip
without an Overlay throws ("No Overlay widget found"). In the owner's
release build that painted the window gray the moment the pointer
reached the button.
The close button drops the tooltip and keeps the accessible "Close"
label on the icon. New tests mount the banner in MaterialApp.builder,
as the app does, and hover the close button; both failed before the
fix with the Overlay error and pass now. The earlier tests mounted it
under home:, which has an Overlay, so they could not catch this.
Epic #668.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The firmware refuses a second CMD_GET_CONTACTS while it is streaming
(ERR_CODE_BAD_STATE), and the app had no contact handling for that
error. Two refreshes that overlapped could leave the in-flight state
tangled, and a request the radio refused left the list half-synced.
A request made while one runs is now queued and sent after END (a full
request wins over an incremental one). A request with no contact frames
for 30 s is treated as lost, so a missing END cannot block every later
refresh (owner decision on #672; the hang itself stays with #86/#504).
An ERR before the stream starts, when no caplog download or tracked
command could own it, ends the request and keeps the saved list. A
send that throws resets the in-flight state.
Tests cover queueing, the queued request running after END, full over
incremental, ERR, the 30 s stale rule, keep-alive from contact frames
and a failed send; with the guard disabled, 4 fail.
Epic #668.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A short contact sync is now loud (SAFELANE 6). A banner above the whole
app says the radio reported N contacts but sent M and that the saved
contacts were kept; it stays until dismissed. When the automatic retry
is short too, a modal asks: Keep my contacts (the default, focused, so
Enter keeps) or Use the radio's list, which states how many contacts it
would remove. Owner decisions on #670.
The banner sits in MaterialApp.builder next to the storage banner
(#385), above the Navigator, so the modal is drawn in place rather than
pushed as a route. Strings are English; other locales fall back through
untranslated.json, as the storage banner's do.
Widget tests cover hidden, shown with counts, the no-total wording,
dismiss, the decision's default and both choices; with the Keep default
removed, two fail.
Epic #668.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ContactStore.loadContacts returned an empty list when the stored JSON
failed to decode, and the next save wrote the in-memory list over the
stored contacts. A read failure was treated as "no contacts".
A decode failure is now logged as an error, the raw value is kept
under contacts<key>.unreadable-<timestamp>, and saves to that key are
refused (and logged) until a load succeeds. Other radios' keys are
unaffected.
Tests cover the round trip, the failure report, the raw copy, the
refused save, recovery after a good load, and another radio's key;
with the refusal disabled the save test fails.
Epic #668.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full contact sync cleared the app's list, then saved whatever the
radio streamed as the whole list. The owner's RAK declared 350 contacts
and streamed 106; the app kept the 106 and silently lost the rest,
favorites included (#660).
A full sync now leaves the local list in place and records which
contacts the radio delivered. Only a complete sync (received equals the
declared total) drops the contacts the radio no longer holds. A short
or undeclared sync merges what arrived, removes nothing, logs an error,
and retries once per connection. If the retry is short too, the
connector exposes a pending decision (keep local, default, or use the
radio's list) for the UI in #674.
Removes the now-dead _preserveContactsOnRefresh flag. Adds test-only
seams to feed frames and capture sent frames. Tests cover complete,
short, undeclared, retry bound, both decisions, mid-sync adverts and
incremental sync; with the old clear reinstated, 5 of them fail.
Epic #668.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same gap as the companion form: a repeater on the USA values with a
1- or 2-byte path hash matched MeshCore's "Canada" (3-byte). The remote
matcher now takes the node's path hash mode and applies the same rule.
Epic: #733
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MeshCore's "Canada" and "USA" share 910.525 / 62.5 / SF7 / CR5 and
differ only in path hash (Canada 3-byte). Matching ignored path hash,
and Canada sorts first, so a USA radio showed "Canada" (D1 screenshot).
A preset with a path hash size now matches only a radio on that size;
presets without one match as before.
Epic: #726
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sensor contacts gain a "Manage Sensor" item that opens the repeater
login and admin hub. Stock sensor firmware handles the same admin login
(SensorMesh::handleLoginReq) and CLI-over-mesh as repeaters, so the
remote settings screen, its preset picker and tempradio option work
there too. Repeater and room server menus are unchanged.
Epic: #733
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picking a preset that carries a path hash size sets the screen's
existing path hash field to the zero-based mode, so Save sends
`set path.hash.mode N` alongside the radio params.
With "Apply temporarily" checked, a preset's path hash is held back:
firmware has no temporary path hash, so it would outlive the tempradio
revert and leave the node off its mesh. A note says so on screen, and
the value stays pending for a normal save. A path hash the user sets by
hand is always sent. (Default chosen here; flagged for the owner.)
Epic: #733
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A checkbox on the remote-node radio card switches Save from
`set radio` (persisted, applied after a reboot) to stock `tempradio`
(applied now, reverting after the duration, nothing saved). The
duration defaults to 1440 minutes (owner decision) and is limited to
1-35791: firmware schedules the revert at 2000 + minutes * 60000 ms in
a 32-bit int, which overflows beyond that. Because tempradio retunes
the node 2 s after it replies, it is sent after every other command in
the same save. Coding rate goes out as the 4/x denominator, which is
what firmware range-checks. Unchecked behaviour is unchanged.
Epic: #733
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The remote-node radio card gains the same grouped RadioPresetPicker as
Radio Settings. Picking a preset fills frequency, bandwidth, SF and CR
and marks the radio field dirty, so Save sends the existing `set radio`.
TX power is untouched: on these nodes it is a separate command. Room
servers share this screen (contacts_screen.dart:1063), so they get it
too. The selection is matched from the current fields to the nearest
kHz (repeaters report e.g. 908.205017). The list refreshes when stale.
Epic: #733
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RadioPreset.frequencyHz returned kHz; renamed frequencyKHz (the unit
CMD_SET_RADIO_PARAMS carries). The picker is disabled while a refresh
runs, so a pick can't vanish when the refreshed list lands, and the
selected-item builder uses an id-to-title map.
Epic: #726
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The About card gains a credit line under the existing MeshCore Open
attribution, and the licenses page gains a "MeshCore suggested radio
presets" entry naming Liam Cottle, api.meshcore.nz, MeshCore and the
config-profiles mirror, alongside the Open-Meteo entry.
Epic: #726
Agent: MagentaHawk (session 5a8922d6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>