From 6db8ac97f59e3baf5227c86a1ebb247a688227df Mon Sep 17 00:00:00 2001 From: agessaman Date: Sun, 19 Jul 2026 07:10:37 -0700 Subject: [PATCH] fix(cli): point the flood advert interval at the engine timer key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit set flood.advert.interval wrote flood_advert_interval_hours, a key nothing reads, and get reported it with a default of 24 — the engine's flood-advert timer (and the web API) consume send_advert_interval_hours with a default of 10. Read and write the consumed key so the remote command actually reschedules the timer; the orphan key is left in place and ignored. --- repeater/handler_helpers/mesh_cli.py | 6 ++++-- tests/test_handler_helpers_mesh_cli.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/repeater/handler_helpers/mesh_cli.py b/repeater/handler_helpers/mesh_cli.py index 5d289d2..f01bd32 100644 --- a/repeater/handler_helpers/mesh_cli.py +++ b/repeater/handler_helpers/mesh_cli.py @@ -571,7 +571,8 @@ class MeshCLI: return f"> {interval}" elif param == "flood.advert.interval": - interval = self.repeater_config.get("flood_advert_interval_hours", 24) + # The engine's flood-advert timer consumes send_advert_interval_hours. + interval = self.repeater_config.get("send_advert_interval_hours", 10) return f"> {interval}" elif param == "flood.max": @@ -736,7 +737,8 @@ class MeshCLI: hours = int(value) if (hours > 0 and hours < 3) or hours > 168: return "Error: interval range is 3-168 hours" - self.repeater_config["flood_advert_interval_hours"] = hours + # The engine's flood-advert timer consumes send_advert_interval_hours. + self.repeater_config["send_advert_interval_hours"] = hours if not self._save_config_and_apply(["repeater"]): return "Error: Failed to save config" return "OK" diff --git a/tests/test_handler_helpers_mesh_cli.py b/tests/test_handler_helpers_mesh_cli.py index 881a816..9970af1 100644 --- a/tests/test_handler_helpers_mesh_cli.py +++ b/tests/test_handler_helpers_mesh_cli.py @@ -15,6 +15,7 @@ def _base_config(): "longitude": 3.4, "airtime_factor": 1.1, "advert_interval_minutes": 120, + # Stale orphan key from the old CLI; nothing must read it. "flood_advert_interval_hours": 24, "max_flood_hops": 20, "rx_delay_base": 0.2, @@ -221,6 +222,10 @@ def test_cmd_set_updates_and_validation_errors(): assert cli._cmd_set("advert.interval 59").startswith("Error: interval range") assert cli._cmd_set("flood.advert.interval 2").startswith("Error: interval range") + assert cli._cmd_set("flood.advert.interval 12") == "OK" + # The engine's timer key is updated; the stale orphan key is left alone. + assert cfg["repeater"]["send_advert_interval_hours"] == 12 + assert cfg["repeater"]["flood_advert_interval_hours"] == 24 assert cli._cmd_set("flood.max 100") == "Error: max 64" assert cli._cmd_set("rxdelay -1") == "Error: cannot be negative" assert cli._cmd_set("txdelay -1") == "Error: cannot be negative" @@ -528,3 +533,15 @@ def test_cmd_set_radio_commands_stage_without_live_apply(): assert mgr.save_to_file.call_count == 3 mgr.live_update_daemon.assert_not_called() + + +def test_cmd_get_flood_advert_interval_reads_engine_key(): + cfg = _base_config() + cli = MeshCLI("/tmp/cfg.yaml", cfg, _cfg_mgr()) + + # The orphan flood_advert_interval_hours (24) must be ignored; the engine + # key is absent so the engine default (10) is reported. + assert cli._cmd_get("flood.advert.interval") == "> 10" + + cfg["repeater"]["send_advert_interval_hours"] = 6 + assert cli._cmd_get("flood.advert.interval") == "> 6"