Fix frequency range reporting and display for 900MHz devices (#803)

This commit is contained in:
Tim Wilkinson 2023-04-23 18:00:53 -07:00 committed by GitHub
parent 8711afa9ca
commit be969b1e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -271,13 +271,19 @@ function hardware.get_rfchannels(wifiintf)
local f = io.popen("iwinfo " .. wifiintf .. " freqlist")
if f then
local freq_adjust = 0
local freq_min = 0
local freq_max = 0x7FFFFFFF
if wifiintf == "wlan0" then
local radio = hardware.get_radio()
if radio then
if radio.name:match("M9") then
freq_adjust = -1520;
freq_min = 907
freq_max = 922
elseif radio.name:match("M3") then
freq_adjust = -2000;
freq_min = 3380
freq_max = 3495
end
end
end
@ -286,12 +292,14 @@ function hardware.get_rfchannels(wifiintf)
local freq, num = line:match("(%d+%.%d+) GHz %(Channel (%-?%d+)%)")
if freq and not line:match("restricted") and not line:match("disabled") then
freq = tonumber("" .. freq:gsub("%.", "")) + freq_adjust
num = tonumber("" .. num:gsub("^0+", ""))
channels[#channels + 1] = {
label = num .. " (" .. freq .. ")",
number = num,
frequency = freq
}
if freq >= freq_min and freq <= freq_max then
num = tonumber("" .. num:gsub("^0+", ""))
channels[#channels + 1] = {
label = freq_adjust == 0 and (num .. " (" .. freq .. ")") or (freq),
number = num,
frequency = freq
}
end
end
end
f:close()

View File

@ -181,8 +181,11 @@ local wifi_ssid
if not wifi_disabled then
wifi_channel = cursor:get("wireless", radio, "channel")
wifi_channel = tonumber(wifi_channel) or 0
if wifi_channel >= 76 and wifi_channel <= 99 then
local basefreq = aredn.hardware.get_rfchannels(wifi_iface)[1].frequency
if basefreq > 3000 and basefreq < 5600 then
wifi_channel = wifi_channel * 5 + 3000
elseif basefreq > 900 and basefreq < 2300 then
wifi_channel = wifi_channel * 5 + 887
end
wifi_chanbw = cursor:get("wireless", radio, "chanbw") or "20"
wifi_ssid = "none"