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>
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>
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>
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>
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>
Add virtual BaseSerialInterface::isConnectionSecure() (default true). On the dual interface it is true only for MITM-paired BLE. Gate CMD_EXPORT_PRIVATE_KEY and CMD_SET_DEVICE_PIN, and hide the BLE PIN in CMD_DEVICE_QUERY, when the frame arrived over unauthenticated USB.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace three unbounded strcpy() into the fixed tmp[] buffer with StrHelper::strncpy(sizeof). Add 'sensor read' which decodes the live CayenneLPP telemetry (temperature/humidity/voltage/current/pressure/gps) to text, so a console/bridge can pull sensor values that 'sensor list' (settings only) never exposed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
onRecvPacket() used two received length fields without validating them against the actual received/decrypted length (TRACE payload_len underflow + OOB read; PATH path_len OOB stack read + extra_len underflow). Both now validated before use.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Before this commit, there was no way to set a different max hop count
for unscoped messages.
Now with this change, by defaul it tracks the flood.max setting, until
a user provides a flood.max.unscoped value, which tax precidence for
packets if ROUTE_TYPE_FLOOD is true.
This is a consolidation of my changes for BME680 on RAK4631 nodes.
I will close my other PRs related to this and link back to this one.
*Background on change:*
This change replaces the Adafruit BME680 driver on RAK4631 with the
Bosch BSEC library. Other boards continue to use the existing
Adafruit path via ENV_INCLUDE_BME680.
This makes the IAQ portion of the sensor functional, and more accurate.
It also contains the math and/or CayenneLPP fixes from my other PRs.
The Bosch code also appears to handle calibrating sensor aging as well,
whereas the Adafruit code is just looking at blind values that can drift
with time. Pretty cool to see this shooting out useful data!
RAK4631 platform.io is set to override to ENV_INCLUDE_BME680_BSEC while
leaving the Adafruit code for other node types. (If this becomes applicable
for other node types in future, awesome! I just don't have hardware
to test against.)
Using the BSEC library introduces IAQ sensor calibration, and saves
the calibration state periodically so it does not have to calibrate
again later.
At startup the IAQ sensor takes 30 minutes to heat and to hit a baseline,
then starts calibrating. Once calibrated, it will save those settings
and will only write settings again if calibration falls back and restores
back to state 3.
This fix also has the gas resistance math fix that was in
[pull 2146](https://github.com/meshcore-dev/MeshCore/pull/2146) so
the adafruit path also can at least show accurate values instead
of looping negative.
Also includes the fix from [pull 2149](https://github.com/meshcore-dev/MeshCore/pull/2149) so the pressure output isn't truncated to 1hPa steps.
*Fixes/Changes:*
- Add bsec_config_iaq[] with the 3.3V/3s-LP/28d calibration profile
- BSEC init applies setConfig() for voltage-correct heater targeting
- IAQ, heat-compensated temperature/humidity, pressure, and altitude
reported over CayenneLPP
- IAQ accuracy reported as analog input over CayenneLPP (0,1,2,3)
- Calibration state persisted to /bsec_state.bin on nRF52 internal
flash; written only when iaqAccuracy improves to >= 2, should
keep write frequency well within flash endurance over device lifetime
- Fix non-BSEC query_bme680: float pressure division, addGenericSensor
for gas resistance (was addAnalogInput, overflows at > 327 Ohm)
- loop() correctly gated for both GPS and BSEC-only builds
- Add fix_bsec_lib.py extra_script to resolve nRF52840 hard-float ABI
mismatch in Bosch's PlatformIO packaging, silly Bosch
One general note outside of this code change: I noticed while BME680
_functions_ in companion nodes, since companion nodes run Bluetooth,
BLE preempts the CPU, and can do so mid-I2C-transaction.
This can cause the BME680 to see an anomaly and drop calibration and
start a recalibrate. This is behavior that will exist (and has existed)
regardless of using the Adafruit or Bosch paths.
This particular companion behavior does not seem to occur in sensor
or repeater nodes since their BLE is off. Probably affects other
I2C devices as well.
*Tests:*
- RAK19003
- RAK19007
- RAK19001
- repeater, sensor, companion
Framework for upcoming variant-specific PRs that add LED feedback during boot. The hook gives users visual cues that the device is busy and
shouldn't be interacted with until startup completes.
Extract the inline cursor-walk in handleRegionCmd into file-local
helpers (skipSpaces, rtrimSpaces, takeToken, splitNameJump,
processRegionDefSegment), grouped immediately above the consumer.
Behavior is identical; addresses PR #2540 review feedback on
readability.
Tighten the region def docs: collapse five Note callouts into three
grouped paragraphs (Behavior / Existing regions / Limits), add a
case-sensitivity caveat plus an error example, note the cursor reset
between split commands, and use generic placeholder names.