Commit Graph
1409 Commits
Author SHA1 Message Date
mikecarper 2c4e6da63b Add explicit Heltec companion FEM builds 2026-07-17 10:28:52 -07:00
mikecarper 09c8aaba9c Add repeater flood filters and transport scopes 2026-07-17 00:35:51 -07:00
mikecarper 63776482e1 Add repeater filtering, clock sync, and companion fixes 2026-07-15 17:40:20 -07:00
mikecarper 0d2eb2420c Register SolarXiao LoRa OTA targets 2026-07-15 10:41:47 -07:00
mikecarper 710790b81d Enable LoRa OTA for nRF52 repeaters 2026-07-15 09:49:40 -07:00
mikecarper dce99fd5b3 Add WiFi MQTT companion setup portal 2026-07-15 00:27:20 -07:00
mikecarper 11aa4bc191 Harden LoRa OTA and enable unattended targets 2026-07-14 15:24:35 -07:00
mikecarper 8599cf0acb Verify staged OTA payloads and flash writes 2026-07-14 14:42:26 -07:00
mikecarper a45c43f2b1 Add RX watchdog and fix repeater builds 2026-07-13 23:42:04 -07:00
mikecarper fcfca64cc5 Refine trace and group data retries 2026-07-13 17:56:08 -07:00
mikecarper e3f47b487b Harden packet, retry, and alert handling 2026-07-13 16:37:32 -07:00
mikecarper b8f438d6ea Honor retry settings across firmware roles 2026-07-13 15:22:36 -07:00
mikecarper 4f839d3477 Reduce background polling and radio power use 2026-07-13 14:36:34 -07:00
mikecarper b9e7e416be Harden retry, region, radio, and alert logic 2026-07-13 13:18:49 -07:00
mikecarper 5a2aa592ea Improve repeater alerts and delivery reliability 2026-07-13 09:54:16 -07:00
mikecarper da00a00436 Improve repeater reliability and build tooling 2026-07-13 01:03:27 -07:00
mikecarper 2b4aed4ef1 Merge branch 'dev' of github.com:meshcore-dev/MeshCore into keymindCascade
# Conflicts:
#	examples/simple_repeater/main.cpp
#	examples/simple_room_server/main.cpp
#	src/helpers/sensors/EnvironmentSensorManager.cpp
#	src/helpers/sensors/MicroNMEALocationProvider.h
2026-07-13 00:44:40 -07:00
ripplebizandGitHub 174bcdfbcc Merge pull request #2942 from liamcottle/board/thinknode-m9
Add support for Elecrow ThinkNode M9
2026-07-13 17:10:54 +10:00
liamcottle 87bf371cd3 initial support for thinknode m9 2026-07-13 19:07:09 +12:00
ripplebizandGitHub 4f12dc02d5 Merge pull request #2937 from benskigomez/fix/gps-timesync-millis-overflow
sensors: fix millis() rollover that stalls GPS time-sync on long-uptime nodes
2026-07-13 17:06:09 +10:00
Jody Bentley 63731d3fbf sensors: fix millis() rollover stall in GPS time-sync + minor cleanups
next_check and next_gps_update stored a future millis() value in a signed
long and compared with a naive '>'. After the ~24.8-day millis() sign flip
the deadline sits above the wrapped millis(), so the block never runs again
and GPS->RTC time-sync (and the location cache refresh) stall permanently
until reboot. Switch to unsigned deadlines with the wrap-safe signed-
difference compare '(long)(millis() - deadline) > 0', matching the idiom in
Dispatcher::millisHasNowPassed.

Also: reorder the MicroNMEALocationProvider ctor init-list to declaration
order (silences -Wreorder) and drop the always-true 'if (_claims > 0)' guard
in claim() (claim() always runs after _claims++, so it is >= 1).
2026-07-12 18:30:40 -04:00
Alex Beal 07b543176b Merge branch 'dev' into pr-1446 2026-07-12 15:44:28 -06:00
mikecarper 73c6472d95 Harden flood retry airtime handling 2026-07-11 23:51:14 -07:00
mikecarper 927d7869ff Treat flood retry prefixes as bridge bucket seven 2026-07-11 23:11:25 -07:00
mikecarper 7d6bd44082 Match retry prefixes across path hash widths 2026-07-11 23:00:05 -07:00
mikecarper 0ede4e2066 Merge RX duty-cycle power saving into keymindCascade 2026-07-11 22:12:20 -07:00
mikecarper 4f8f36354e Restore Keymind features after LoRa OTA merge 2026-07-11 12:45:02 -07:00
mikecarper 4c0dbe707d Merge PR 2864 LoRa OTA into Keymind 2026-07-11 12:40:31 -07:00
agessaman b88dc02b66 Merge mcarper/keymindCascade into mqtt-observer-plus
Integrates Mike Carper's transmission-reliability work (direct retries with
SNR-adaptive backoff and CR, flood retry controls, alt-path replies, flood
channel gates) plus its upstream/dev base (as of 2026-07-06) on top of the
observer stack. The flex branch is untouched; this branch is the experimental
integration line.

Conflict-resolution decisions, for future re-syncs (git rerere is enabled and
has recorded these):
- NodePrefs adopts keymind/upstream member order + retry/flood tail. Member
  order is in-memory only: /com_prefs stays field-by-field with the same
  canonical file order both sides already share through offset 294; keymind
  appends the retry tail at 295+ (new canonical size 676). Flex fleet files
  load unchanged; retry fields default via direct_retry_prefs_magic.
- loadPrefsInt keeps the fork's legacy MQTT-gap recovery but moves its
  detection boundary from 'extra > 5' to 'extra > LEGACY_MQTT_GAP_3SLOT (864)'
  so keymind-size tails take the normal read path. COM_PREFS_TAIL_BYTES
  retired.
- Dispatcher/RadioLibWrappers: fork watchdog additions + keymind TX overrides
  and CAD busy counter are unioned; RxReservePacketManager::queueOutbound
  follows upstream's new bool return (false when shedding).
- CommonCLI: fork observer dispatch + versioned /mqtt_prefs machinery kept;
  keymind CLI (retry/flood/radioat) taken; duplicate CAD/FEM handlers and
  sanitise lines deduped (kept keymind placements to minimize future diff).
- MyMesh (repeater/room): fork alerter/OTA/observer wiring kept; keymind
  scheduled-radio system replaces the old pending_* temp-radio members;
  applySavedRadioParams() replaces raw setParams at startup.
- ESP32Board: fork manifest-OTA + keymind powerOff/deepSleep and stopOTAUpdate
  unioned; startOTAUpdate keeps fork's STA-aware IP with keymind's idempotency
  guard.
- build.sh taken wholesale from keymind (fleet builds use GH Actions).

Verified: Heltec_v3_repeater_observer_mqtt, Heltec_v3_repeater,
heltec_v4_repeater_observer_mqtt, Heltec_v3_room_server_observer_mqtt build;
host migration harness (13 MQTT + non-MQTT scenarios) passes with updated
expectations (676-byte /com_prefs; odd-size files normalize on save, not
load); native unit tests 13/13.
2026-07-09 23:10:41 -07:00
agessaman 9bbc43822c Merge branch 'restore/upstream-duty-cycle' into restore/fem-rxgain 2026-07-09 19:06:50 -07:00
agessaman 847be34e7d fix(mqtt): keep throttled nodes administrable — priority-aware shed + stale expiry
Device testing at 'set dutycycle 1' on a busy mesh showed the node becoming
un-administrable within ~2 minutes: the shed policy dropped its own CLI
responses along with repeats, and parked retransmissions (which never expire)
absorbed every budget refill.

RxReservePacketManager now sheds by priority below the RX reserve — only
pri > 1 outbound (multi-hop flood repeats, adverts, trace) is refused, so the
node's own responses/ACKs (pri 0) and login/PATH replies (pri 1) still queue;
below an emergency floor (reserve/2) everything is shed to protect capture.
Queued packets untransmitted 30 s past their scheduled time are expired at
dequeue via a pointer-keyed age table (the pool is a fixed set of packets, so
pool_size slots cover every key). Under normal load the queue drains in
milliseconds and neither policy triggers.
2026-07-09 19:06:41 -07:00
agessaman 1d52161332 Merge branch 'restore/upstream-duty-cycle' into restore/fem-rxgain 2026-07-09 17:54:45 -07:00
agessaman 1c9c6292e5 fix(mqtt): shed retransmissions, not capture, when duty cycle starves the pool
Load-testing the restored token bucket at 'set dutycycle 1' showed MQTT
capture dropping to exactly the TX rate. Queued retransmissions hold static-
pool packets with no expiry, so throttling parks the whole pool in the send
queue; Dispatcher::checkRecv() then discards received packets before logRx()
ever feeds the bridge — each completed TX frees exactly one packet for
exactly one more RX.

Observer builds now use RxReservePacketManager (fork-owned header): once the
free pool drops below a quarter of the pool, outbound packets are refused and
freed, so RX allocation and MQTT capture continue at full rate while the node
sheds repeat load it has no TX budget for anyway. Non-observer builds keep
upstream pool behavior via the same factory; StaticPoolPacketManager stays
byte-identical to upstream.
2026-07-09 17:54:38 -07:00
Jarosław Domański 415faea52f Added RX duty-cycle noise floor calibration again (this time it works!) 2026-07-09 22:23:56 +02:00
agessaman ae9c01f0b7 Merge branch 'restore/upstream-duty-cycle' into restore/fem-rxgain 2026-07-09 12:18:47 -07:00
agessaman 4b7a312209 fix(radio): match upstream performChannelScan signature; name /com_prefs tail size
performChannelScan was restored as protected non-virtual but upstream declares
it public virtual — match upstream verbatim so the hunk disappears from the
merge surface. Also replace the bare 'extra > 5' tail threshold with
COM_PREFS_TAIL_BYTES, tied by comment to the trailing writes in savePrefs(),
so the next upstream field append updates one named constant.
2026-07-09 12:18:33 -07:00
agessaman 3e1b8638e2 Merge branch 'feat/clean-up-merge' into restore/upstream-duty-cycle 2026-07-09 12:16:41 -07:00
agessaman c3b8633aa7 fix(mqtt): hold newer-version /mqtt_prefs across saves + pin frozen layouts
The unknown-version path kept defaults at boot but any later savePrefs()
(every CLI set command) rewrote /mqtt_prefs as v1 with defaults, destroying
the newer config after a firmware downgrade. Latch _mqtt_prefs_hold when an
unsupported version is seen and refuse to write while it is set — checked
before the NRF52/STM32 open path, which deletes the file first.

Also pin the frozen legacy /mqtt_prefs layouts (472/1464/2904 bytes + 8-byte
header) with static_asserts so every target build re-verifies the deployed
fleet's file offsets, and null-check _obs in AlertReporter::onLoop.
2026-07-09 12:16:20 -07:00
agessaman e905451dce feat(radio): drive LoRa FEM RX gain from radio_fem_rxgain (heltec_v4)
Completes the FEM RX-gain restoration begun in the CAD/prefs change, which
persisted radio_fem_rxgain but didn't yet drive the hardware. Also dropped
by the 22eb9b87 revert; restored to match upstream.

- MainBoard: setLoRaFemLnaEnabled()/canControlLoRaFemLna()/isLoRaFemLnaEnabled()
  virtuals (default: can't control — non-FEM boards report unsupported)
- heltec_v4: board overrides driving loRaFEMControl; LoRaFEMControl gains the
  isLNAEnabled() getter (it already tracked lna_enabled and drove the FEM)
- CLI: `set radio.fem.rxgain on/off` / `get radio.fem.rxgain` (guarded by
  canControlLoRaFemLna, so it reports "unsupported" on non-FEM boards)
- app startup applies the persisted pref: board.setLoRaFemLnaEnabled(
  _prefs.radio_fem_rxgain), beside setRxBoostedGainMode

Default is ON (upstream), so on FEM boards the LNA is enabled after upgrade —
a real reception behavior change to confirm on hardware. The other FEM
variants (heltec_t096/tower_v2/tracker_v2) need the same small board-override
addition; until then `radio.fem.rxgain` reports unsupported there (no
regression — status quo).

Builds: heltec_v4 repeater-observer + room-observer (FEM board), Heltec_v3
repeater (non-FEM, base virtuals no-op). NEEDS on-device validation on a
Heltec V4.
2026-07-09 11:20:07 -07:00
agessaman df90673d18 feat(radio): restore CAD support + radio_fem_rxgain persistence (upstream parity)
Continues restoring features dropped by the 22eb9b87 revert. Both were
upstream-tested code, not intentional fork removals.

CAD (hardware Channel Activity Detection / listen-before-talk before TX),
fully restored and functional:
- NodePrefs.cad_enabled + `set cad on/off` / `get cad` CLI (default off)
- RadioLibWrapper: _cad_enabled + setCADEnabled() + the scanChannel()/CAD
  branch in isChannelActive() (Phase 1 already restored the Dispatcher hook)
- getCADEnabled() overrides in the repeater/room/sensor apps (return the
  pref) and companion (always on, matching upstream)

radio_fem_rxgain: the NodePrefs field + /com_prefs persistence are restored
here at upstream's exact offsets (293 fem, 294 cad), which makes /com_prefs
byte-identical to upstream through the tail. The field is persisted and
defaults on (upstream default), but the per-board LNA *driving* + the
`radio.fem.rxgain` CLI are deferred to the FEM-hardware change (they depend
on board methods and want per-board bench testing).

The new-format /com_prefs tail grows from 3 to 5 bytes; the old-format
detection threshold and the host migration harness are updated accordingly
(all scenarios pass, incl. the non-MQTT-build variant).

Builds: Heltec_v3 repeater, repeater-observer, room-observer. (sensor /
plain-room / companion fail only on the pre-existing Timezone.h include
issue, unrelated to these changes.)
2026-07-09 11:12:57 -07:00
agessamanandClaude Fable 5 7076ff5b31 fix(radio): restore upstream token-bucket duty-cycle enforcement
Commit 22eb9b87 ("Revert 'Merge remote-tracking branch origin/dev...'")
reverted an entire upstream merge to escape a bad merge state, dropping
860 lines across 66 files. Among the collateral never reconciled on a
later re-merge was eb4fa032's token-bucket duty-cycle enforcement — the
mechanism that keeps nodes under a configured airtime budget (and EU
868 MHz nodes under the legally-mandated duty cycle). The fork had fallen
back to fixed per-packet spacing (getAirtimeBudgetFactor reverted to 2.0),
losing the windowed enforcement.

This was never an intentional design choice, so restoring it re-aligns the
fork with upstream and REDUCES the merge-conflict surface: Dispatcher.{h,cpp}
now diverge from upstream by watchdog additions only (77 insertions, 0
deletions) instead of rewriting checkSend()/loop().

Restored from upstream: updateTxBudget/tx_budget_ms/duty_cycle_window_ms/
getRemainingTxBudget/getDutyCycleWindowMs and the windowed budget logic in
Dispatcher; getOutboundTotal() and the 0xFFFFFFFF count-all sentinel in
StaticPoolPacketManager; the getOutboundTotal() call in StatsFormatHelper.
Re-applied the fork's MQTT radio-watchdog on top as pure additions
(#ifdef WITH_MQTT_BRIDGE), keeping formatRadioDiag.

Stored airtime_factor settings keep their meaning: fork's t*factor spacing
and upstream's 1/(1+factor) windowed budget yield the same steady-state
duty cycle; upstream additionally allows short bursts within the window.

Phase 2 (CAD / radio_fem_rxgain, which touch NodePrefs persistence and
per-board FEM wiring) is documented in RESTORE_UPSTREAM_NOTES.md, not done
here. Builds: Heltec_v3 observer + plain repeater. NEEDS ON-DEVICE
duty-cycle validation before merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 10:08:14 -07:00
agessamanandClaude Fable 5 58b9cb66a6 refactor(mqtt): version the /mqtt_prefs file format and drop vestigial fields
The /mqtt_prefs format was detected purely by struct size, which is fragile
(size collisions across eras) and forced the vestigial `_legacy_*` fields to
be retained forever to preserve byte offsets. With ~several thousand observer
devices deployed from the rolling `observer-mqtt-latest` flasher, this is the
last safe moment to fix it before the observer-settings split ships.

/mqtt_prefs now leads with an 8-byte MQTTPrefsHeader (magic {0xF5,'M','Q','P'},
version, payload_len) followed by the raw payload. The magic's non-ASCII lead
byte cannot collide with a legacy file (whose payload starts with the
mqtt_origin string), so versioned and headerless files are cleanly separable.
An unrecognized (newer) version leaves the file untouched and falls back to
defaults rather than misreading it.

MQTTPrefs is compacted: the six `_legacy_*` fields are removed. Every deployed
headerless layout — pre-slot (OldMQTTPrefs), 3-slot (ThreeSlotMQTTPrefs), and
the shipped 6-slot flex layout (new Legacy6SlotMQTTPrefs) — is field-copied
into the compact struct and re-saved with the header once, on first boot.
Future fields append to the payload and stay backward compatible.

Verified with a host harness that generates a byte-exact deployed flex
/mqtt_prefs (the flex MQTTPrefs is confirmed identical to Legacy6SlotMQTTPrefs,
2904 bytes) and round-trips it through the new load path, plus pre-slot/3-slot
migration, unknown-version safety, magic/origin collision-safety, and the
combined /com_prefs observer-tail recovery. Observer + room-server + no-MQTT
ESP32 targets build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 08:40:48 -07:00
Wessel Nieboer 4605d3b6ce fix misspelled RF switch pin macros in SX1268/LLCC68/SX1276 radio wrappers 2026-07-09 16:31:28 +02:00
Jarosław Domański a1330facff Improved RX duty-cycle watchdog observation with esp32 sleep in mind 2026-07-09 14:39:20 +02:00
Jarosław Domański 9cbd944a29 Added RX duty-cycle watchdog recovery 2026-07-09 12:00:15 +02:00
agessaman 5a1a0cd5ec Merge branch 'mqtt-bridge-implementation-flex' into feat/clean-up-merge
# Conflicts:
#	src/helpers/bridges/MQTTBridge.cpp
2026-07-08 19:55:04 -07:00
agessamanandClaude Fable 5 55110ffa94 fix(mqtt): migrate observer settings from legacy /com_prefs on upgrade
The NodePrefs->MQTTPrefs split (2eb41bae) left the promised one-time
migration of the old /com_prefs trailing block unimplemented, so users
upgrading an observer node silently lost SNMP, radio-watchdog, and
fault-alert configuration (alerts reset to off; PSK/hashtag/region wiped).

loadPrefsInt now detects an old-format /com_prefs by its size, skips the
legacy zero-filled MQTT gap (6-slot or 3-slot era), and recovers the
trailing observer block into a LegacyObserverTail (reusing the old
firmware's byte291/292 heuristic and per-field availability guards).
loadMQTTPrefs applies those values when the loaded /mqtt_prefs predates
the appended observer fields, and both files are rewritten once in the
current layout. rx_boosted_gain/flood_max_* are also recovered from the
correct offsets (previously read from inside the old gap and reset).

Verified with a host-side harness that round-trips the real old-firmware
savePrefs (from 2eb41bae^) through the new load path across upgrade,
fresh-install, upstream-format, 3-slot-era, truncated, and legacy-variant
cases, plus a non-MQTT-build variant. Updates the stale migration comments
and documents the CommonCLI_Observer seam in MQTT_IMPLEMENTATION.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 19:53:20 -07:00
Jarosław Domański 92d09c84ef Fixed RX power saving RSSI sampling during listen windows 2026-07-08 23:49:35 +02:00
Jarosław Domański 38034d2ee2 Fixed RX duty-cycle rearming and profile timings 2026-07-08 14:25:14 +02:00
Jarosław Domański e97f0fecc6 Added RX duty-cycle power saving support 2026-07-08 08:49:37 +02:00