feat: channel/band mapping helpers for radio1 AP

This commit is contained in:
2026-08-17 23:01:16 -05:00
parent 5f6dc5bcdb
commit acbf4c0ce9
2 changed files with 108 additions and 0 deletions
@@ -1594,6 +1594,55 @@ def _uci_wifi_iface(name):
return _uci_values('wireless.%s' % name)
BAND_2G = '2.4'
BAND_5G = '5'
BAND_6G = '6'
CHANNEL_BANDS = {
BAND_2G: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
BAND_5G: [36, 40, 44, 48, 52, 56, 60, 64,
100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144,
149, 153, 157, 161, 165],
BAND_6G: list(range(1, 234, 4)),
}
DFS_CHANNELS = frozenset([52, 56, 60, 64, 100, 104, 108, 112, 116, 120,
124, 128, 132, 136, 140, 144])
def channel_band(ch):
if ch is None:
return None
try:
ch = int(ch)
except (TypeError, ValueError):
return None
if 1 <= ch <= 14:
return BAND_2G
if 36 <= ch <= 177:
return BAND_5G
if 1 <= ch <= 233 and (ch - 1) % 4 == 0:
return BAND_6G
return None
def channel_freq(band, ch):
if band == BAND_2G:
return 2412 + (ch - 1) * 5
if band == BAND_5G:
return 5180 + (ch - 36) * 5
if band == BAND_6G:
return 5955 + (ch - 1) * 5
return None
def band_htmode(band):
return {BAND_2G: 'HT20', BAND_5G: 'VHT80', BAND_6G: 'HE80'}.get(band)
def band_radio(band):
return 'radio0' if band == BAND_2G else 'radio1'
def _uci_section(section):
return _uci_values(section)