Skip to content

Commit

Permalink
Add configuration option for LoRa Region Code override for region-loc…
Browse files Browse the repository at this point in the history
…ked builds/variants (meshtastic#3540)

The main use case for this will be to create a custom Heltec WiFi LoRa 32 V3 SG_923 variant, which will be pre-flashed and sent for regulatory approval for retail sale.

Signed-off-by: Andrew Yong <[email protected]>
Co-authored-by: Ben Meadors <[email protected]>
  • Loading branch information
ndoo and thebentern authored Apr 16, 2024
1 parent e813703 commit 9599549
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RTC_DATA_ATTR
#endif

// -----------------------------------------------------------------------------
// Regulatory overrides for producing regional builds
// -----------------------------------------------------------------------------

// Define if region should override user saved region
// #define LORA_REGIONCODE meshtastic_Config_LoRaConfig_RegionCode_SG_923

// -----------------------------------------------------------------------------
// Feature toggles
// -----------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion src/mesh/RadioInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,16 @@ static uint8_t bytes[MAX_RHPACKETLEN];
void initRegion()
{
const RegionInfo *r = regions;
#ifdef LORA_REGIONCODE
for (; r->code != meshtastic_Config_LoRaConfig_RegionCode_UNSET && r->code != LORA_REGIONCODE; r++)
;
LOG_INFO("Wanted region %d, regulatory override to %s\n", config.lora.region, r->name);
#else
for (; r->code != meshtastic_Config_LoRaConfig_RegionCode_UNSET && r->code != config.lora.region; r++)
;
myRegion = r;
LOG_INFO("Wanted region %d, using %s\n", config.lora.region, r->name);
#endif
myRegion = r;
}

/**
Expand Down

0 comments on commit 9599549

Please sign in to comment.