refactored radio hardware info

main
riley 1 year ago
parent 1b3930dd2d
commit 895d07f3c3

@ -31,39 +31,24 @@ function detect_Node()
end end
function get_verbose_hw_info(iface) local function get_verbose_hw_info(iface)
local type = iwinfo.type(iface) local type = iwinfo.type(iface)
if not type then if not type then return "Generic" end
return "Generic"
end
local driver = iwinfo[type] local driver = iwinfo[type]
if not driver then if not driver then return "Driver not supported" end
return "Driver not supported"
end
local hw_name = driver.hardware_name and driver.hardware_name(iface)
if not hw_name or hw_name == "" then
hw_name = "Unknown hardware"
end
local hw_modes = driver.hwmodelist and driver.hwmodelist(iface) local hw_name = driver.hardware_name and driver.hardware_name(iface) or "Unknown hardware"
local hw_modes = driver.hwmodelist and driver.hwmodelist(iface) or {}
local supported_modes = {} local supported_modes = {}
if hw_modes then
for mode, supported in pairs(hw_modes) do for mode, supported in pairs(hw_modes) do
if supported then if supported then
table.insert(supported_modes, mode) supported_modes[#supported_modes + 1] = mode
end
end end
end end
if #supported_modes == 0 then return hw_name .. " (" .. (#supported_modes > 0 and table.concat(supported_modes, "/") or "No mode information") .. ")"
supported_modes_str = "No mode information"
else
supported_modes_str = table.concat(supported_modes, "/")
end
local verbose_info = hw_name .. " (" .. supported_modes_str .. ")"
return verbose_info
end end
local Nodes = luci.sys.exec("batctl n 2>/dev/null| tail +3 | wc -l") local Nodes = luci.sys.exec("batctl n 2>/dev/null| tail +3 | wc -l")

Loading…
Cancel
Save