summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-11-15 15:46:27 +0000
committerSteven Barth <steven@midlink.org>2009-11-15 15:46:27 +0000
commit89ece183ef93a16afcbbdf3dca5398d34c233aa6 (patch)
treebb9ed3a1bf1de0b86ffe01700d90e5ef089ee293
parent1b77a6f4c49b29b83e3063d9deca1a38e97ad897 (diff)
Merge luci.sys.wifi.channels to iwinfo
-rw-r--r--libs/sys/luasrc/sys.lua34
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua4
2 files changed, 18 insertions, 20 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index 1708a2735..c09c5e273 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -687,27 +687,25 @@ end
-- @param iface Wireless interface (optional)
-- @return Table of available channels
function wifi.channels(iface)
- local cmd = "iwlist " .. ( iface or "" ) .. " freq 2>/dev/null"
- local cns = { }
-
- local fd = io.popen(cmd)
- if fd then
- local ln, c, f
- while true do
- ln = fd:read("*l")
- if not ln then break end
- c, f = ln:match("Channel (%d+) : (%d+%.%d+) GHz")
- if c and f then
- cns[tonumber(c)] = tonumber(f)
- end
- end
- fd:close()
+ local t = iwinfo.type(iface)
+ local cns
+ if t and iwinfo[t] then
+ cns = iwinfo[t].freqlist(iface)
end
- if not next(cns) then
+ if not cns or #cns == 0 then
cns = {
- 2.412, 2.417, 2.422, 2.427, 2.432, 2.437,
- 2.442, 2.447, 2.452, 2.457, 2.462
+ {channel = 1, mhz = 2.412},
+ {channel = 2, mhz = 2.417},
+ {channel = 3, mhz = 2.422},
+ {channel = 4, mhz = 2.427},
+ {channel = 5, mhz = 2.432},
+ {channel = 6, mhz = 2.437},
+ {channel = 7, mhz = 2.442},
+ {channel = 8, mhz = 2.447},
+ {channel = 9, mhz = 2.452},
+ {channel = 10, mhz = 2.457},
+ {channel = 11, mhz = 2.462}
}
end
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
index 78d763056..00bd560fc 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua
@@ -91,8 +91,8 @@ local nsantenna = m:get(arg[1], "antenna")
ch = s:taboption("general", Value, "channel", translate("Channel"))
ch:value("auto", translate("auto"))
-for c, f in luci.util.kspairs(luci.sys.wifi.channels()) do
- ch:value(c, "%i (%.3f GHz)" %{ c, f })
+for _, f in ipairs(luci.sys.wifi.channels()) do
+ ch:value(f.channel, "%i (%.3f GHz)" %{ f.channel, f.mhz })
end