Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fe1f5d9
Enhance LoRa configuration with modem presets and validation logic
NomDeTom Mar 6, 2026
3ff2c3b
Rename bootstrapLoRaConfigFromPreset tests to validateModemConfig for…
NomDeTom Mar 6, 2026
9f1a824
Merge branch 'meshtastic:develop' into radio_interface_cherrypick
NomDeTom Mar 6, 2026
feb5172
additional tidy-ups to the validateModemConfig - still fundamentally …
NomDeTom Mar 7, 2026
e71e6a9
Enhance region validation by adding numPresets to RegionInfo and impl…
NomDeTom Mar 8, 2026
36a8215
Add validation for modem configuration in applyModemConfig
NomDeTom Mar 8, 2026
0254105
Fix region unset handling and improve modem config validation in hand…
NomDeTom Mar 8, 2026
5259494
Refactor LoRa configuration validation methods and introduce clamping…
NomDeTom Mar 9, 2026
cf9712e
Update handleSetConfig to use fromOthers parameter to either correct …
NomDeTom Mar 10, 2026
eb240d7
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 10, 2026
237ac2c
Fix some of the copilot review comments for LoRa configuration valida…
NomDeTom Mar 10, 2026
0ada155
Redid the slot default checking and calculation. Should resolve the o…
NomDeTom Mar 11, 2026
4a5da3e
Add bandwidth calculation for LoRa modem preset fallback in clampConf…
NomDeTom Mar 11, 2026
ef72c40
Remove unused preset name variable in validateConfigLora and fix defa…
NomDeTom Mar 11, 2026
2e84995
update tests for region handling
NomDeTom Mar 11, 2026
251b64f
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 11, 2026
b6d55af
Got the synthetic colleague to add mock service for testing
NomDeTom Mar 11, 2026
c73b592
Flash savings... hopefully
NomDeTom Mar 12, 2026
ca28017
Refactor modem preset handling to use sentinel values and improve def…
NomDeTom Mar 12, 2026
3c3ddde
Refactor region handling to use profile structures for modem presets …
NomDeTom Mar 12, 2026
d768507
added comments for clarity on parameters
NomDeTom Mar 12, 2026
a9bc5ce
Add shadow table tests and validateConfigLora enhancements for region…
NomDeTom Mar 14, 2026
e14a6a5
Merge branch 'meshtastic:develop' into radio_interface_cherrypick
NomDeTom Mar 14, 2026
e475562
Add isFromUs tests for preset validation in AdminModule
NomDeTom Mar 14, 2026
d554c82
Merge branch 'meshtastic:develop' into radio_interface_cherrypick
NomDeTom Mar 15, 2026
e3d5b49
Respond to copilot github review
NomDeTom Mar 18, 2026
4c28a6b
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 18, 2026
b4ca217
address copilot comments
NomDeTom Mar 18, 2026
f9ea6be
address null poointers
NomDeTom Mar 18, 2026
f5e959d
fix build errors
NomDeTom Mar 18, 2026
b471666
Fix the fix, undo the silly suggestions from synthetic reviewer.
NomDeTom Mar 18, 2026
eca8218
we all float here
NomDeTom Mar 18, 2026
dbedf27
Fix include path for AdminModule in test_main.cpp
NomDeTom Mar 18, 2026
c31c904
Potential fix for pull request finding
NomDeTom Mar 19, 2026
dfc38fc
More suggestion fixes
NomDeTom Mar 19, 2026
ca74713
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 19, 2026
1d9d6bb
admin module merge conflicts
NomDeTom Mar 19, 2026
78d8802
admin module fixes from merge hell
NomDeTom Mar 19, 2026
d060e0d
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 19, 2026
107191b
fix: initialize default frequency slot and custom channel name; updat…
NomDeTom Mar 20, 2026
f1a56bc
save some bytes...
NomDeTom Mar 20, 2026
7ef568b
Merge branch 'develop' into radio_interface_cherrypick
NomDeTom Mar 20, 2026
2ee48b7
fix: simplify error logging for bandwidth checks in LoRa configuration
NomDeTom Mar 20, 2026
3cba534
Update src/mesh/MeshRadio.h
NomDeTom Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion protobufs
14 changes: 13 additions & 1 deletion src/graphics/draw/MenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "modules/TraceRouteModule.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <utility>

Expand Down Expand Up @@ -265,13 +266,24 @@ void menuHandler::FrequencySlotPicker()
optionsEnumArray[options++] = 0;

// Calculate number of channels (copied from RadioInterface::applyModemConfig())

meshtastic_Config_LoRaConfig &loraConfig = config.lora;
double bw = loraConfig.use_preset ? modemPresetToBwKHz(loraConfig.modem_preset, myRegion->wideLora)
: bwCodeToKHz(loraConfig.bandwidth);

uint32_t numChannels = 0;
if (myRegion) {
numChannels = (uint32_t)floor((myRegion->freqEnd - myRegion->freqStart) / (myRegion->spacing + (bw / 1000.0)));
// Match RadioInterface::applyModemConfig(): include padding, add spacing in numerator, and use round()
const double spacing = myRegion->profile->spacing;
const double padding = myRegion->profile->padding;
const double channelBandwidthMHz = bw / 1000.0;
const double numerator = (myRegion->freqEnd - myRegion->freqStart) + spacing;
const double denominator = spacing + (padding * 2) + channelBandwidthMHz;
if (denominator > 0.0) {
numChannels = static_cast<uint32_t>(round(numerator / denominator));
} else {
LOG_WARN("Invalid region configuration: non-positive channel spacing/width");
}
} else {
LOG_WARN("Region not set, cannot calculate number of channels");
return;
Expand Down
39 changes: 36 additions & 3 deletions src/mesh/MeshRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,51 @@
#include "PointerQueue.h"
#include "configuration.h"

// Sentinel marking the end of a modem preset array
#define MODEM_PRESET_END ((meshtastic_Config_LoRaConfig_ModemPreset)0xFF)

// Region profile: bundles the preset list with regulatory parameters shared across regions
struct RegionProfile {
const meshtastic_Config_LoRaConfig_ModemPreset *presets; // sentinel-terminated; first entry is the default
float spacing; // gaps between radio channels
float padding; // padding at each side of the "operating channel"
bool audioPermitted;
bool licensedOnly; // a region profile for licensed operators only
int8_t textThrottle; // throttle for text - future expansion
int8_t positionThrottle; // throttle for location data - future expansion
int8_t telemetryThrottle; // throttle for telemetry - future expansion
uint8_t overrideSlot; // a per-region override slot for if we need to fix it in place
};

extern const RegionProfile PROFILE_STD;
extern const RegionProfile PROFILE_EU868;
extern const RegionProfile PROFILE_UNDEF;
// extern const RegionProfile PROFILE_LITE;
// extern const RegionProfile PROFILE_NARROW;
// extern const RegionProfile PROFILE_HAM;

// Map from old region names to new region enums
struct RegionInfo {
meshtastic_Config_LoRaConfig_RegionCode code;
float freqStart;
float freqEnd;
float dutyCycle;
float spacing;
float dutyCycle; // modified by getEffectiveDutyCycle
uint8_t powerLimit; // Or zero for not set
bool audioPermitted;
bool freqSwitching;
bool wideLora;
const RegionProfile *profile;
const char *name; // EU433 etc

// Preset accessors (delegate through profile)
meshtastic_Config_LoRaConfig_ModemPreset getDefaultPreset() const { return profile->presets[0]; }
const meshtastic_Config_LoRaConfig_ModemPreset *getAvailablePresets() const { return profile->presets; }
size_t getNumPresets() const
{
size_t n = 0;
while (profile->presets[n] != MODEM_PRESET_END)
n++;
return n;
}
};

extern const RegionInfo regions[];
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ void NodeDB::loadFromDisk()
// Coerce LoRa config fields derived from presets while bootstrapping.
// Some clients/UI components display bandwidth/spread_factor directly from config even in preset mode.
if (config.has_lora && config.lora.use_preset) {
RadioInterface::bootstrapLoRaConfigFromPreset(config.lora);
RadioInterface::clampConfigLora(config.lora);
}

#if defined(USERPREFS_LORA_TX_DISABLED) && USERPREFS_LORA_TX_DISABLED
Expand Down
Loading
Loading