mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-02 02:08:25 +00:00
Merge pull request #13 from 446564/repeater-prefs
load radio settings from prefs for repeaters
This commit is contained in:
@@ -470,9 +470,39 @@ int main(void)
|
||||
self_identity.pub_key[4], self_identity.pub_key[5],
|
||||
self_identity.pub_key[6], self_identity.pub_key[7]);
|
||||
|
||||
/* Pre-load persisted prefs into radio_prefs BEFORE repeater_mesh.begin().
|
||||
*
|
||||
* Rationale: lora_radio was constructed at static-init time with a pointer
|
||||
* to radio_prefs (see line ~286). When repeater_mesh.begin() runs, it
|
||||
* calls Mesh::begin() -> Dispatcher::begin() -> _radio->begin(), which
|
||||
* reads freq/bw/sf/cr through that pointer to configure the hardware.
|
||||
*
|
||||
* Without this pre-load, the radio boots on the compile-time defaults
|
||||
* from initNodePrefs() (freq=869.618, EU ISM band) regardless of what the
|
||||
* user configured. RepeaterMesh::begin() then loads the persisted prefs
|
||||
* into its own _prefs member, so CLI/UI readback shows the correct saved
|
||||
* values — but the hardware is already configured on the stale defaults
|
||||
* and never gets reconfigured. The result: device appears operational on
|
||||
* the configured frequency but is physically tuned to 869.618 MHz, so
|
||||
* transmissions are not heard and no packets can be received.
|
||||
*
|
||||
* This went unnoticed in the EU because 869.618 happens to match the
|
||||
* default; US/CA users on 910.525 (and any other non-default freq) hit it.
|
||||
*
|
||||
* Mirrors the temp_prefs pattern in main_companion.cpp. The subsequent
|
||||
* setPrefs() rebind (after begin()) points the radio at the live prefs in
|
||||
* RepeaterMesh so CLI `set radio` changes take effect on reconfigure(). */
|
||||
data_store.loadPrefs(radio_prefs);
|
||||
|
||||
/* Start mesh with data store - this loads prefs, ACL, regions */
|
||||
repeater_mesh.begin(&data_store);
|
||||
|
||||
/* Rebind radio prefs pointer to the live prefs inside repeater_mesh.
|
||||
* radio_prefs above was a one-time copy for static init; from here on,
|
||||
* the radio must read from the same struct RepeaterMesh mutates so that
|
||||
* CLI-driven reconfigure() calls see current values. */
|
||||
lora_radio.setPrefs(repeater_mesh.getNodePrefs());
|
||||
|
||||
/* Generate default node name from hardware device ID if not set */
|
||||
NodePrefs* prefs = repeater_mesh.getNodePrefs();
|
||||
if (strlen(prefs->node_name) == 0 || strcmp(prefs->node_name, "Repeater") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user