properly reset CAD offset when needed

This commit is contained in:
liquidraver
2026-09-10 21:56:52 +02:00
parent ce6e71067d
commit 69cc148fbe
12 changed files with 249 additions and 44 deletions
+18 -5
View File
@@ -673,11 +673,6 @@ static uint16_t get_battery_mv(void)
return zephyr_board.getBattMilliVolts();
}
static void radio_reconfigure(void)
{
lora_radio.reconfigure();
}
static mesh::ZephyrMillisecondClock ms_clock;
static mesh::ZephyrRNG zephyr_rng;
static mesh::SimpleMeshTables mesh_tables;
@@ -886,6 +881,24 @@ static ClientACL companion_acl; /* unused by CommonCLI but required by construc
static CommonCLI companion_cli(zephyr_board, rtc_clock, companion_acl,
&companion_mesh.prefs, &companion_cli_cbs);
/* Radio reconfigure, reached from the app protocol (CMD_SET_RADIO_PARAMS /
* CMD_SET_RADIO_TX_POWER). Defined here rather than up with the other radio
* callbacks because it needs companion_cli, which needs the mesh and the
* datastore — same reason save_prefs_to_flash() sits below them.
*
* Unlike the CLI's `set radio`, this path applies LIVE: there is no reboot and
* no frozen old preset, so by the time the CAD reset runs the radio is already
* on the new one and the base it stamps is the right one to keep — hence
* preset_pending = false. */
static void radio_reconfigure(bool preset_changed)
{
lora_radio.reconfigure();
if (preset_changed) {
companion_cli.resetCadState(false);
}
}
#if defined(CONFIG_ZEPHCORE_AUTO_SHUTDOWN_MILLIVOLTS) && \
CONFIG_ZEPHCORE_AUTO_SHUTDOWN_MILLIVOLTS > 0
#define ZEPHCORE_HAS_AUTO_SHUTDOWN 1