summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2024-06-11 09:34:27 +0000
committerFelix Fietkau2024-06-21 09:52:26 +0000
commit31aa61503e519b546539ad4d145faec86fcb4666 (patch)
treef49e1ef3085a5913a4c6f0741adc1930bfd0fcb6
parent33420f039d3d3357e1a5943e8756b9d22359cc11 (diff)
downloadopenwrt-31aa61503e519b546539ad4d145faec86fcb4666.tar.gz
wifi-scripts: add default channel to board.json in wifi-detect.uc
Preparation for avoiding iw calls in /lib/wifi/mac80211.sh Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc34
1 files changed, 33 insertions, 1 deletions
diff --git a/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc b/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc
index 5f375880d2..109b6a33cf 100644
--- a/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc
+++ b/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc
@@ -53,6 +53,26 @@ function wiphy_get_entry(phy, path) {
return wlan[phy];
}
+function freq_to_channel(freq) {
+ if (freq < 1000)
+ return 0;
+ if (freq == 2484)
+ return 14;
+ if (freq == 5935)
+ return 2;
+ if (freq < 2484)
+ return (freq - 2407) / 5;
+ if (freq >= 4910 && freq <= 4980)
+ return (freq - 4000) / 5;
+ if (freq < 5950)
+ return (freq - 5000) / 5;
+ if (freq <= 45000)
+ return (freq - 5950) / 5;
+ if (freq >= 58320 && freq <= 70200)
+ return (freq - 56160) / 2160;
+ return 0;
+}
+
function wiphy_detect() {
let phys = nl.request(nl.const.NL80211_CMD_GET_WIPHY, nl.const.NLM_F_DUMP, { split_wiphy_dump: true });
if (!phys)
@@ -80,8 +100,10 @@ function wiphy_detect() {
band_name = "6G";
else if (freq > 4000)
band_name = "5G";
- else
+ else if (freq > 2000)
band_name = "2G";
+ else
+ continue;
bands[band_name] = band_info;
if (band.ht_capa > 0)
band_info.ht = true;
@@ -124,6 +146,16 @@ function wiphy_detect() {
if (he_phy_cap & 0x2)
push(modes, "HE40");
+ for (let freq in band.freqs) {
+ if (freq.disabled)
+ continue;
+ let chan = freq_to_channel(freq.freq);
+ if (!chan)
+ continue;
+ band_info.default_channel = chan;
+ break;
+ }
+
if (band_name == "2G")
continue;
if (band_info.vht)