Skip to content

fix: apply LoRa config changes live without rebooting - #9931

Closed
Elwimen wants to merge 6 commits into
meshtastic:developfrom
Elwimen:fix/lora-no-reboot-on-config-change
Closed

fix: apply LoRa config changes live without rebooting#9931
Elwimen wants to merge 6 commits into
meshtastic:developfrom
Elwimen:fix/lora-no-reboot-on-config-change

Conversation

@Elwimen

@Elwimen Elwimen commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

When LoRa configuration is saved, AdminModule::saveChanges() calls service->reloadConfig() which fires configChanged.notifyObservers(). This observer is already wired to RadioInterface::reloadConfig()reconfigure(), which puts the radio in standby, reprograms all modem parameters (SF, BW, CR, frequency, power), and restarts receive — all without a reboot. The reboot that followed was therefore redundant.

sx126x_rx_boosted_gain exception: this flag is applied during init() via lora.begin() and the retention memory writes involved are part of the chip initialization sequence (per SX1261/2 datasheet section 9.6). Register 0x08AC is preserved through STDBY mode, so it remains correctly set across reconfigure() calls. A reboot is still triggered only when that specific flag changes.

Prior art: ARCH_PORTDUINO with SimRadio already skipped the reboot for this exact reason.

Bonus: custom modem config display now shows EU_868/BW125-SF7-CR5 instead of EU_868/Custom.

Changes

  • src/modules/AdminModule.cpp — remove blanket reboot for LoRa config changes; reboot only when sx126x_rx_boosted_gain changes; reject LORA_24 region at runtime with BAD_REQUEST if the active radio hardware does not support 2.4 GHz (replaces the startup-only validation that previously required a reboot to enforce)
  • src/DisplayFormatters.cpp — keep "Custom" return value stable for non-preset mode (used by RadioInterface for uses_default_frequency_slot hashing and by Channels for default-channel detection)
  • src/graphics/draw/DebugRenderer.cpp — format BW/SF/CR directly in the display renderer when not using a preset, keeping the display improvement without affecting any non-display callers

Test plan

  • LilyGo T3S3 (ESP32-S3 + SX1262) — LoRa config change applies immediately, no reboot
  • LilyGo T-Echo (nRF52840 + SX1262) — LoRa config change applies immediately, no reboot
  • Verified TX and RX across various SF, CR and BW settings after live reconfigure
  • Setting LORA_24 region on SX1262 hardware returns BAD_REQUEST and logs a warning; config is not applied

@CLAassistant

CLAassistant commented Mar 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown
Contributor

@Elwimen, Welcome to Meshtastic!

Thanks for opening your first pull request. We really appreciate it.

We discuss work as a team in discord, please join us in the #firmware channel.
There's a big backlog of patches at the moment. If you have time,
please help us with some code review and testing of other PRs!

Welcome to the team 😄

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes unnecessary reboot after saving LoRa configuration by relying on the existing configChangedRadioInterface::reconfigure() live-apply path, and improves the on-device display string for custom modem parameters.

Changes:

  • Update AdminModule::handleSetConfig() to reboot only when sx126x_rx_boosted_gain changes.
  • Update DisplayFormatters::getModemPresetDisplayName() to show BW/SF/CR when not using a preset (for non-short names).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/modules/AdminModule.cpp Changes reboot decision logic for LoRa config updates to prefer live reconfigure.
src/DisplayFormatters.cpp Formats a detailed “custom” modem string for display when not using a preset.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/modules/AdminModule.cpp
Comment thread src/DisplayFormatters.cpp Outdated
@Elwimen
Elwimen force-pushed the fix/lora-no-reboot-on-config-change branch 2 times, most recently from 72cdf24 to 3fe8cee Compare March 17, 2026 22:03
@Elwimen

Elwimen commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

@Copilot review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Meshtastic’s configuration-application path so LoRa modem/radio parameter changes take effect immediately via the existing configChangedRadioInterface::reloadConfig()reconfigure() observer chain, avoiding unnecessary device reboots, and improves how custom modem settings are displayed in the debug UI.

Changes:

  • Avoid blanket reboot on LoRa config changes; reboot only for sx126x_rx_boosted_gain changes.
  • Reject LORA_24 region at runtime when the active radio hardware cannot do 2.4 GHz.
  • Improve debug display of custom modem settings while keeping DisplayFormatters’ “Custom” string stable for non-display callers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/modules/AdminModule.cpp Removes most LoRa-config reboots; adds runtime LORA_24 rejection logic.
src/graphics/draw/DebugRenderer.cpp Displays custom modem parameters (BW/SF/CR) instead of a generic “Custom”.
src/DisplayFormatters.cpp Documents that “Custom” must remain stable for non-display callers.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/modules/AdminModule.cpp Outdated
Comment thread src/modules/AdminModule.cpp Outdated
Comment thread src/graphics/draw/DebugRenderer.cpp Outdated
The configChanged observer already calls reconfigure() on all radio
interfaces when LoRa config is saved, which puts the radio in standby,
reprograms all modem parameters (SF, BW, CR, freq, power), and restarts
receive. The reboot was therefore redundant.

This commit:
- Removes the reboot trigger for LoRa config changes in AdminModule
- Rejects LORA_24 region at runtime with BAD_REQUEST if the active radio
  does not support 2.4 GHz, replacing the startup-only reboot-based check
- Moves the BW/SF/CR display formatting into DebugRenderer, keeping
  getModemPresetDisplayName() semantics stable for non-display callers
  (RadioInterface frequency slot hashing, Channels default-channel detection)

Portduino with SimRadio already skipped the reboot via the same reasoning.
@Elwimen
Elwimen force-pushed the fix/lora-no-reboot-on-config-change branch from 3fe8cee to d63bba3 Compare March 17, 2026 22:30
@Elwimen

Elwimen commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

@Copilot review

@thebentern
thebentern requested a review from Copilot March 18, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes unnecessary reboots when applying LoRa configuration changes by relying on the existing configChangedRadioInterface::reconfigure() live-reload path, while keeping a targeted reboot for the sx126x_rx_boosted_gain init-only setting. Also improves how custom modem settings are displayed, and adds runtime rejection for unsupported LORA_24 on non-2.4GHz-capable hardware.

Changes:

  • Apply most LoRa config changes live (reboot only for sx126x_rx_boosted_gain changes).
  • Reject LORA_24 at runtime when the active radio cannot do 2.4GHz.
  • Improve display of custom modem params without changing non-display callers’ stable "Custom" semantics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/modules/AdminModule.cpp Removes blanket reboot on LoRa changes; adds runtime LORA_24 hardware-capability validation.
src/graphics/draw/DebugRenderer.cpp Renders custom modem parameters (BW/SF/CR) directly for display.
src/DisplayFormatters.cpp Documents and preserves stable "Custom" return for non-preset mode.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/graphics/draw/DebugRenderer.cpp Outdated
Comment thread src/modules/AdminModule.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Elwimen

Elwimen commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

@Copilot

Addressed in latest commit:

  • DebugRenderer.cpp: %d%u with static_cast<unsigned> for bandwidth/SF/CR fields
  • AdminModule.cpp: LORA_24 check split into named bools (isLoraConfig, isRequestingLora24, isRadioCapableOfWideLora); now fails closed when RadioLibInterface::instance is null

@Elwimen
Elwimen force-pushed the fix/lora-no-reboot-on-config-change branch from e5cddad to 529ebcd Compare March 18, 2026 13:45
@thebentern
thebentern requested a review from Copilot March 18, 2026 15:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Meshtastic’s configuration flow so LoRa modem changes apply immediately (via the existing configChangedRadioInterface::reconfigure() path) instead of forcing a reboot, while preserving compatibility for the sx126x_rx_boosted_gain init-only setting. It also improves how “custom” modem settings are presented on-device without changing non-display semantics used elsewhere.

Changes:

  • Remove the blanket reboot after LoRa config updates; reboot only when sx126x_rx_boosted_gain changes.
  • Reject LORA_24 region changes at runtime on hardware that doesn’t support wide/2.4 GHz LoRa.
  • Improve debug display formatting for custom modem settings while keeping "Custom" stable for non-display callers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/modules/AdminModule.cpp Applies LoRa config changes live (no reboot) except boosted-gain; adds runtime LORA_24 capability validation.
src/graphics/draw/DebugRenderer.cpp Displays BW/SF/CR for non-preset configurations without altering shared formatter behavior.
src/DisplayFormatters.cpp Documents and preserves "Custom" as a stable literal for non-preset mode to avoid affecting non-display logic.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/modules/AdminModule.cpp Outdated
…heck

- DebugRenderer: use %u instead of %d for uint32_t bandwidth/SF/CR fields
- AdminModule: extract LORA_24 check into named bools for readability;
  fail closed when RadioLibInterface::instance is null
@Elwimen
Elwimen force-pushed the fix/lora-no-reboot-on-config-change branch from 529ebcd to c245412 Compare March 19, 2026 08:14
@Elwimen

Elwimen commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

@Copilot review

@Elwimen

Elwimen commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

@thebentern Is there anything else that needs to be done? Can we merge this thing?

@Elwimen

Elwimen commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of a consolidated PR that also includes live apply of sx126x_rx_boosted_gain changes and LORA_24 hardware validation.

@Elwimen Elwimen closed this Mar 20, 2026
@Elwimen
Elwimen deleted the fix/lora-no-reboot-on-config-change branch July 31, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs first-contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants