Commit Graph
3036 Commits
Author SHA1 Message Date
tthandClaude Opus 5 4fb886170f feat(clock): a node with no GPS starts at its build epoch, not in 2024
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>
2026-08-09 22:24:59 +02:00
tthandClaude Opus 5 a49bbb914d fix(bot): size !link's reply for the longest PATH, not the longest command
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>
2026-08-07 11:11:25 +02:00
tthandClaude Opus 5 7060cc30ab fix(cli): i2c -- stop truncating the reply mid-word, and over-reading to do it
`i2c` on a SenseCap answered `no I2C device answered; expected-empt`. The cut
is not in transport: the node emits those 37 bytes.

The expected-empty list's first entry is `"; expected-empty %02X"` -- 19 chars
plus a NUL -- assembled in a 16-byte scratch buffer. snprintf() stored 15 chars
and returned 19, the length it WANTED. Using that return as a byte count did
two things: memcpy read 20 bytes out of a 16-byte stack buffer, and the write
cursor advanced past the NUL that had actually been stored, so every following
address landed after the string terminator where nothing would ever read it.

So the list has been invisible on every board since it was added, not just this
one -- which matters, because the whole point of printing the addresses the
build expects is to tell "sensor absent" from "sensor at the wrong address".

Fixed by appending through a helper that measures the source with strlen() and
writes only whole entries, plus buffers sized for the real worst case. A host
reproduction under ASan flags the old path as a 20-byte read of a 16-byte
frame and the new one comes back clean, printing the full
`expected-empty 40 44 76`; in a buffer too small it now stops on an entry
boundary instead of mid-word.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 10:21:39 +02:00
tthandClaude Opus 5 1561d29218 feat(power): stop paying for a blinking LED and 6.5 Hz advertising
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>
2026-08-06 10:05:56 +02:00
tthandClaude Opus 5 005773ec4b feat(cli): i2c -- scan the bus on a live node
begin() already scans I2C before touching any sensor library, but only into a
MESH_DEBUG log nobody has on a deployed node. So "is that sensor actually there?"
was answerable only by inference from telemetry, and inference is what produced
`TELEM_INA226_ADDRESS=0x40` in our SenseCap envs: a guard against false-detecting
SHT41 at the library default 0x44, written as if an INA226 existed.

It does not. `i2c` on bench-rpt answers "no I2C device" -- the variant has a
single bus (WIRE_INTERFACES_COUNT 1) and nothing on it. That closed a whole line
of "measure the solar node with its own current sensor" work.

Output leads with what answered, then lists the table addresses that stayed
quiet, deduplicated and as bare hex: names for three entries sharing 0x76 alone
overran the 150 B mesh reply and truncated the interesting part.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 10:05:40 +02:00
tthandClaude Opus 5 c7c9b812ab feat(gps): duty-cycle the receiver, for nodes that run GPS only for the clock
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>
2026-08-06 10:05:26 +02:00
tthandClaude Opus 5 bdaf1678da docs: correct the USB-vanish diagnosis, and write down what was measured
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>
2026-08-04 22:59:03 +02:00
tthandClaude Opus 5 f99ae9ab18 fix(repeater/dfu): drop D+ before the reset, and print RESETREAS at boot
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>
2026-08-04 22:38:47 +02:00
tthandClaude Opus 5 b9848fe79a feat(radio): DIO1-less operation + pin diagnostics, to salvage bench-board
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>
2026-08-04 21:32:58 +02:00
tthandClaude Opus 5 fc32a1a0a8 fix(repeater/bot): cooldown per sender, not per channel
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>
2026-08-04 20:03:41 +02:00
tthandClaude Opus 5 27f1339ac9 feat(repeater/bot): !link, and move the path question to the node that can answer it
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>
2026-08-04 19:45:15 +02:00
tthandClaude Opus 5 58038729e9 docs(bot): ignore list is NOT for gagging a peer node's name
Correcting a deployment choice I got wrong. I set BOT_IGNORE_SENDERS="tracker"
after observing "tracker: Ping" traffic and assuming the Solo node emitted it
periodically on its own. It does not -- a human types those pings in the mobile
app attached to that node.

Filtering on the sender name therefore gagged the user's own app: every question
typed there would have gone unanswered, which is the exact opposite of what the
node is for. My live !snr test passed only because I sent it from the T1000-E
(name "TTH"), so the misconfiguration never showed up.

The ignore list was also unnecessary for its stated purpose. With BOT_TRIGGER
empty this node reacts only to an explicit !command, and no bot reply ever
contains one, so bot-to-bot feedback cannot start. Empty trigger IS the
arbitration; the filter added nothing but a gag.

Deployed config now has BOT_IGNORE_SENDERS="". The mechanism stays in the
firmware -- it is tested and it would be the right tool if a bare-word trigger
were ever enabled here -- but it must key on something a bot says, not on who
owns the radio a human is typing into.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 19:28:44 +02:00
tthandClaude Opus 5 355e4609eb feat(repeater/bot): sender ignore list + command whitelist so two bots share one channel
#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>
2026-08-04 19:26:03 +02:00
tthandClaude Opus 5 cca22dd45d feat(repeater): channel bot in the analyzer build -- listens and answers without repeating
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>
2026-08-04 18:30:47 +02:00
tthandClaude Opus 5 e217b6d6f7 fix(repeater): advertise the node's real name over BLE; harden the UF2 flasher
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>
2026-08-04 13:48:07 +02:00
tthandClaude Opus 5 3c27e7745f feat(repeater): dfu [uf2|serial|ota] — deterministic reboot into the bootloader
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>
2026-08-04 12:53:20 +02:00
tthandClaude Opus 5 59e974854f feat(repeater): blink on|off, txpwr with RadioLib's verdict; UF2 flash helper
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>
2026-08-04 12:45:28 +02:00
tthandClaude Opus 5 29d620e1a6 feat(repeater): blink [n] — ask a board to identify itself
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>
2026-08-04 12:20:28 +02:00
tthandClaude Opus 5 7c071d1515 fix(companion): bound the build-date copy; fit the version stamp in the frame
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>
2026-08-04 11:43:53 +02:00
tthandClaude Opus 5 0dbaba046c build(version): derive the base version from the upstream tag, not a literal
build_version.py replaced one hardcoded version with another: it stamped
"v1.16.0-tth-<sha>" with v1.16.0 written into the script. The SHA made the
build identifiable, but the base would have kept claiming v1.16.0 for as
long as nobody remembered to edit this file -- the same stale-by-
construction string the script exists to eliminate.

Now taken from the newest upstream release tag HEAD descends from
(`git describe`, upstream tags them per-example as companion-v1.16.0 /
repeater-v1.16.0, so match any *v[0-9]* and strip the prefix). Our own
release tags carry '+tth.<timestamp>' and are excluded so they cannot
shadow the upstream base.

Also documents the wiring in the header, because the failure mode is
silence: an env that forgets the script builds fine and ships a node that
lies about its own version.

Verified stamping on all nine envs we flash -- T1000E_cmp_cz, the four
XIAO test nodes plus oldble, and the three SenseCap repeaters.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 11:28:24 +02:00
tthandClaude Opus 5 4759954c58 build: move build_version.py to tools/, so any env can stamp its version
The script has nothing SenseCap-specific in it -- it reads the git SHA and
the clock -- but it sat under variants/sensecap_solar/ and only that
variant referenced it. Everything else silently shipped the hardcoded
literals from examples/*/MyMesh.h ("v1.16.0", "6 Jun 2026"), identical in
every build.

That cost real time tonight. After a 14-minute BLE DFU onto the T1000-E
tracker, every field the node reports back -- ver, fw_build, model,
max_contacts -- was byte-for-byte what it had said before the flash, so
`ver` could not distinguish the new image from the old one. The only
evidence the image had actually landed was the bootloader's own IMAGE ok /
VALIDATE ok. That is sound evidence, but it lives in a log that scrolls
away, not on the device you can query a month later.

Verified after the move: SenseCap_Solar_repeater_ble, SenseCap_ples_rpt and
T1000E_cmp_cz all stamp v1.16.0-tth-<sha> and a build timestamp.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 10:59:48 +02:00
tthandClaude Opus 5 5333a71927 fix(tools/ble_dfu): require the target address; feat: ble_cli.py; feat: silent-by-default repeater
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>
2026-08-03 21:46:23 +02:00
tth 8c3d7b076d Merge remote-tracking branch 'origin/main' into feat/ble-diag-and-2b-path-hash 2026-08-03 20:07:53 +02:00
tthandClaude Opus 5 ee7eab747a chore: gitignore tools/__pycache__, editor-added comment in extensions.json
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 19:12:21 +02:00
tthandClaude Opus 5 bfdaf32d30 feat(mesh): default to 2-byte path hashes (PATH_HASH_MODE_DEFAULT)
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>
2026-08-03 19:12:15 +02:00
tthandClaude Opus 5 85be4a76a6 feat(repeater/ble): runtime conn TX power (blepwr) + negotiated params (bleconn)
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>
2026-08-03 19:12:04 +02:00
Liam Cottle fec0521099 Merge pull request #3047 from dg1tal/codex/docs-3044-group-privacy
Clarify hashtag privacy and group sender identity
2026-07-28 15:41:48 +12:00
DG1TAL ae3517f480 Clarify hashtag privacy and group sender identity 2026-07-27 20:07:08 +02:00
tthandClaude Fable 5 c4f3941897 perf(repeater/ble): non-blocking console TX pump — main loop never stalls on BLE
bleWriteAll used to spin-retry with delay(3) when the SoftDevice
notification queue was full, stalling loop() up to ~0.9 s per call
while a client streamed the console (rxlog/pktlog drains). That is
long enough to disturb LoRa RX/TX timing on the relay path.

Replace with a 4 KB ring buffer: bleWriteAll only enqueues, and
bleTxPump() (each loop pass) hands the SoftDevice as much as it will
take right now — zero waiting. Overflow truncates the newest bytes;
a torn page loses its 'E,' trailer so the bridge re-requests the
same cursor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 21:24:20 +02:00
tthandClaude Fable 5 b7af3924b0 fix(repeater/ble): widen conn interval 15-30 -> 60-80 ms; pktfeed ring 32 -> 64
Fewer SoftDevice connection events = fewer LoRa TX collisions (the
measured driver of the direct-forward loss); the Dispatcher TX retry
covers the residue. Bigger pktfeed ring buys margin for the bridge's
new connect->drain->disconnect duty cycle (~3-4 min between drains).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 13:43:34 +02:00
tthandClaude Fable 5 6e076a6e8d fix(mesh/tx): requeue failed transmits with backoff instead of dropping
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>
2026-07-21 13:43:34 +02:00
Liam Cottle 4fd6f50a16 Merge pull request #1865 from MeshEnvy/fix/python-json-parse-error
fix: JSON parsing regression in build.sh
2026-07-19 22:58:21 +12:00
tthandClaude Fable 5 c5fb0fb4ce feat(repeater/analyzer): pktfeed ring + pktlog cmd — raw frames for the community observer feed
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>
2026-07-16 20:50:25 +02:00
tthandClaude Fable 5 91f827cede feat(repeater/analyzer): big console pages + physics-sized tables (rxlog 512, heard 128)
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>
2026-07-15 11:53:48 +02:00
tthandClaude Fable 5 ce907bbe4a feat(repeater/analyzer): grow rxlog ring 96 -> 256 records
Daytime advert bursts (an advert plus its copies from surrounding repeaters
arrive within seconds) overflowed the 96-slot ring between BLE bridge drains --
~250 dropped records/h in meshcore_rxlog_dropped_total, zero at night. 256
records at ~32 B each costs +5 KB RAM (17.7% total on nRF52840). Paired with
bridge-side tuning (drain page cap 20 -> 60, poll 5 s -> 2 s in home-scripts).

Flashed to mast-three.example via BLE DFU 2026-07-14.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 18:30:24 +02:00
ripplebiz a187f63fc5 Merge pull request #2943 from meshcore-dev/revert-2915-main
Revert "Add StreamSensor allocation for GroupData"
2026-07-13 19:31:05 +10:00
ripplebiz 95f3869475 Revert "Add StreamSensor allocation for GroupData" 2026-07-13 19:30:11 +10:00
ripplebiz 668d5a554a Merge pull request #2915 from hpux735/main
Add StreamSensor allocation for GroupData
2026-07-13 18:42:54 +10:00
tthandClaude Opus 4.8 ef6628afed fix(repeater/analyzer): colon-delimit path hops so hash width is self-describing
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>
2026-07-12 19:16:48 +02:00
tthandClaude Opus 4.8 dd2642dc0e feat(repeater/analyzer): multi-path join key + prefer direct 0-hop path
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>
2026-07-12 18:47:44 +02:00
tthandClaude Opus 4.8 d882f6c4bd fix(repeater/ble): slave latency 4 -> 0 to hold sync on the marginal link
btmon shows the disconnects are HCI reason 0x3E (Connection Failed to be
Established / lost sync), not supervision timeout -- so widening the timeout
didn't help. The mast link is weak (RSSI -75..-90) and the node is busy with
LoRa; with slave latency 4 the peripheral may skip connection events, so the
central loses sync and reports 0x3E. Respond on every event (latency 0) to
maximise sync on a weak/busy link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 02:29:18 +02:00
tthandClaude Opus 4.8 ccf4802132 fix(repeater/ble): raise BLE supervision timeout 6s -> 16s
6 s cut the reconnect churn from every 15-30 s to every ~60 s but didn't
eliminate it: under the bridge's real polling load the node shows a
periodic multi-second stall (advert TX airtime / SoftDevice-LoRa
coexistence) that occasionally exceeds 6 s. Widen the supervision timeout
to 16 s so those stalls are tolerated; a genuine freeze is still caught by
the 20 s hardware watchdog (16 s < 20 s).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 02:00:33 +02:00
tthandClaude Opus 4.8 5fbb3e0a6c fix(repeater/ble): widen connection supervision timeout to stop link churn
The BLE console link dropped every ~15-30 s and the bridge kept
reconnecting. Root cause: Bluefruit's default supervision timeout is only
2 s, and this repeater relays heavy LoRa flood traffic, so main-loop /
radio coexistence stalls past 2 s and the central tears down the link.

Mirror the companion's proven approach (explicit sd_ble_gap_conn_param_update
on 'secured', since some centrals ignore the advertised PPCP) but widen the
supervision timeout to 6 s (a repeater is far busier than a client), with a
15-30 ms interval and slave latency 4. PPCP is also set before advertising.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 01:15:29 +02:00
tthandClaude Opus 4.8 55166d4773 perf(repeater): drop duplicate per-packet SHA-256 from rxlog capture
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>
2026-07-12 01:05:16 +02:00
tthandClaude Opus 4.8 44aa778e97 feat(repeater): passive mesh analyzer -- nodes + rxlog over the console
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>
2026-07-12 00:19:32 +02:00
tthandClaude Opus 4.8 5c092498ff feat(core): capture per-packet RSSI at RX (Packet::_rssi)
SNR was already stored on the Packet at parse time, but RSSI was only
transiently available via Radio::getLastRSSI() -- valid synchronously in
checkRecv(), but stale by the time a score-delayed flood packet reaches
its handler (onAdvertRecv etc.). Store RSSI alongside _snr so downstream
code (e.g. the mesh analyzer) gets the correct last-hop RSSI regardless
of when it reads it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 00:19:20 +02:00
tthandClaude Opus 4.8 952b677a01 fix(sensor read): full node telemetry + per-channel decode
sensor read only called querySensors(), so it missed the node's own battery voltage and built-in MCU temperature (added separately in the mesh-telemetry path) — hence only one temperature showed. Now mirror that assembly (addVoltage + querySensors + MCU addTemperature). Decode keys every field by its LPP channel (temperature.1 = MCU, temperature.2 = ambient, etc.) so same-type values no longer collide, and skip unknown LPP types by their known size instead of break-ing (which silently dropped everything after e.g. INA226 power).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 20:09:35 +02:00
tthandClaude Opus 4.8 ae80337a8f config: git-ignored BLE PIN secret + SenseCap SHT41/INA226 + nRF52 framework symlink
Add [secrets] ble_pin mechanism: envs use ${secrets.ble_pin}, the committed default is a non-secret placeholder, and the real PIN lives only in the git-ignored platformio.local.ini. Move INA226 to 0x40 (frees 0x44 for SHT41), skip flaky GPS detection on SenseCap, and use a local framework symlink for the nRF52 short-SHA fork.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 19:21:11 +02:00
tthandClaude Opus 4.8 cba8164693 feat: expose repeater text console over BLE + nRF52 SoftDevice fixes
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>
2026-07-11 19:21:11 +02:00
tthandClaude Opus 4.8 40c166fa7f feat: dual BLE/USB serial interface + dock-quiet BLE
Backport of PR #1779 (BLE companion usable over USB while BLE disconnected), plus: track the active transport (secure-transport gating), and stop BLE advertising while a USB host is connected (docked) so the node stays quiet on 2.4 GHz; resume advertising when undocked. An active BLE link is never force-disconnected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 19:21:11 +02:00