Skip to content

Lora region preset map#10736

Merged
thebentern merged 4 commits into
developfrom
lora-region-preset-map
Jun 20, 2026
Merged

Lora region preset map#10736
thebentern merged 4 commits into
developfrom
lora-region-preset-map

Conversation

@thebentern

Copy link
Copy Markdown
Contributor

This pull request introduces a new feature that allows the firmware to communicate the legal combinations of LoRa regions and modem presets to clients during the configuration handshake. This enables client UIs to prevent users from selecting illegal region+preset combinations, improving user experience and regulatory compliance. The implementation includes protocol extensions, firmware-side logic to generate the compatibility map, integration into the configuration handshake, and comprehensive unit tests.

LoRa Region–Preset Compatibility Feature

Protocol and API Additions:

  • Added a new region_presets field (field 19) to the FromRadio message in the protobufs, along with supporting messages (LoRaRegionPresetMap, LoRaPresetGroup, and LoRaRegionPresets) to describe legal region→preset groupings. This enables efficient transmission of compatibility data to clients. [1] [2]

Firmware Implementation:

  • Implemented the getRegionPresetMap() function in MeshRadio.h/RadioInterface.cpp to generate the grouped region→preset compatibility map, coalescing regions that share identical preset lists and licensing requirements. [1] [2]
  • Integrated the new compatibility map into the configuration handshake in PhoneAPI.cpp, sending it to clients after metadata and before channel configuration. This ensures clients receive the map as part of the standard config flow. [1] [2] [3] [4]

Testing and Validation:

  • Added unit tests in test_radio/test_main.cpp to verify that all known regions are covered, the map stays within protocol bounds, and the advertised presets and licensing flags match the firmware's region table.

Documentation:

  • Added a comprehensive client implementation specification (docs/lora_region_preset_compatibility_client_spec.md) detailing the protocol changes, client handling rules, decoding logic, UI/UX recommendations, and platform-specific notes for Android, Apple, Python, and web clients.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (24)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-07-17. Updated for a84a3a9.

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 adds a new “LoRa region ↔ modem preset compatibility map” to the config handshake so clients can prevent users from choosing illegal region+preset combinations (and can surface “licensed-only” bands), improving UX and regulatory compliance.

Changes:

  • Extends the protobuf/API with FromRadio.region_presets (field 19) and supporting messages to efficiently encode region→preset-group constraints.
  • Implements getRegionPresetMap() to generate a grouped region→preset map from the firmware region table and sends it during want_config (after metadata, before channels).
  • Adds unit tests validating coverage and correctness of the advertised map against the live region table.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test_radio/test_main.cpp Adds tests for getRegionPresetMap() coverage, bounds, and consistency with the region table.
src/mesh/RadioInterface.cpp Implements getRegionPresetMap() by coalescing regions into preset groups.
src/mesh/PhoneAPI.h Adds a new handshake state STATE_SEND_REGION_PRESETS.
src/mesh/PhoneAPI.cpp Sends FromRadio.region_presets during the config handshake after metadata.
src/mesh/MeshRadio.h Declares getRegionPresetMap() for use by PhoneAPI and tests.
src/mesh/generated/meshtastic/mesh.pb.h Adds generated structs/fields for the new protobuf messages and FromRadio oneof variant.
src/mesh/generated/meshtastic/mesh.pb.cpp Registers/binds the new protobuf message descriptors.
docs/lora_region_preset_compatibility_client_spec.md Adds client-facing spec describing delivery timing and decoding/UX rules.

Comment thread test/test_radio/test_main.cpp Outdated
Comment thread test/test_radio/test_main.cpp Outdated
Comment thread src/mesh/RadioInterface.cpp
Comment thread src/mesh/RadioInterface.cpp Outdated
Comment thread src/mesh/PhoneAPI.cpp Outdated
@github-actions github-actions Bot added the enhancement New feature or request label Jun 17, 2026
- Log (and break/skip) when the region preset map exceeds its array bounds
  instead of silently dropping regions
- Derive test bounds from the generated nanopb array sizes via sizeof()
  instead of hard-coded magic numbers
- Fix want_config sequence comment (missing comma, STATE_SEND_MODULECONFIG)
- Specify a language on the spec's fenced code blocks (markdownlint MD040)
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Firmware Size Report

22 targets | vs develop: 22 increased, net +13,776 (+13.5 KB)

Target Size vs develop
tlora-c6 2,343,344 📈 +864
heltec-ht62-esp32c3-sx1262 2,109,744 📈 +832
rak11200 1,834,272 📈 +704
t-eth-elite 2,464,000 📈 +672
elecrow-adv-35-tft 3,390,096 📈 +656
Show 17 more target(s)
Target Size vs develop
heltec-v4 2,257,904 📈 +656
station-g3 2,239,248 📈 +656
t-deck-tft 3,784,112 📈 +656
heltec-v3 2,237,424 📈 +640
heltec-vision-master-e213-inkhud 2,197,568 📈 +640
rak3312 2,244,400 📈 +640
seeed-xiao-s3 2,248,400 📈 +640
pico2w 1,198,284 📈 +624
station-g2 2,248,816 📈 +624
pico2 749,376 📈 +608
picow 1,221,780 📈 +608
seeed_xiao_rp2350 747,544 📈 +608
pico 761,480 📈 +592
rak11310 784,104 📈 +592
seeed_xiao_rp2040 759,680 📈 +576
rak3172 180,960 📈 +368
wio-e5 233,332 📈 +320

Updated for 73ec1bc

…available()

available() had a separate per-state switch that wasn't updated for the new
state, so it returned false ('unexpected state 5') and getFromRadio() was
never called - the config handshake stalled after metadata and the client
timed out. Verified via the native simulator integration test.
@thebentern thebentern merged commit dd1ec9d into develop Jun 20, 2026
88 checks passed
@thebentern thebentern deleted the lora-region-preset-map branch June 20, 2026 11:42
raghumad pushed a commit to raghumad/mezulla-firmware that referenced this pull request Jun 25, 2026
* Added lora region and preset maps

* Protos

* Address PR review feedback

- Log (and break/skip) when the region preset map exceeds its array bounds
  instead of silently dropping regions
- Derive test bounds from the generated nanopb array sizes via sizeof()
  instead of hard-coded magic numbers
- Fix want_config sequence comment (missing comma, STATE_SEND_MODULECONFIG)
- Specify a language on the spec's fenced code blocks (markdownlint MD040)

* Fix want_config stall: handle STATE_SEND_REGION_PRESETS in PhoneAPI::available()

available() had a separate per-state switch that wasn't updated for the new
state, so it returned false ('unexpected state 5') and getFromRadio() was
never called - the config handshake stalled after metadata and the client
timed out. Verified via the native simulator integration test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants