Commit Graph
1227 Commits
Author SHA1 Message Date
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
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
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
agessaman 7e0ffdbea3 feat(mqtt): clarify custom endpoint requirements in code and documentation
Updated MQTT configuration to succeed when port is defined in mqttN.server but not explicitly set in mqttN.port. Updated documentation to specify that when a full
URL with a scheme is provided, the port setting is optional. Added an
example for local development using a plain WebSocket URL, enhancing
clarity for users configuring custom MQTT brokers.
2026-07-06 12:34:53 -07:00
agessaman 2eb41baeda refactor(mqtt): migrate observer settings to MQTTPrefs structure
Refactored the handling of observer-related settings by moving them from
NodePrefs to a new MQTTPrefs structure. This change centralizes MQTT,
WiFi, timezone, SNMP, and alert configurations, improving code organization
and maintainability. The new structure allows for better separation of
concerns and prepares the codebase for future enhancements.
2026-06-26 08:59:48 -07:00
agessaman 9535f243af refactor(cli): move observer command handling to CommonCLI_Observer.cpp
Refactored the CommonCLI class to separate observer-related command
handling into CommonCLI_Observer.cpp. This change improves code
organization and maintainability by isolating MQTT, WiFi, and other
observer-specific commands from the main CLI logic.
2026-06-25 14:05:16 -07:00
agessaman 706d1c7ea2 fix(mqtt): enhance error handling for connection refusals
Improved error handling in the MQTT client to log specific reasons
for connection refusals, including detailed return codes. This change
ensures that users are informed of authentication issues and server
availability problems, enhancing the debugging experience.
2026-06-25 08:13:55 -07:00
Adam Gessaman b699bf6a3b Merge branch 'mqtt-bridge-implementation-flex' into add-rflab-mqtt-preset 2026-06-24 21:38:49 -07:00
agessaman c39ab639b0 feat(mqtt): add ipnt.uk preset to MQTT presets 2026-06-24 21:20:56 -07:00
agessaman b458ac42e4 perf(mqtt): remove dead code and optimize hex conversion
Remove unused MQTTMessageBuilder members (getPacketTypeString,
formatTimestamp/Time/Date stubs, JSON_BUFFER_SIZE constant) for a
small flash saving with no behavior change.

Replace the per-byte snprintf("%02X") in bytesToHex with a nibble
lookup table, avoiding a format-string parse up to ~512x per publish
on the MQTT task. Output is byte-for-byte identical uppercase hex.
2026-06-24 20:33:00 -07:00
agessaman 7416d632b9 feat(mqtt): add NTP server configuration and diagnostics commands
Implemented new commands for configuring and diagnosing NTP server
settings in the MQTT bridge. Users can now set a custom NTP server
and probe connectivity to configured servers. This enhancement
improves time synchronization reliability for JWT authentication
and provides better diagnostics for NTP connectivity issues.
2026-06-24 17:14:11 -07:00
agessaman 125ddac184 feat(ota): add partition-table signature handling for OTA updates
Implemented functionality to generate and compare partition-table
signatures during OTA updates. This enhancement ensures that the
target build's partition layout matches the device's actual layout,
improving the reliability of OTA updates and preventing issues
related to partition changes.
2026-06-23 15:38:10 -07:00
agessaman a6851813f9 fix(ota): improve display of version and hash in OTA status messages
Updated the otaFromManifestImpl method to enhance the display of
available and current firmware versions. The changes ensure that
the short commit hash is included in the status messages,
providing clearer versioning information during OTA checks.
2026-06-23 14:25:06 -07:00
agessaman 5acfdd736a fix(ota): enhance manifest fetching logic for OTA updates
Improved the otaFromManifestImpl method to handle dry run scenarios
by allowing HTTP fetches without TLS, reducing heap usage on no-PSRAM
boards. This change ensures better compatibility and reliability during
OTA checks while maintaining security for actual updates.
2026-06-23 14:08:12 -07:00
agessaman 730eb37dbd feat(ota): implement build number suffix for firmware versioning
Enhanced the firmware versioning system by appending a build number
suffix when available, allowing for better tracking of published builds.
This change improves the OTA update process by providing clearer
versioning information in the embedded firmware string.
2026-06-23 12:55:07 -07:00
agessaman addb637b63 feat(mqtt): add meshcore-fi preset to MQTT presets 2026-06-23 09:31:45 -07:00
Adam Gessaman a06a14dfa8 Merge pull request #17 from agessaman/feat/ota-web
Feat/ota web
2026-06-22 22:36:38 -07:00
agessaman c1885fcc15 feat(ota): implement deferred OTA update scheduling and handling
Added support for deferred OTA updates in the MyMesh class, allowing
the system to schedule firmware updates to occur after a confirmation
reply is sent. This change improves the user experience by ensuring
that the update process does not block the main application loop,
allowing for smoother operation during firmware updates.
2026-06-22 22:33:57 -07:00
agessaman dec668386a fix(ota): improve OTA update handling for connected WiFi networks
Updated the startOTAUpdate method to serve the ElegantOTA on the
station IP when connected to a WiFi network, enhancing accessibility
for OTA updates. If not connected, it defaults to the MeshCore-OTA
SoftAP. This change improves the user experience by allowing easier
access to OTA updates without needing to switch networks.
2026-06-22 21:28:18 -07:00
agessaman 3719ebb980 fix(ota): improve streaming JSON parsing in otaFromManifest
Updated the otaFromManifest method to stream-parse the firmware manifest
directly from the network, reducing peak RAM usage during OTA checks. This
change enhances compatibility with slow TLS links by implementing a per-read
timeout, ensuring a more efficient and reliable update process.
2026-06-22 19:53:40 -07:00
agessaman e84c266576 feat(ota): add ota check and ota update commands for pull-based updates 2026-06-22 19:36:05 -07:00
agessaman b679c0d712 fix(ota): handle HTTP response and empty manifest in otaFromManifest
Updated the otaFromManifest method to enforce HTTP/1.0 for better
compatibility with CDNs and to handle empty manifest responses. This
ensures that the JSON parser receives a complete body, preventing
errors during firmware update checks.
2026-06-22 19:32:23 -07:00
agessaman 454afec91d feat(mqtt): add flmesh.us preset to MQTT implementation 2026-06-22 13:52:48 -07:00
agessaman 004d308ea9 feat(ota): implement pull-based OTA from manifest for observer builds
Added functionality to support pull-based OTA updates by fetching firmware
from a manifest. The new `otaFromManifest` method allows the system to
check for available updates and flash the firmware if necessary. This
enhancement improves the update process for observer builds using the
MQTT bridge, ensuring a more seamless firmware management experience.
2026-06-21 11:57:05 -07:00
Dreikor17 32b0eb91dd feat(mqtt): add rflab.io WebSocket broker preset
Adds the "rflab" built-in MQTT preset and bumps MQTT_PRESET_COUNT to 22.

  - Server:   wss://mqtt.rflab.io:443
  - Auth:     JWT (Ed25519 device identity), audience mqtt.rflab.io
  - Topic:    MeshCore style
  - TLS:      Let's Encrypt, pinned to ISRG Root X1

Also documents the preset in the MQTT_IMPLEMENTATION.md preset table.
2026-06-21 11:20:44 -05:00
agessaman 618c849d53 feat(mqtt): enhance timestamp formatting with microsecond precision
Updated the MQTTMessageBuilder to include microsecond precision in the
timestamp formatting. The formatIsoTimestampForMqtt function now accepts
a microsecond parameter, allowing for more accurate time representation.
Modified related functions in MQTTBridge to utilize the new timestamp
formatting, ensuring consistency across MQTT messages.
2026-06-18 15:03:02 -07:00
agessaman 8bf590b1e3 Enhance MQTT message structure by adding cumulative packet statistics (packets_sent and packets_received) to the status message. Update related functions in MQTTMessageBuilder and MQTTBridge to handle new parameters and ensure proper JSON serialization. Document the new fields and their significance in the implementation notes. 2026-06-16 15:59:36 -07:00
agessaman e80a5ded1c Enhance MQTT message handling by updating path representation to use an array of lowercase hex hop tokens. Refactor related functions in MQTTMessageBuilder to accommodate new path parameters and improve JSON serialization. Update documentation to reflect changes in path handling and timestamp formatting. 2026-06-16 14:39:03 -07:00
Adam Gessaman cf629fb71b Update MQTT implementation to add CTMesh preset and adjust related documentation 2026-06-10 10:12:42 -07:00
Adam Gessaman 4d6fa74062 Add BostonMesh preset 2026-06-10 09:45:39 -07:00
agessaman b45373a31f Update firmware build date format and enhance MQTT timestamp handling to always emit UTC with "+00:00" offset. Adjusted buffer sizes for timestamps in MQTTMessageBuilder and MQTTBridge to accommodate new format. 2026-06-06 20:29:52 -07:00
agessamanandCursor dcc8f826db Merge upstream/dev into mqtt-bridge-implementation-flex
Pick up 97 commits from upstream/dev, resolving conflicts in
CommonCLI prefs layout, board definitions, docs, and T-Beam Supreme
platformio config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 09:29:16 -07:00
Scott Powell 5f6821bb66 * new CLI config: flood.max.advert (default 16) 2026-06-06 13:09:24 +10:00
Adam Gessaman 4a4f20a392 Update MQTT preset for Meshmapper to use new domain 2026-06-05 09:49:57 -07:00
Liam Cottle 1485d3301b Merge pull request #2463 from NoodlesNZ/fix-stddef
Add stddef.h to fix compilation issue on MacOS
2026-06-05 11:29:44 +12:00
Liam Cottle da21d42a2e Merge pull request #2672 from meshcore-dev/non-contact-requests
Non contact requests
2026-06-04 16:05:47 +12:00
Liam Cottle b83355e702 Merge pull request #2671 from sefinek/fix/typos-grammar-formatting
Fix typos and formatting in documentation and comments
2026-06-04 15:57:48 +12:00
ripplebiz 6be398d748 Merge pull request #2663 from oltaco/no-autoshutdown-when-powered
Disable auto-shutdown when externally powered, add auto-shutdown warning for OLED displays
2026-06-04 13:42:00 +10:00
Scott Powell 3c96a7de43 * powersaving on/off lowercase fix 2026-06-04 13:36:18 +10:00