From 2454accbb5f0d59fe608b3b16f7bd082d823ce56 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Sun, 12 May 2024 14:53:37 -0700 Subject: [PATCH] Fix various status information errors (#1195) * Fix various status information errors * Fix whitespace --- files/usr/lib/lua/aredn/info.lua | 6 ++++++ files/usr/local/bin/mgr/lqm.lua | 5 ++++- files/www/cgi-bin/status | 7 ++++--- files/www/cgi-bin/sysinfo.json | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/files/usr/lib/lua/aredn/info.lua b/files/usr/lib/lua/aredn/info.lua index dd66f7da..9c8c0bf1 100755 --- a/files/usr/lib/lua/aredn/info.lua +++ b/files/usr/lib/lua/aredn/info.lua @@ -290,6 +290,7 @@ end -- Return Frequency ------------------------------------- function model.getFreq(radio) + require("aredn.hardware") local api=iwinfo.type(radio) local iw = iwinfo[api] local freq = iw.frequency(radio) @@ -298,6 +299,11 @@ function model.getFreq(radio) if (chan >= 76 and chan <= 99) then freq = freq - 2000 end + -- 900MHz channel -> Freq conversion + local radio = aredn.hardware.get_radio() + if radio and radio.name:match("M9") then + freq = freq - 1520 + end return tostring(freq) end diff --git a/files/usr/local/bin/mgr/lqm.lua b/files/usr/local/bin/mgr/lqm.lua index 42566dcc..6879893d 100755 --- a/files/usr/local/bin/mgr/lqm.lua +++ b/files/usr/local/bin/mgr/lqm.lua @@ -1003,7 +1003,8 @@ function lqm() -- Save valid (unblocked) rf mac list for use by OLSR if config.enable and phy ~= "none" then - f = io.open("/tmp/lqm." .. phy .. ".macs", "w") + local tmpfile = "/tmp/lqm." .. phy .. ".macs.tmp" + f = io.open(tmpfile, "w") if f then for _, track in pairs(tracker) do @@ -1012,6 +1013,8 @@ function lqm() end end f:close() + filecopy(tmpfile, "/tmp/lqm." .. phy .. ".macs", true) + os.remove(tmpfile) end end diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index c4369031..b64a48a2 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -166,7 +166,7 @@ local cursor = uci.cursor() local wifi_channel local wifi_chanbw -local wifi_freq_range = "" +local wifi_freq_range = "-" local wifi_ssid if not wifi_disabled then wifi_channel = cursor:get("wireless", radio, "channel") @@ -174,6 +174,7 @@ if not wifi_disabled then wifi_chanbw = tonumber(cursor:get("wireless", radio, "chanbw") or "20") local rfchans = aredn.hardware.get_rfchannels(wifi_iface) if rfchans and rfchans[1] then + local num = wifi_channel local basefreq = rfchans[1].frequency if basefreq > 3000 and basefreq < 5000 then wifi_channel = wifi_channel * 5 + 3000 @@ -182,8 +183,8 @@ if not wifi_disabled then end for _, chan in ipairs(rfchans) do - if chan.number == wifi_channel then - wifi_freq_range = (chan.frequency - wifi_chanbw / 2) .. " - " .. (chan.frequency + wifi_chanbw / 2) .. " MHz" + if chan.number == num then + wifi_freq_range = math.floor(chan.frequency - wifi_chanbw / 2) .. " - " .. math.ceil(chan.frequency + wifi_chanbw / 2) .. " MHz" break end end diff --git a/files/www/cgi-bin/sysinfo.json b/files/www/cgi-bin/sysinfo.json index 53d4294b..1973cf7e 100755 --- a/files/www/cgi-bin/sysinfo.json +++ b/files/www/cgi-bin/sysinfo.json @@ -112,9 +112,9 @@ end -- Tunnel info info['tunnels']={} -- ACTIVE TUNNELS -local atc="" -atc=os.capture("ifconfig|grep tun|wc -l") -info['tunnels']['active_tunnel_count']=atc:chomp() +local atc=os.capture("ifconfig|grep tun|wc -l"):chomp() +local awc=os.capture("wg|grep interface|wc -l"):chomp() +info['tunnels']['active_tunnel_count']=tonumber(atc) + tonumber(awc) -- Location info -- LAT/LON