mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-29 16:28:11 +00:00
feat(repeater): default network profile, band-matched to companion freq
Enabling the repeater now defaults to a dedicated radio profile rather than relaying on the companion's current frequency: same-network repeating isn't the MeshCore community norm. The default profile is seeded with a frequency in the same legal band as the companion's own network (433/868/915 MHz, via defaultRepeaterFreqForBand()) rather than a flat firmware constant, so it can't land outside what's allowed for the operator's region. Also fixes a gap where a true first boot (no prefs file yet) never hit the DataStore.cpp migration fallback and stayed on repeater_use_profile=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -356,16 +356,23 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
|
||||
rd(&_prefs.repeater_bw, sizeof(_prefs.repeater_bw));
|
||||
rd(&_prefs.repeater_sf, sizeof(_prefs.repeater_sf));
|
||||
rd(&_prefs.repeater_cr, sizeof(_prefs.repeater_cr));
|
||||
// Pre-0x10 files leave stray sentinel bytes here. If the profile fields aren't a
|
||||
// valid radio config, force the profile off so the repeater can't switch to junk.
|
||||
// Pre-0x10 files leave stray sentinel bytes here, same as a never-configured
|
||||
// device. Either way there's no valid saved profile, so default to a profile
|
||||
// in the same band as the companion's own network (_prefs.freq, already read
|
||||
// above) rather than "Current" — a repeater silently following the companion
|
||||
// onto whatever private network it later joins isn't the MeshCore community
|
||||
// norm; that stays opt-in. Band-matched rather than a flat frequency so the
|
||||
// default can't land outside what's legal where the companion is set up.
|
||||
if (_prefs.repeater_use_profile > 1) _prefs.repeater_use_profile = 0;
|
||||
if (!(_prefs.repeater_freq >= 100.0f && _prefs.repeater_freq <= 960.0f
|
||||
&& _prefs.repeater_sf >= 5 && _prefs.repeater_sf <= 12
|
||||
&& _prefs.repeater_cr >= 5 && _prefs.repeater_cr <= 8
|
||||
&& _prefs.repeater_bw >= 7.0f && _prefs.repeater_bw <= 510.0f)) {
|
||||
_prefs.repeater_use_profile = 0;
|
||||
_prefs.repeater_freq = _prefs.repeater_bw = 0.0f;
|
||||
_prefs.repeater_sf = _prefs.repeater_cr = 0;
|
||||
_prefs.repeater_use_profile = 1;
|
||||
_prefs.repeater_freq = defaultRepeaterFreqForBand(_prefs.freq);
|
||||
_prefs.repeater_bw = LORA_BW;
|
||||
_prefs.repeater_sf = LORA_SF;
|
||||
_prefs.repeater_cr = LORA_CR;
|
||||
}
|
||||
// → 0xC0DE000B: append bot_commands_enabled + quiet-hours. Older files leave
|
||||
// stray bytes here; clamp so upgraders fall back to off / no quiet hours.
|
||||
|
||||
Reference in New Issue
Block a user