From 1edfae6dae2fc4c2c173d5a89e2234631a599ec7 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Thu, 17 Oct 2024 12:54:54 -0700 Subject: [PATCH] Mark bandwidths invalid on various devices (rather than marking what is valid) (#1639) * Mark bandwidths invalid on various devices (rather than marking what is valid) * Typo --- files/etc/radios.json | 28 ++++++++-------- files/usr/share/ucode/aredn/hardware.uc | 44 ++++++++++++++----------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/files/etc/radios.json b/files/etc/radios.json index 02c73545..bbb6b564 100644 --- a/files/etc/radios.json +++ b/files/etc/radios.json @@ -68,7 +68,7 @@ }, "gl.inet gl-mt1300": { "wlan0": { - "bandwidths": [ 20 ], + "exclude_bandwidths": [ 5, 10 ], "antenna": { "description": "3 dBi Omni", "gain": 3, @@ -76,7 +76,7 @@ } }, "wlan1": { - "bandwidths": [ 20 ], + "exclude_bandwidths": [ 5, 10 ], "antenna": { "description": "3 dBi Omni", "gain": 3, @@ -342,7 +342,7 @@ }, "mikrotik routerboard 921gs-5hpacd-15s": { "maxpower": 31, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "15 dBi 120° Sector", "gain": 15, @@ -351,7 +351,7 @@ }, "mikrotik routerboard 921gs-5hpacd-19s": { "maxpower": 31, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "19 dBi 120° Sector", "gain": 19, @@ -369,7 +369,7 @@ }, "wlan1": { "maxpower": 22, - "bandwidths": [ 10, 20 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "2 dBi Omni", "gain": 2, @@ -388,7 +388,7 @@ }, "wlan1": { "maxpower": 22, - "bandwidths": [ 10, 20 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "2 dBi Omni", "gain": 2, @@ -407,7 +407,7 @@ }, "wlan1": { "maxpower": 22, - "bandwidths": [ 10, 20 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "2 dBi Omni", "gain": 2, @@ -449,7 +449,7 @@ }, "mikrotik ldf 5 ac (rbldfg-5acd)": { "maxpower": 25, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": "external" }, "mikrotik routerboard rbldf-5nd": { @@ -550,7 +550,7 @@ }, "mikrotik lhg 5 ac (rblhgg-5acd)": { "maxpower": 25, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "24.5 dBi 7° Dish", "gain": 24.5, @@ -559,7 +559,7 @@ }, "mikrotik lhg 5 ac xl (rblhgg-5acd-xl)": { "maxpower": 25, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "27 dBi 7° Dish", "gain": 27, @@ -640,7 +640,7 @@ }, "mikrotik sxtsq 5 ac (rbsxtsqg-5acd)": { "maxpower": 25, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "16 dBi 23° Panel", "gain": 16, @@ -658,7 +658,7 @@ }, "wlan1": { "maxpower": 26, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "2.5 dBi Omni", "gain": 2.5, @@ -677,7 +677,7 @@ }, "wlan1": { "maxpower": 26, - "bandwidths": [ 10, 20, 40, 80 ], + "exclude_bandwidths": [ 5 ], "antenna": { "description": "5.5 dBi Omni", "gain": 5.5, @@ -982,7 +982,7 @@ "0xe4f2": { "name": "Ubiquiti NanoBeam 2AC 13 (2WA)", "wlan0": { - "bandwidths": [ 10, 20 ], + "exclude_bandwidths": [ 5 ], "maxpower": 21, "pwroffset": 6, "antenna": { diff --git a/files/usr/share/ucode/aredn/hardware.uc b/files/usr/share/ucode/aredn/hardware.uc index 10d320c2..13532ea6 100755 --- a/files/usr/share/ucode/aredn/hardware.uc +++ b/files/usr/share/ucode/aredn/hardware.uc @@ -195,31 +195,37 @@ export function getRfChannels(wifiIface) export function getRfBandwidths(wifiIface) { const radio = getRadioIntf(wifiIface); - if (radio.bandwidths) { - return radio.bandwidths; + const invalid = {}; + map(radio.exclude_bandwidths || [], v => invalid[v] = true); + const bw = []; + if (!invalid["5"]) { + push(bw, 5); } - else { - const bw = [ 5, 10, 20 ]; - if (fs.access(`/sys/kernel/debug/ieee80211/${replace(wifiIface, "wlan", "phy")}/ath10k`)) { - const f = fs.popen(`/usr/bin/iwinfo ${wifiIface} htmodelist 2> /dev/null`); - if (f) { - let line = f.read("line"); - if (line) { - if (index(line, "VHT40") !== -1) { - push(bw, 40); - } - if (index(line, "VHT80") !== -1) { - push(bw, 80); - } + if (!invalid["10"]) { + push(bw, 10); + } + if (!invalid["20"]) { + push(bw, 20); + } + if (fs.access(`/sys/kernel/debug/ieee80211/${replace(wifiIface, "wlan", "phy")}/ath10k`)) { + const f = fs.popen(`/usr/bin/iwinfo ${wifiIface} htmodelist 2> /dev/null`); + if (f) { + let line = f.read("line"); + if (line) { + if (index(line, "VHT40") !== -1 && !invalid["40"]) { + push(bw, 40); } - while (!line) { - line = f.read("line"); + if (index(line, "VHT80") !== -1 && !invalid["80"]) { + push(bw, 80); } - f.close(); } + while (!line) { + line = f.read("line"); + } + f.close(); } - return bw; } + return bw; }; export function getDefaultChannel(wifiIface)