Upstream shipped companion/repeater/room-server v1.17.0 today; its tree is
identical to origin/main, so that is what this merges. Our base was 7 Jul
(7b566670), i.e. 350 files / +11k lines of upstream behind.
Conflicts and how they were settled:
* Mesh.cpp -- upstream split the dedup into wasSeen() + explicit markSeen().
Kept BOTH: their new call pair AND our payload-length bound on the TRACE
path-hash read, which is what stops a crafted short TRACE from steering
isHashMatch() past the buffer.
* companion_radio/main.cpp -- upstream grew its own MultiSerialInterface
(BLE + USB + WiFi + Ethernet registered side by side), which is a superset
of the SerialDualInterface we backported from PR #1779. Took theirs whole;
our copy is now dead code. NOTE: envs that relied on the backport for a USB
console alongside BLE now need an explicit -D ENABLE_USB_INTERFACE.
* ui-new/UITask.cpp -- isSerialEnabled() was renamed isBluetoothEnabled()
upstream and DisplayDriver::RED became UIColor::warning_txt. Same intent
either way: no BT pin on screen while Bluetooth is off.
* EnvironmentSensorManager.cpp -- upstream fixed the millis() wrap on the GPS
update timer in the exact line our gpsDutyLoop() call sits on. Kept both,
with their wrap-safe compare.
* NRF52Board.cpp -- upstream independently arrived at the same sd_temp_get()
fix for SoftDevice-protected TEMP. Took their form, kept our comment, which
is the only place recording WHY (APP_MEMACC fault -> reboot on telemetry).
* RadioLibWrappers.{h,cpp}, simple_repeater/main.cpp -- add/add. Their
configSideDetectors()/performChannelScan()/external watchdog next to our
irqDoneMask()/probeDio1()/BLE pump/WDT feed. The repeater console keeps the
1032-byte reply buffer for paged analyzer output and now clears it, since a
static buffer would otherwise reprint the previous reply.
* .vscode/extensions.json -- deleted upstream, and it is in .gitignore; our
only change was a comment. Gone.
Built clean: Xiao_x1_rpt, Xiao_x2_cmp, Xiao_x3_obs, SenseCap_s1_rpt,
T1000E_cmp_cz. Not flashed to anything yet.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bench-board died 29. 7. 2026 to a breadboard short that put GND on D1 (= DIO1)
and 5 V on D0. Signature: `sent 0` with tx_timeout climbing WHILE A WITNESS
HEARD THE FRAMES, plus `recv 0` at strong signal -- the radio works, the
interrupt line does not. setPacketReceivedAction() is the only thing that
ever sets STATE_INT_READY, so a dead line means nothing is ever picked up.
LORA_POLL_IRQ reads completion from the chip's IRQ status register over SPI
instead. The chip latches those events regardless of whether they are mapped
out to a DIO pin, so this bypasses the whole line and therefore works no
matter WHICH end of it broke. Rewiring DIO1 to a spare GPIO only helps if the
broken end is the MCU's input pad -- and that is the less likely end, because
grounding an input cannot damage the input, it stresses whatever drives the
net. Polling is strictly stronger: if it does not revive the node, no wire
will either. Cost is one extra SPI read per Dispatcher pass, next to the
isReceivingPacket() read already in that path.
getIrqFlags() returns the RAW chip register (SX126x bits, not RadioLib's
generic RADIOLIB_IRQ_* indices), so the mask comes from a new virtual
irqDoneMask() that only the chip-specific wrapper can fill in.
PIN_DIAG answers "which end?" without a multimeter:
- boot-time pull-up/pull-down sweep of every header pin, placed BEFORE
radio_init() because that halt()s when the radio does not answer -- so it
is the only diagnostic that still runs with the module unplugged, which is
also the only state where D1's result means anything (attached, the SX1262
drives DIO1 low and a healthy board reads 0 too). The internal pull is the
ohmmeter. It cannot see a lifted pad -- the resistor is on the die -- hence
the optional PIN_DIAG_LOOP_A/B jumper loopback, which drives from outside
and reads while pulling AGAINST the driver.
- `dio1` has the radio assert DIO1 via a 1-byte transmit and compares the
IRQ status register against the actual pin level. Where they disagree is
where the break is.
All of it is behind #ifdef; a build without the flags is unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The #tth-test bot needed a host process (slidge) plus a dedicated serial
companion node. Putting it in the firmware removes both: the observer node
answers by itself, and the serial console stays free for the CoreScope feed.
Not a port of the Solo bot. That one lives in examples/companion_radio on a
branch 610 commits diverged from ours, and it can only be configured from an
on-device BotScreen -- a XIAO has no display or buttons, so it would compile
and never arm. What made a local implementation cheap is that mesh::Mesh
already exposes everything:
* Mesh::onRecvPacket() calls searchChannelsByHash() + onGroupDataRecv() and
THEN routeRecvPacket() (Mesh.cpp:236-249), so reading a channel is
independent of forwarding it. Both hooks are no-op virtuals, which is the
only reason a repeater is normally deaf to channel traffic.
* allowPacketForward() gates only RECEIVED packets, so a node with
`repeat off` can still originate a reply. That is the point here: the
observer sits metres from another repeater and must never forward, but it
does have to answer.
* createGroupDatagram() is in mesh::Mesh and sendFloodScoped() is a plain
alias for sendFlood(), so none of the chat/contact machinery is needed.
Written against the mesh::Mesh API only, so it drops into
examples/simple_room_server unchanged if we ever want it there.
Commands are the ones only an analyzer can answer: !path (per-hop hashes at
the packet's own hash width, not a hardcoded 1 byte -- one node here runs 3),
!snr from the frame that carried the request, !heard from the registry.
Two guards, because this node's replies are its only transmissions:
anti-loop compares the sender prefix against _prefs.node_name (the runtime
name, so it holds even when stored prefs override the build-time one), and a
cooldown caps the reply rate. Both are needed: the cooldown alone would only
slow a ping-pong down, not stop it.
The channel key comes in as hex via -D BOT_CHANNEL_PSK, which is the form
`meshcore-cli get_channel <n>` prints -- no base64 round trip and no
base64.hpp dependency in this build. Hash derivation matches
BaseChatMesh::addChannel(); cross-checked against a live node, whose
128-bit key hashes to the same channel_hash the node reports.
All of it compiles out without BOT_CHANNEL_PSK. Costs 2.4 KB flash and 48 B
RAM over the plain analyzer build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The 1200-baud touch was the wrong mechanism, not an unreliable one. The
Adafruit bootloader chooses its mode from GPREGRET at boot, and the core
already exposes exactly that (cores/nRF5/wiring.c):
enterUf2Dfu() 0x57 DFU_MAGIC_UF2_RESET -> mass-storage drive
enterSerialDfu() 0x4e DFU_MAGIC_SERIAL_ONLY_RESET -> CDC only, no drive
enterOTADfu() 0xA8 DFU_MAGIC_OTA_RESET -> BLE DFU
The touch only ever requests the *serial* one. That is why no UF2 drive ever
appeared however long we waited for it, and it is the real reason today's
flashes kept going sideways -- I read "coin flip" into what was simply a
request for a different mode, and then wedged two boards proving it.
`dfu` writes the magic and resets, so the board lands in the mode you asked
for, every time. The reply goes out first and the reset happens ~700 ms later
from loop(), since reset_mcu() never returns and over BLE the notification
still has to be pumped out of the TX ring.
LOCAL ONLY (sender_timestamp == 0, the same physical-presence test CommonCLI
uses for `erase` and `set freq`). Over the mesh this would park a node in a
bootloader that waits forever, on a mast, with no way back but a visit.
Builds clean; NOT yet exercised on hardware -- the boards that could test it
are the ones still running firmware without the command.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
blink: a fixed burst is a race against walking to the bench -- 30 blinks
(~7 s) was not enough to find the board in time. `blink on` now runs until
`blink off`, with a 10-minute backstop so a node left blinking does not
quietly eat a battery. Cap on the counted form raised to 999.
txpwr: `set tx` cannot tell you whether the radio took the value. It clamps
to -9..30, saves the pref and replies "OK", but SX1262 accepts only -9..+22
and rejects the rest WITHOUT touching the PA -- so `get tx` can report a
power the radio never had. An earlier sweep here measured +2 dBm and -9 dBm
as RSSI -44.1 and -44.0 at a witness and concluded runtime tx power "does
not work"; that conclusion rested on an instrument that could not
distinguish a refused request from a link that does not care.
RadioLibWrapper::setTxPower keeps the status now (the signature stays void,
it implements an upstream callback), and `txpwr [dBm]` reports it. It
deliberately does not write the pref, so a sweep cannot leave a node booting
at some experimental power.
xiao_uf2_flash.sh: the 1200-baud touch is roughly a coin flip on this build.
Today it worked twice, then wedged x4, then wedged x1 -- and a wedged board
is gone from USB *and* BLE, does not recover on its own (waited 400 s) and
needs a physical replug. Not a "too soon after boot" effect: x1 had been up
23 minutes. Double-tap RESET into UF2 is reliable and takes seconds, so this
makes that the easy path. It refuses to act when several UF2 drives are
present rather than guessing, since they are all labelled XIAO-SENSE.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A bench of identical XIAOs cannot be told apart. The USB serial number
needs a data cable, and boards sharing power rails have none; the BLE MAC
is printed nowhere; and ADVERT_NAME is only as trustworthy as the last
flash, which is usually the thing being checked. Today two boards in the
same breadboard were both advertising "bench-board" -- one of them the
board with the burned DIO1, still happily running BLE.
`blink 10` flashes an LED ten times (default 6, clamped 1..30), and works
from serial, the BLE console and the mesh admin CLI, so it also reaches a
node that is already mounted somewhere.
Deliberately not the status LED. On XIAO that is LED_BLUE, which Bluefruit
drives as its connection indicator -- every BLE node blinks blue the same
way, which is why the LED was useless for identification in the first
place. Preference order LED_GREEN (XIAO, free) -> LED_WHITE (SenseCap, only
ever touched at boot and powerOff) -> LED_BUILTIN, which is last because on
SenseCap it is pin 12, the LoRa TX indicator. Variants may define a colour
they do not physically have by pointing it at PINS_COUNT (SenseCap does
that with LED_RED), so the chain range-checks rather than trusting #ifdef.
Driven from loop(), not inline: a blocking burst would stall the mesh for
up to ~7 s at the cap and disturb the very LoRa timing this fleet measures.
Always finishes dark. Goes through LED_STATE_ON, which is 0 on XIAO and 1
on SenseCap -- hard-coding HIGH would leave half the fleet unlit.
Verified on bench-board over the USB console: "blink 10" ->
"OK - blinking 10 times", and the build stamps v1.16.0-ttha12965f+.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ble_dfu find(): with want_dfu it accepted ANY device whose name contained "DFU"
and then took the first one the scan returned. With more than one board in
bootloader at the same time that reaches for someone else's hardware. It just
did: target CE:72:…:02, connected FE:11:…:C4. Caught only because the log was
being read by hand -- a few seconds later START_DFU would have overwritten a
different node. The address is now mandatory (MAC or MAC+1, covering both the
SCAP_DFU-on-MAC+1 and AdaDFU-on-same-MAC bootloaders), and foreign boards in
bootloader are listed as explicitly ignored.
ble_cli.py: the BLE console had no tool, so every ad-hoc script re-implemented
it and re-learned the same trap: a NUS write carries ATT_MTU-3 bytes and BlueZ
will not split it, so at the usual MTU 23 anything over 20 bytes fails with
"Failed to initiate write" -- which reads like a dropped link, not "command too
long". Commands up to 18 chars work, longer ones fail, deterministically.
Chunking is now in one place, with retries and the pairing/single-console
caveats documented.
simple_repeater: ADVERT_INTERVAL_DEFAULT / FLOOD_ADVERT_INTERVAL_DEFAULT /
DISABLE_FWD_DEFAULT, so a node can be built to ship silent. ENABLE_ADVERT_ON_BOOT
alone is not enough -- it only suppresses the boot advert, the periodic timer
still fires, so an `erase`d node is on the air within two minutes. Found the
hard way: a node flashed before this change and then erased spent ~44 s
transmitting on the live CZ frequency from a desk.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Upstream never initialises _prefs.path_hash_mode, so a fresh node came up at
mode 0 = 1 byte per hop. Nobody on the CZ mesh runs 1 B any more, which meant
every new install needed a manual `set path.hash.mode 1`. Default it to 1 at
compile time in both the repeater and the companion; the pref still overrides
it, so existing nodes are unaffected.
NOTE this is the PATH hash, not PATH_HASH_SIZE. It is used as
sendFlood(..., path_hash_mode + 1), i.e. the bytes each hop appends to the path
while flooding, and the size travels in the packet -- Packet.h:85 packs it into
the top two bits of path_len and Mesh.cpp:93 matches with getPathHashSize() --
so mixed-mode nodes still route for each other. PATH_HASH_SIZE (1) is a
different field, the destination and channel hash in Mesh.cpp:458/548, and
changing THAT would break the wire format against every other node in the mesh.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A TX that fails to start (startTransmit error) or never completes
(send-complete IRQ lost) was released permanently — with an nRF52
SoftDevice servicing BLE connection events this silently ate ~40 % of
DIRECT-route forwards (measured A/B on mast-three: direct_rx +5 / direct_tx
+3 with an idle BLE connection, 5/5 with BLE off). Flood redundancy
masked the same loss for flood traffic.
Retry up to MESH_TX_RETRIES (3) with a short growing backoff; a
duplicate on air is harmless (hasSeen dedup). New tallies
tx_start_fail/tx_timeout in stats-packets + ERR_EVENT_TX_* flags make
this failure class visible at last.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Small sibling ring to rxlog (PKTFEED_SIZE=32, ~8.6 KB) that keeps the FULL
raw frame bytes: staged pre-parse in logRxRaw, committed post-parse in logRx
(radio garbage never enters). Paged `pktlog [cursor]` mirrors rxlog paging;
the bridge derives route/type/payload and the MeshCore SHA packet hash
(analyzer correlation key) from raw, so the radio hot path stays SHA-free.
No 'always emit >=1' here: a ~550 B record line would overflow the 150 B
mesh-CLI budget — there the reply degrades to a bare trailer.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The BLE bridge drain was throttled by three multiplied costs: 150 B pages
(~3 rxlog records), 20 B NUS notification chunks, and the bridge waiting for
line silence per page. This fixes the firmware half:
- handleCommand() takes an explicit reply_max (default 150). The local console
(USB/BLE) passes ~1000 B -> ~20 rxlog records / ~7 nodes lines per round
trip; the mesh admin CLI keeps 150 so its reply still fits one LoRa packet.
Explicit parameter on purpose: a forged sender_timestamp==0 from the mesh
path must never be able to grow the reply past its 166 B buffer.
- bleWriteAll() chunks by negotiated MTU (247 -> 244 B) instead of fixed 20 B.
- Tables sized from channel physics instead of last week's traffic:
RXLOG_SIZE 512 = ~2 min of a saturated SF8/62.5k channel (~2-4 frames/s),
MAX_HEARD_NODES 128 > distinct nodes heard per neighbour advert period
(48 filled in <2 h and churned out real 0-hop neighbours).
- Page-sort scratch arrays moved off the loop-task stack into BSS.
RAM 17.7% -> 25.3% (59.6 KB / 235 KB). Flashed via BLE DFU 2026-07-15.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The path field emitted raw hex, but the hop-hash width (1/2/3 B, top 2 bits of
path_len) wasn't visible in it -- the bridge couldn't tell "A31FC2" from three
1-byte hops vs one-and-a-half 2-byte hops. Emit hops colon-separated instead
("A3:1F:C2" vs "A31F:C204"): each token is one hop, its width is len/2. Field
order/count is unchanged (path stays the same column), so the bridge only
changes how it splits that one token. Shared helper analyzer_path_hex() used by
both nodes and rxlog. (`HEX` had to be a local name other than the Arduino
Print.h `HEX` macro.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two related improvements to how heard nodes are represented:
1. Multi-path. A node's advert reaches us via several paths at once, but the
mesh dedups by payload hash (path not hashed) so onAdvertRecv sees only the
first copy -> `nodes` kept one path. rxlog, however, is fed pre-dedup and
logs every copy with its own path+SNR. Add the advert's FNV id (`pkt_hash`)
to each `nodes` row as a JOIN KEY: the bridge groups rxlog by pkt_hash and
joins to nodes to reconstruct every route a named node arrived by. New
`nodes` field: N,...,<age>,<pkthash>,<path>,<name> (name now after 10th comma).
2. Prefer direct. onAdvertRecv often processes a relayed copy first (stronger),
so the direct 0-hop link was being overwritten by a relayed path -- the
direct neighbours only showed up via the old `neighbors` path. Track
`direct_heard`; keep the direct (empty) path + its SNR for
HEARD_DIRECT_TTL_SECS after last hearing the node 0-hop.
Shared FNV helper (analyzer_frame_id) now used by both captureRx and
putHeardNode so nodes.pkt_hash == the rxlog copies' pkt_hash exactly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
captureRx() ran calculatePacketHash() (SHA-256) on every received frame in
the logRx hot path. The mesh core already computes that SHA once per frame
in hasSeen() during routing, so the analyzer was doubling the crypto load
on the radio-shared main loop for no benefit.
Replace pkt_hash with a cheap FNV-1a over (type||payload): same purpose
(dedup / correlation across nodes running this FW), a fraction of the CPU.
RAM-only, no flash writes, still main-loop (not ISR) -- so this does not by
itself explain BLE link drops (those match the known SoftDevice/LoRa
coexistence instability the BLE watchdog already guards), but it removes
the one real RX-path cost the analyzer added.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two RAM-only, opt-in tables fed from the normal RX path and pulled out
over the text console (serial / BLE) for a BLE bridge + map to consume.
Both are compiled out unless the build sets a non-zero size; enabled on
SenseCap_Solar_repeater_ble (-D MAX_HEARD_NODES=48 -D RXLOG_SIZE=96,
~6 KB RAM).
nodes [offset] -- registry of heard REPEATERS and ROOM SERVERS (chat
clients are deliberately skipped: personal/mobile devices, privacy).
Per node: pubkey prefix, name, type, lat/lon, last SNR/RSSI, seconds
since heard, and the path the advert arrived by. Fed from onAdvertRecv
(adverts are signature-verified upstream). -> map dots + topology
edges + link quality.
rxlog [cursor] -- circular firehose of EVERY parsed frame heard, fed
from logRx() (synchronous, so SNR/RSSI belong to that frame). Per
record: monotonic seq (paging cursor), time, packet hash, header
(route|type), SNR/RSSI, hop path. -> live traffic / analyzer view.
Both replies are paged to stay within the ~160 B console reply cap and
carry a trailer (next cursor + totals) so the bridge can drain and detect
if it fell behind the ring. Reachable over serial, the PIN-paired BLE
console and the admin mesh CLI, same as `neighbors`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Repeater can be queried over BLE Nordic-UART (advert/neighbours/stats) without USB. Fix SoftDevice-protected TEMP peripheral access (sd_temp_get) that crashed BLE repeater telemetry, add USB-connected detection to ArduinoSerialInterface, and adjust the nRF52 ldscript/extra FS.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Before this commit, there was no way to set a different max hop count
for unscoped messages.
Now with this change, by defaul it tracks the flood.max setting, until
a user provides a flood.max.unscoped value, which tax precidence for
packets if ROUTE_TYPE_FLOOD is true.
* room server: added RegionMap, and new CommonCLI wiring, default_scope handling
* sensor: only minimal RegionMap wiring. Still needs work to handle default-scope
Instead of overloading getOutboundCount() with a magic sentinel value,
add a dedicated getOutboundTotal() method to the PacketManager interface
that returns the total queue size without time filtering.
This eliminates the fragile convention that caused the regression and
makes the two operations — time-filtered count vs total count —
explicitly separate in the API.
This change addresses two issues. The first is that the
LilyGo_TLora_V2_1_1_6_terminal_chat build would try to compile
simple_repeater/MyMesh.cpp. All other examples of terminal chat
targets are instead building simple_secure_chat/main.cpp . This
change would align this build to the rest of the builds.
The second issue, found during the course of investigating the
first, stems from simple_repeater/MyMesh.cpp using the
MAX_NEIGHBOURS #define to control whether the neighbor list is kept.
Repeaters that keep this list must define this value, and if the
value is not defined, then all neighbor-related functionality is
compiled out. However, the code that replies to
REQ_TYPE_GET_NEIGHBOURS did not properly check for this #define,
and thus any target that compiles simple_repeater/MyMesh.cpp
without defining MAX_NEIGHBOURS would get an undefined variable
compilation error.
As a practical matter though, there are no targets that compile
simple_repeater/MyMesh.cpp AND do not define MAX_NEIGHBOURS,
except this build due to the first issue. As a result, the
second issue is addressed only as a matter of completeness. The
expected behavior with this change is that such a repeater would
send a valid reply indicating zero known neighbors.