fix: push_radio_channel uses 'wifi' (full restart) instead of 'wifi reload'
'wifi reload' only reapplies the running config without physically changing the channel on many ath9k/ath10k/mt76 hardware+driver combinations. A full 'wifi' (down + up) cycle is required for channel changes to take effect. Also updated the test assertion accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
512871b1bb
commit
4c41345489
@@ -528,7 +528,12 @@ class OpenWrtWirelessMixin:
|
|||||||
return entries
|
return entries
|
||||||
|
|
||||||
def push_radio_channel(self, radio: str, channel: int) -> None:
|
def push_radio_channel(self, radio: str, channel: int) -> None:
|
||||||
"""Set a new channel on *radio* via UCI and reload the wireless stack.
|
"""Set a new channel on *radio* via UCI and restart the wireless stack.
|
||||||
|
|
||||||
|
Uses ``wifi`` (full down/up cycle) rather than ``wifi reload``.
|
||||||
|
``wifi reload`` only re-applies the running config without changing
|
||||||
|
the physical channel on many hardware/driver combinations; a full
|
||||||
|
restart is required for channel changes to take effect.
|
||||||
|
|
||||||
:param radio: UCI radio name, e.g. ``"radio0"``.
|
:param radio: UCI radio name, e.g. ``"radio0"``.
|
||||||
:param channel: Channel number to set; ``0`` sets UCI ``auto``.
|
:param channel: Channel number to set; ``0`` sets UCI ``auto``.
|
||||||
@@ -536,7 +541,7 @@ class OpenWrtWirelessMixin:
|
|||||||
ch_val = "auto" if channel == 0 else str(channel)
|
ch_val = "auto" if channel == 0 else str(channel)
|
||||||
self._send_command(f"uci set wireless.{radio}.channel={ch_val}")
|
self._send_command(f"uci set wireless.{radio}.channel={ch_val}")
|
||||||
self._send_command("uci commit wireless")
|
self._send_command("uci commit wireless")
|
||||||
self._send_command("wifi reload")
|
self._send_command("wifi")
|
||||||
|
|
||||||
def get_radio_status(self) -> dict[str, Any]:
|
def get_radio_status(self) -> dict[str, Any]:
|
||||||
"""Return radio status from UCI and iwinfo.
|
"""Return radio status from UCI and iwinfo.
|
||||||
|
|||||||
@@ -1076,11 +1076,13 @@ class TestPushRadioChannel:
|
|||||||
driver.push_radio_channel("radio0", 11)
|
driver.push_radio_channel("radio0", 11)
|
||||||
assert any("uci commit wireless" in c for c in issued)
|
assert any("uci commit wireless" in c for c in issued)
|
||||||
|
|
||||||
def test_issues_wifi_reload(self, driver):
|
def test_issues_wifi_restart(self, driver):
|
||||||
|
"""Must call 'wifi' (full restart) — NOT just 'wifi reload'."""
|
||||||
issued: list[str] = []
|
issued: list[str] = []
|
||||||
driver._send_command = lambda cmd, **kw: issued.append(cmd) or ""
|
driver._send_command = lambda cmd, **kw: issued.append(cmd) or ""
|
||||||
driver.push_radio_channel("radio1", 36)
|
driver.push_radio_channel("radio1", 36)
|
||||||
assert any("wifi reload" in c for c in issued)
|
# 'wifi' alone is a full restart; 'wifi reload' is insufficient for channel changes
|
||||||
|
assert any(c.strip() == "wifi" for c in issued)
|
||||||
|
|
||||||
def test_auto_channel_zero(self, driver):
|
def test_auto_channel_zero(self, driver):
|
||||||
"""channel=0 should set 'auto' in UCI."""
|
"""channel=0 should set 'auto' in UCI."""
|
||||||
@@ -1089,11 +1091,11 @@ class TestPushRadioChannel:
|
|||||||
driver.push_radio_channel("radio0", 0)
|
driver.push_radio_channel("radio0", 0)
|
||||||
assert any("channel=auto" in c or "channel='auto'" in c for c in issued)
|
assert any("channel=auto" in c or "channel='auto'" in c for c in issued)
|
||||||
|
|
||||||
def test_commit_before_reload(self, driver):
|
def test_commit_before_restart(self, driver):
|
||||||
"""UCI commit must happen before wifi reload."""
|
"""UCI commit must happen before wifi restart."""
|
||||||
issued: list[str] = []
|
issued: list[str] = []
|
||||||
driver._send_command = lambda cmd, **kw: issued.append(cmd) or ""
|
driver._send_command = lambda cmd, **kw: issued.append(cmd) or ""
|
||||||
driver.push_radio_channel("radio0", 6)
|
driver.push_radio_channel("radio0", 6)
|
||||||
commit_idx = next(i for i, c in enumerate(issued) if "commit" in c)
|
commit_idx = next(i for i, c in enumerate(issued) if "commit" in c)
|
||||||
reload_idx = next(i for i, c in enumerate(issued) if "wifi reload" in c)
|
wifi_idx = next(i for i, c in enumerate(issued) if c.strip() == "wifi")
|
||||||
assert commit_idx < reload_idx
|
assert commit_idx < wifi_idx
|
||||||
|
|||||||
Reference in New Issue
Block a user