Duty přidal c7c9b812 (6. 8.), ale jen čtecí stranu: MyMesh.h:182 umí
gps_enabled == 2, zapsat ho tam ale nešlo. Dvě upstream místa to mařila,
každé samo o sobě:
* CMD_SET_CUSTOM_VAR uložil `gps:2` jako 0 (podmínka byla boolean),
takže duty se runtime zapnul, ale do prefs se dostala nula;
* a i kdyby se 2 uložila, sanitizace po loadPrefs ji clampovala na 1.
Výsledek: `gps duty` byl na companionu nedosažitelný přes jedinou cestu,
kterou karta má — companion build nemá textovou konzoli ani USB rozhraní.
Karty probe-card i a-card proto jely GPS naplno, tedy o ~46 mA víc,
než je potřeba (měřeno na SenseCAP P1-Pro, viz docs/power-saving.md).
Clamp 0..2 je i v CommonCLI.cpp:137, takže tohle jen srovnává companion
se zbytkem stromu. Displejová cesta (ui-tiny/UITask.cpp:811) zůstává
boolean — karta má NullDisplayDriver, takže na ni nedosáhne.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pwhe5XoCuuEbBCNLvsJBPL
Ranní 4caf52bb spravil jen sendZeroHop() a jen tam, kde mu volající šířku
předal. Zbylo dvoje místo, kde uzel s `path.hash.mode 1` pořád vysílal
hlavičku s 1 B:
* sendDirect() s PRÁZDNOU cestou. `path_len` je zakódovaný bajt (bity
šířky + počet hopů), takže neprázdná cesta si svou šířku nese sama a
přes copyPath() projde beze změny — proto tady žádná chyba routingu
není a moje první diagnóza „forwarder rozseká cestu po bajtu" byla
mylná. Prázdná cesta ale nemá co nést a holá 0 se dekóduje jako 1 B.
A přesně to je nejběžnější případ: odpověď sousedovi na dosah jde
zerohop direct, takže tudy tekla VĚTŠINA 1B provozu, co je vidět na
ob2 a v appce na #tth-test.
* volání send*() bez explicitní šířky. Companion (ob1/ob2/L1) posílá
zerohop na třech místech výchozím argumentem, stejně tak sensor
a room server; ACKy a PATH-return v BaseChatMesh a Mesh.cpp:187 taky.
Řeší se to na jednom místě: `getSelfPathHashSize()` je nový protected
virtual na Mesh a výchozí hodnota parametru se mění z 1 na 0 = „vem prefs
uzlu". Firmwary s NodePrefs ho přebíjejí na `path_hash_mode + 1`, takže
opravu dostanou i cesty, které si šířku nikdy nepředávaly. Základní třída
prefs nemá a vrací protokolové minimum, tedy simple_secure_chat zůstává,
jak byl.
TRACE se schválně nedotýká: tam `path_len` NENÍ zakódovaný bajt, ale holý
čítač SNR vzorků, a šířka se veze v příznacích payloadu (Mesh.cpp:55).
Kompatibilita: `path_len = 0x40` znamená šířka 2, počet hopů 0, tedy
`getPathByteLen() == 0` — starší uzly ho projdou přes isValidPathLen()
a nepřečtou o bajt navíc.
Přeloženo: SenseCap_hreb_rpt, SenseCap_ples_rpt,
SenseCap_Solar_repeater_ble, T1000E_cmp_cz,
Heltec_t114_without_display_room_server, Heltec_ct62_sensor.
Upstream to opravené nemá: origin/main je cad602e4 (v1.17.1) a je předkem
tohohle stromu, 0 commitů napřed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`packet->path_len = 0` vynuluje celý bajt — a v jeho horních dvou bitech bydlí
šířka hashe (`Packet.h:85`). Zerohop paket proto hlásil 1 B bez ohledu na
`path_hash_mode`, zatímco floodová větev šířku dostávala. Na uzlu s 2bajtovým
nastavením to vypadalo takhle: `flood: {2 B}` a `route2: {1 B}` od téhož
původce, přesně `advert.interval` od sebe.
Routing to nerozbíjí (zerohop nemá cestu a nepřeposílá se, `Mesh.cpp:83` chce
`getPathHashCount() > 0`), ale kazí to odvozování šířky v analyzerech — a je to
pravděpodobné vysvětlení části komunitních uzlů vedených jako "suspected 1B".
`sendZeroHop()` dostal `path_hash_size=1` jako `sendFlood()` a všechna čtyři
volání v `simple_repeater` mu předávají `_prefs.path_hash_mode + 1`. Zvlášť to
u periodického advertu (`MyMesh.cpp:1706`), který NEJDE přes
`sendSelfAdvertisement()` — oprava jen v té funkci by ho minula, a přitom je to
zrovna on, koho bylo v datech vidět.
Ostatní příklady se nemění, default zachovává dnešní chování. Build ověřen na
všech třech produkčních envech.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A repeater that keeps failing to get its transmits out looks perfectly
healthy over RF: sent/airtime just stop growing and nothing in the status
says why. The Dispatcher already counts those failures (n_tx_start_fail,
n_tx_timeout, from the requeue path); this puts them on the air.
Appended at the END of RepeaterStats on purpose, because the struct goes out
byte-for-byte and clients parse it by fixed offsets. Upstream grew the same
frame the same way -- meshcore-py's parse_status() reads recv_errors only
`if len(data) >= offset + 56`, with the comment "appended in firmware
v1.12.0" -- so older clients keep working and simply do not see the new
fields. Verified against the installed parser before writing this.
A static_assert pins sizeof(RepeaterStats) == 64 (56 + 8, padding-free):
reordering a field or gaining padding would silently shift every offset
after it, and that is not something to leave to review.
Room server keeps its own, already-different stats struct -- not touched.
Builds: SenseCap_Solar_repeater, SenseCap_Solar_repeater_ble, t1000e_repeater.
NOT field-tested yet: needs a repeater flashed with this and queried over RF.
Reading the two values also needs the consumer side extended (the library
parser stops at 56 bytes by design).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ContactInfo is filled field by field in three places, and none of them
writes every member:
- CMD_ADD_UPDATE_CONTACT, for a contact the node does not know yet
(companion_radio/MyMesh.cpp): the frame's lat/lon/lastmod are optional,
and clients omit them when the contact has no location -- so
gps_lat/gps_lon keep whatever was on the stack.
- DataStore::loadContacts(), and the same loop in simple_secure_chat: the
on-disk record carries no shared_secret/shared_secret_valid, so those
two members are never written. For every contact, on every boot.
shared_secret_valid is the dangerous one. getSharedSecret() computes the
secret only while the flag is false, so a non-zero byte there makes it
hand out an uninitialised buffer as the ECDH shared secret, and DMs to
that contact go out encrypted with garbage -- no error, no log.
populateContactFromAdvert() already memsets for exactly this reason; do
the same at the other three sites.
Found in the field: a room server whose advert carries no location showed
up at 0.255433, 0.0 in two independent companion clients. 255433 is
0x0003E5C9, straight off the stack. Verified the advert itself is clean by
decoding it in a third, unrelated tool.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Small one after v1.17.0: 57 files, +825/-200, and it merged with no conflicts at
all. Unlike 1.17.0, the release tags sit directly on origin/main, so no
`-s ours` is needed for git describe to see the release.
What matters for our nodes:
* fix-rxgain-setting-post-agc-reset -- rx gain no longer resets after an AGC
adjustment. The release notes ask repeater admins to verify radio.rxgain (and
the new radio.fem.rxgain) after updating, so that goes on the post-flash list.
* NRF52 CC310 crypto is initialised once instead of on every call, and several
NRF52 pin maps were corrected.
* New 'get/set radio.fem.rxgain/txgain' CLI commands (companion cannot configure
them yet).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Introduced consistent preferences for external LoRa FEM RX and TX gain settings in NodePrefs. Updated companion MyMesh to apply these settings during initialization and transmission. Added unit tests to verify the round-trip serialization of these new preferences.
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>
Measured 7. 8. 2026: bench-board had been running 811 days behind since it was
deployed, and every board on the bench was 812 days behind. Nobody had ever
set their clocks, because setting one was a manual step documented in two
places and performed in neither.
That is not cosmetic. Mesh.cpp stamps every advert a node transmits from the
RTC, and a receiver drops a stale timestamp as a replay -- so a wrong clock
turns into replies that vanish.
Nothing could fix it by itself. The only automatic sources in the tree are GPS
(which these nodes do not have) and BaseChatMesh, which the repeater build does
not link; and `clock sync` cannot work from the console at all, because USB and
BLE share one command buffer and pass sender_timestamp = 0, so the
`sender_timestamp > curr` guard is never satisfied.
So build_version.py now also stamps FIRMWARE_BUILD_EPOCH, and that -- not a
hardcoded 15 May 2024 -- is where a clock with no other source comes up. A
freshly flashed board is right to within "time since compile". It needs no GPS,
nothing carrying a correct time on air, and no host: the one case the host-side
tooling cannot reach. Verified on x1: build epoch 1786100869 = 11:07:49, and
after a reboot the board came up at 11:07:47.
The #ifndef fallback is load-bearing, not decoration: build_version.py is
nRF52-only and reaches 7 of the 16 local envs, so upstream envs never define it.
Verifying an integer define is not `strings` -- dump .text and look for the
word, and check the old literal is gone from all three sites.
`clock` also reports the epoch now. Its human part is minutes only, so a host
comparing clocks could not see a difference under a minute and had to leave a
59 s deadband; appended, so anything that just prints the reply is unaffected.
Also here, and DISABLED, is carrying the clock across a soft reset in retained
RAM. It was tried and measured not to work: the record at 0x2003FFE0 came back
as `00000000 10001000 00000000` after a reboot -- not zeroed, OVERWRITTEN, and
0x10001000 is the nRF52 UICR base, i.e. a UICR pointer left on the Adafruit
bootloader's stack. The bootloader runs before the app on every reset and links
against the full RAM, so it owns the top of it; being outside the app's linker
region is not enough. The code stays because it self-disables against __StackTop
and now says so at boot, and because the same doubt applies to the hardfault
record at 0x2003FFF0, which sits HIGHER -- treat a missing hardfault report as
"unknown", not as "nothing crashed".
Two things that cost a cycle each and are now designed out: the restore's
"nothing stored" branch was silent, which is indistinguishable from "working";
and `clkreboot` would have undone itself, writing the build epoch and then
having the reboot restore the value it just discarded (weak
retainedClockInvalidate() closes that).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
BOT_FRAG_LEN was 72, chosen against the longest command name rather than the
longest answer, and it held only because !link had never been asked from
further than two hops away. An 11-hop request wanted 88 chars, so the reply
was cut at 71 -- and it cut off exactly the SNR and RSSI the command exists to
report: "... 209f:34fa:ed9c, SNR 4.0 ".
Two changes, because the size alone would not be enough:
* 100 bytes, sized against the real worst case. botFormatPath() caps the
path at 62 chars (21 hops at 1 B, 12 at 2 B, 9 at 3 B all land just under
BOT_PATH_STR_LEN) and the numbers in front add 36, so 98 + NUL.
* the path goes LAST. It is the only unbounded part of the reply -- and the
SENDER picks the hash width, so this node does not even control how long
it gets. With it at the tail, an overrun eats hops instead of eating the
link budget, and a partial path is still useful where a missing SNR is not.
Both bot envs (Xiao_x1_bot, Xiao_x3_obs) build.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two upstream defaults that cost a headless solar node around the clock:
* Bluefruit blinks LED_BLUE while advertising and holds it on while connected.
On SenseCap Solar that pin is 12 -- the SAME pin as P_LORA_TX_LED -- so a
sealed mast node spends charge blinking an LED nobody can see, and the LoRa TX
indicator lies as a bonus. autoConnLed(false) by default (RPT_BLE_CONN_LED).
* The slow advertising interval sat at 244 units = 152.5 ms, i.e. three channels
~6.5 times a second for years. Now 1 s (RPT_BLE_ADV_SLOW); the first 30 s
after boot or a disconnect stay fast, so discovery is unaffected in practice.
Bench boards keep both upstream behaviours via platformio.local.ini: on a desk
the blinking LED is the "this board is alive" indicator.
Also: powersaving must not sleep while the BLE console still has queued output.
WFE only wakes on an interrupt, so a half-drained rxlog/pktlog page would sit in
the ring until the next connection event -- and on the observer node the bridge
drains those on a 2-minute duty cycle, where a slower drain directly costs
collected frames.
Measured: BLE (at the new interval, LED off) is ~1.3 mA of a ~24 mA node, so
`ble off` on a mast is not worth losing remote access over.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Measured on a SenseCAP Solar P1-Pro: a continuously powered L76K costs 46.0 mA
(paired A/B, spread 43.7-47.5), which is more than everything else on the node
put together -- it runs at ~24 mA with GPS asleep. A mast repeater does not need
a continuous fix; it needs its volatile RTC set, or clients drop its replies.
`gps duty` powers the receiver only around a sync and cuts it in between. The
cadence matches the 30-minute re-sync MicroNMEALocationProvider already does, so
clock accuracy is unchanged while 42-45 of those 46 mA come back -- 42 even in
the pathological case where a fix never arrives.
Encoded as gps_enabled == 2 rather than a new pref, so the prefs file layout is
untouched and an older build just clamps the value.
The cadence is owned by the state machine, not by the provider's own re-arm, for
a concrete reason: with the receiver unpowered nothing feeds the parser, and
MicroNMEA keeps reporting the LAST fix as valid -- a provider-driven re-arm
would therefore set the RTC to a half-hour-old timestamp. Hence syncTime() (which
clears the parser) on every wake plus an own timer, and int32_t deltas so the
49-day millis() wrap cannot park GPS on or off forever.
Verified on hardware, both paths: with sky `duty, asleep, fix, 7 sats` (fix
taken, clock set, receiver cut); indoors `awake` for exactly 300 s and then
`asleep` with an hourly retry.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The previous commit asserted "the chip is wedged before either interface comes
up, not gone from USB", reasoning that the absence of enumeration errors ruled
out a host-side problem. That reasoning was wrong and the conclusion is
withdrawn.
The control that broke it: the identical signature -- disconnect, then nothing,
no errors, port reporting `state=not attached` -- was reproduced on a KNOWN GOOD
board by writing 1 then 0 to that root-hub port's `disable` from the host. The
board was healthy and doing nothing unusual; it went to `not attached` and
stayed there until physically replugged. So the log proves the host stopped
seeing a device and nothing more. A missing error message is not evidence of
absence.
That also kills the port-toggle as a recovery mechanism -- it takes healthy
boards off the bus with no way back. Recorded so nobody tries it again.
What survives measurement:
- resets through the RESET pin (double tap) have never failed: 5/5
- software resets fail in both directions, ~5/10 for `dfu` before the
USBPULLUP change, and several times for the bootloader's own reset back
into the application -- a path our firmware cannot reach at all
- so USBPULLUP is aimed at a transition, not at a diagnosed chip fault, and
n=1 since does not demonstrate anything yet
The operational rules that follow (one board at a time, never loop flashes, ask
for hands immediately, and get a hub with real per-port power switching if this
bench is to be recoverable remotely) are in tools/README.md.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three of eight `dfu` commands tonight left the board dead on USB *and* BLE,
recoverable only by a physical replug. I had been calling that "the board fell
off USB" and asking for a replug -- which is a description, not a diagnosis.
The kernel log says exactly what it is and is not:
good: usb 7-9: USB disconnect -> 3 s later idProduct=0045 (bootloader)
bad: usb 7-6: USB disconnect -> nothing, ever
No failed-enumeration errors, so the host was not racing the device; the board
simply never drove D+ again. Nor was it sitting in the bootloader: a bootloader
in DFU mode advertises `AdaDFU`, and a BLE scan during the wedge found the other
two boards advertising normally and this one absent from both interfaces. So the
chip is wedged before either interface comes up, not "gone from USB".
Two changes, one a fix and one an instrument:
- reset_mcu() (core wiring.c) disables the SoftDevice and resets with USBD still
enabled and possibly mid-transfer. Clearing USBPULLUP first drops D+ while the
application is still alive and in control, giving the host an unambiguous
disconnect and leaving USBD in a defined state at reset. One register write --
that is all TinyUSBDevice.detach() does on this chip.
- readResetReason() is latched by the core in init() before RESETREAS is
cleared, and it is the only thing that can distinguish "somebody typed `dfu`"
from a lockup or a power cut after the fact. Printed in the boot diag window
next to the hardfault record.
Scope, honestly: the first change removes a class of race but is NOT yet proven
to be the cause -- the failure is intermittent (~37 %), so only a run of trials
can say. The RESETREAS line is the other half of that instrument.
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>
Reported symptom: "!link arrived only on the second try". Cause was the throttle
itself -- one global 10 s window per channel, so a second person asking inside it
got silence. That reads as a broken bot rather than "wait ten seconds", and it
happened twice while testing.
Now each sender has its own window, keyed on the "<name>: " prefix, over an
8-slot LRU. Spoofable by design and that is fine: this is politeness throttling,
and a channel message carries no identity beyond that prefix anyway.
The airtime guarantee that the global window used to provide is kept explicitly
as BOT_MIN_GAP_MS (2.5 s floor between any two replies, whoever asked), so N
senders can no longer produce N simultaneous transmissions. Without that, going
per-sender would have quietly traded politeness for responsiveness.
`bot` now reports both numbers plus a throttled counter, so a suppressed reply is
visible instead of looking like a dead node.
Bench-verified on the discriminating case, which is the whole point: sender A
asking twice in 3.5 s gets one answer, while sender B asking INSIDE A's window
gets answered -- 3/3.
Note on how that was measured, because it bit me: reading the console counter
costs ~2.4 s (the CDC needs a settle delay), so a probe pair with a counter read
between them is ~15 s apart and the 10 s window has legitimately expired. The
first run of this test "failed" for exactly that reason. Read counters only
before and after a pair, never inside it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Correcting how I split the two bots. I gave !path to the Solo node and kept only
analyzer trivia here, which gets the direction backwards.
When you drive away with the handheld and ask "what link do I have home?", the
handheld's own !path is useless: it describes packets the handheld RECEIVED,
i.e. the reverse leg. Only a fixed node at home can answer the forward one,
because it is the thing your packet actually arrived at. So !path belongs here,
and !link joins it: hops + path + SNR + RSSI in one reply, so the question is one
command and not two while driving.
No duplicate answers in that scenario: when the question comes FROM the handheld,
the handheld is the sender and does not answer its own message, so only this node
replies. Two answers only appear when a third node asks -- which is exactly what
my earlier test did, which is why I mistook it for a general problem.
Second reason to answer from here, found while reading the Solo tree: a Solo
node's own bot reply is INVISIBLE in the phone app. tryBotReplyChannel() echoes
only to the local screen under #ifdef DISPLAY_CLASS
(MeshCore-solo/examples/companion_radio/MyMeshBot.h:220), and the only path into
a connected client is onChannelMessageRecv(), which runs for RECEIVED packets
only. A reply from a different node arrives over the air, so the app shows it
like any other message. Answering from here therefore fixes the "I cannot see
what my node said" confusion for free, with no change to the Solo firmware.
Verified live on #tth-test: !link -> "0 hop direct, SNR 13.2 dB, RSSI -43 dBm",
reply counter 2 -> 3.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#tth-test already had a bot: tracker (Solo firmware), which also puts "Ping" on
the channel by itself. Measured consequence of running a second bot there with
no coordination, over a few minutes: the counter went 2 -> 9, i.e. seven of the
replies went to tracker rather than to a person, and because the cooldown is one
per channel, a human question then landed in a closed window. One of four probes
got no answer for exactly that reason.
Worth stating because it corrects an earlier guess of mine: that miss was NOT an
RF problem. Replies arrive DIRECT (0 hops) at SNR +13.5..14.25 dB, and SF7
demodulates down to about -7.5 dB, so at 2 dBm there is ~20 dB of margin. More
TX power would have bought nothing; the fix was arbitration, not watts.
Two build-time knobs, both defaulting to today's behaviour:
BOT_IGNORE_SENDERS comma-separated node names, dropped before trigger and
command matching. Verified live: `ignored` incremented on
a real tracker message.
BOT_COMMANDS whitelist of !commands this node answers, "" = all.
Matching for both is EXACT and case-insensitive, deliberately unlike
botTriggerMatches()' substring search -- a substring ignore list would let a node
called "TTH" silence "tracker", and a substring whitelist would let "path" enable
"!pathx".
Adds !noise (noise floor), which is in the same spirit as !snr and !heard: things
a companion bot cannot answer at all because it has no analyzer.
`bot` now also reports the whitelist, the ignore list and an ignored counter, so
the arbitration is inspectable from the console instead of inferred.
Deployed split: x3 answers only !snr/!heard/!noise and has NO bare-word trigger,
so it never speaks into ordinary traffic; !path/!ping stay with tracker. Verified
live -- !path drew exactly one answer, from tracker.
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>
BLE name: Bluefruit.setName() was given BLE_DEVICE_NAME, which defaults to the
build-time ADVERT_NAME. That only ever seeds a fresh install, so once the whole
test fleet runs one image every board advertises the same string regardless of
`set name`, and a BLE scan cannot tell them apart. Four boards were advertising
"bench-board" simultaneously here -- including the one with the dead radio, which
is precisely the board you least want to mistake for a working one. Now it
advertises the prefs name, with the build constant as the fallback for a node
that has never been named. Prefs are loaded by the_mesh.begin() well before
Bluefruit.begin(), so the name is available.
xiao_uf2_flash.sh, after four rounds of it being not quite foolproof enough:
- takes an explicit target (serial or fleet number 0..4) and refuses to write
to any other board; the earlier version reported x4's port after flashing
x3, which reads exactly like a successful flash of the wrong board
- rejects a file that is not a UF2 (a .hex or .zip dropped on the drive is
ignored by the bootloader and looks like success)
- refuses an image older than firmware.elf, and demands the version stamp
- resolves drives through sysfs by USB serial, never by label -- every drive
is XIAO-SENSE, numbered in plug order
- retries the mount (the automounter loses the race with a fresh drive) and
the version read-back (the port enumerates seconds before the firmware
answers on it). A check that cries wolf is worse than no check.
- proves the flash by reading `ver` off the board and comparing it to the
image, instead of trusting that some XIAO came back on USB
Co-Authored-By: Claude Opus 5 <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>
Two halves of the same problem: the stamped version reached the device but
not the client.
RESP_CODE_DEVICE_INFO carries the build date in 12 bytes and the version in
20, NUL included -- 11 and 19 usable characters. The version field is
written with strzcpy() and truncates safely; the build date was a bare
strcpy() into a memset region, so a longer string simply ran past the end
into the manufacturer-name field. It never showed because strzcpy()
overwrote that field on the very next line. Benign today, and driven by a
compile-time constant rather than anything remote, but it is an unbounded
copy into a fixed frame slot and the only reason it was invisible is luck
about the write order. Now strzcpy(..., 12) like every other string there.
The stamp then had to fit. "v1.16.0-tth-0dbaba04" is 20 chars, so the node
reported "v1.16.0-tth-0dbaba0" -- readable, but a character short of the SHA
it was built from. "04 Aug 2026 11:28" is 17, so the time was cut clean off.
Now a 7-char SHA with a "-tth" marker (19 with the dirty '+', 18 without)
and a yymmdd hhmm date (11). The budget never sacrifices the base version or
the dirty marker -- a lost '+' would make an uncommitted build look
reproducible -- and warns instead of truncating silently if it ever cannot
fit.
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>
Two diagnostic levers for the BLE/LoRa coexistence work, plus a correction to
what the existing tx power call actually does.
Bluefruit.setTxPower(8) is ADVERTISING power only. Bluefruit stores the value
and BLEAdvertising::start() hands it to sd_ble_gap_tx_power_set() with
BLE_GAP_TX_POWER_ROLE_ADV; nothing in the library ever sets the CONN role, so an
established link runs at the SoftDevice default of 0 dBm. The +8 buys discovery
range and nothing else. Confirmed on hardware: `blepwr` reports
"conn tx: 0 dBm, adv tx: 8 dBm".
- RPT_BLE_CONN_TX_POWER (default 0 = unchanged behaviour), applied per
connection on every 'secured' since the handle is new each time.
- `blepwr [dBm]` sets it at runtime over serial, the BLE console or the mesh
admin CLI. Runtime rather than a build flag because a dose-response sweep
needs many points and reflashing the XIAO costs a physical UF2 dance.
- Auto-revert after 5 min (`blepwr <p> hold` opts out). Without it the command
locks you out of the console you would need to undo it: the value is
re-applied on every 'secured', at -20 dBm the node's replies stop arriving and
at -40 dBm a connection cannot be established at all. Hit this on the bench;
recovery was over USB, and on the mast the only way back would be `reboot`
over the mesh admin CLI.
- `bleconn` reports the connection parameters actually in force. bleOnSecured()
only REQUESTS 15-30/60-80 ms and the central may refuse, so without reading
them back "the pre-fix interval showed no loss either" cannot be told apart
from "the pre-fix interval was never in force". Latched once a second from
loop() so it can be read over USB after the central is gone -- reading it over
the BLE console while connected would collide on the shared command[160].
Measured with these: at a verified 22.50 ms interval, sweeping the connection
tx power from 0 to -20 dBm (RSSI -67..-87 at the central, covering the whole
-75..-90 window the mast sits in) produced zero lost DIRECT forwards, with
tx_timeout and tx_start_fail at zero in every cell.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>