mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-06 17:03:32 +02:00
fix(cli): point the flood advert interval at the engine timer key
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user