diff --git a/payload/user/remote_access/pager-webui/server.py b/payload/user/remote_access/pager-webui/server.py index a4978f4..6339ba8 100644 --- a/payload/user/remote_access/pager-webui/server.py +++ b/payload/user/remote_access/pager-webui/server.py @@ -1817,8 +1817,14 @@ def h_pineap_wifi_set_ap(ctx): open_band = channel_band(openap.get('channel')) if openap.get('channel') is not None else None use_radio1 = wpa_band in (BAND_5G, BAND_6G) or open_band in (BAND_5G, BAND_6G) if use_radio1: - wpa_active = bool(wpa.get('enabled', True)) and wpa.get('channel') is not None - open_active = bool(openap.get('enabled', True)) and openap.get('channel') is not None + wpa_active = (wpa_band in (BAND_5G, BAND_6G) and bool(wpa.get('enabled', True)) + and wpa.get('channel') is not None) + open_active = (open_band in (BAND_5G, BAND_6G) and bool(openap.get('enabled', True)) + and openap.get('channel') is not None) + wpa_present = bool(wpa.get('ssid') or wpa.get('enabled') is not None) + open_present = bool(openap.get('ssid') or openap.get('enabled') is not None) + if (wpa_present and wpa_band == BAND_2G) or (open_present and open_band == BAND_2G): + return 400, {'error': 'cannot configure 2.4GHz and radio1 APs in one request'} if not (wpa_active or open_active): _remove_radio1_ap() device_run(['wifi', 'reload']) diff --git a/tests/test_pineap_bands.py b/tests/test_pineap_bands.py index fb8b356..f9d24f0 100644 --- a/tests/test_pineap_bands.py +++ b/tests/test_pineap_bands.py @@ -249,6 +249,15 @@ class SetApRadio1Test(unittest.TestCase): self.assertEqual(self.uci['pineapd.wlan1mon.hop'], '1') self.assertEqual(self.uci.get('wireless.radio1.channel'), 'auto') + def test_mixed_24g_and_radio1_rejected(self): + status, payload = server.h_pineap_wifi_set_ap(ctx({ + 'open': {'ssid': 'CorpGuest', 'hidden': False, 'enabled': True, + 'channel': 36, 'country': 'US'}, + 'wpa': {'ssid': 'Office', 'passphrase': 'secret123', 'enctype': 'psk2', + 'hidden': False, 'enabled': True, 'channel': 6}})) + self.assertEqual(status, 400) + self.assertIn('2.4GHz', payload['error']) + class GetApRadioChannelFallbackTest(unittest.TestCase): """Regression: iface without a channel option inherits the radio channel."""