Update US LoRa modem preset to region defaults for compliance

This commit is contained in:
Ben Meadors
2026-06-14 18:47:20 -05:00
parent 8a0c7592cc
commit 3f9cd2e4e0
4 changed files with 35 additions and 3 deletions

View File

@@ -82,7 +82,7 @@ void Channels::initDefaultLoraConfig()
{
meshtastic_Config_LoRaConfig &loraConfig = config.lora;
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
loraConfig.modem_preset = getRegion(loraConfig.region)->getDefaultPreset(); // region default (US: LONG_TURBO for FCC)
loraConfig.use_preset = true;
loraConfig.tx_power = 0; // default
loraConfig.channel_num = 0;

View File

@@ -834,7 +834,10 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
#ifdef USERPREFS_LORACONFIG_MODEM_PRESET
config.lora.modem_preset = USERPREFS_LORACONFIG_MODEM_PRESET;
#else
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
// Default to the region's own default preset (US is LONG_TURBO for FCC §15.247; every other region
// is LONG_FAST). region is set just above, so a region-locked board is born on the compliant default
// without any runtime "upgrade" step.
config.lora.modem_preset = getRegion(config.lora.region)->getDefaultPreset();
#endif
#ifdef USERPREFS_LORACONFIG_USE_PRESET
config.lora.use_preset = USERPREFS_LORACONFIG_USE_PRESET;

View File

@@ -77,7 +77,12 @@ const RegionInfo regions[] = {
https://link.springer.com/content/pdf/bbm%3A978-1-4842-4357-2%2F1.pdf
https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/
*/
RDEF(US, 902.0f, 928.0f, 100, 30, false, false, PROFILE_STD, PRESET(LONG_FAST), 0),
// FCC §15.247 requires >=500 kHz of 6 dB bandwidth for digital (non-frequency-hopping)
// modulation in the 902-928 MHz band, so the US region's default preset is LONG_TURBO (500 kHz)
// rather than the 250 kHz LONG_FAST. A fresh US board adopts this as its factory default via
// getDefaultPreset() (see installDefaultConfig); LONG_FAST and the other presets stay available
// for users who opt in.
RDEF(US, 902.0f, 928.0f, 100, 30, false, false, PROFILE_STD, PRESET(LONG_TURBO), 0),
/*
EN300220 ETSI V3.2.1 [Table B.1, Item H, p. 21]

View File

@@ -1112,6 +1112,26 @@ void tearDown(void)
testAdmin = nullptr;
}
// -----------------------------------------------------------------------
// US region factory default preset (LONG_TURBO for FCC §15.247). A fresh board adopts its region's
// default via getDefaultPreset() in installDefaultConfig() — there is no runtime "upgrade" path.
// -----------------------------------------------------------------------
static void test_usRegionDefaultPresetIsLongTurbo()
{
// FCC §15.247: the US region's default preset is the 500 kHz LONG_TURBO, so a fresh US board is
// born compliant.
TEST_ASSERT_EQUAL(meshtastic_Config_LoRaConfig_ModemPreset_LONG_TURBO,
getRegion(meshtastic_Config_LoRaConfig_RegionCode_US)->getDefaultPreset());
}
static void test_nonUsRegionDefaultPresetUnchanged()
{
// Only US changed: every other region still defaults to LONG_FAST.
TEST_ASSERT_EQUAL(meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST,
getRegion(meshtastic_Config_LoRaConfig_RegionCode_EU_868)->getDefaultPreset());
}
void setup()
{
delay(10);
@@ -1180,6 +1200,10 @@ void setup()
RUN_TEST(test_regionFieldsAreSane);
RUN_TEST(test_onlyLORA24HasWideLora);
// US region factory default preset
RUN_TEST(test_usRegionDefaultPresetIsLongTurbo);
RUN_TEST(test_nonUsRegionDefaultPresetUnchanged);
// OVERRIDE_SLOT_PRESET_HASH (-1) slot formula tests
RUN_TEST(test_overrideSlotPresetHash_longFast_customChannelMatchesDefaultNameSlot);
RUN_TEST(test_overrideSlotPresetHash_mediumFast_customChannelMatchesDefaultNameSlot);