libs/sys: implement luci.sys.wifi.getiwinfo() oop interface
This commit is contained in:
parent
d1fb1f9d69
commit
398c125336
1 changed files with 23 additions and 7 deletions
|
@ -25,18 +25,19 @@ limitations under the License.
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
|
||||||
local io = require "io"
|
local io = require "io"
|
||||||
local os = require "os"
|
local os = require "os"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local nixio = require "nixio"
|
local nixio = require "nixio"
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
local iwinfo = require "iwinfo"
|
||||||
|
|
||||||
local luci = {}
|
local luci = {}
|
||||||
luci.util = require "luci.util"
|
luci.util = require "luci.util"
|
||||||
luci.ip = require "luci.ip"
|
luci.ip = require "luci.ip"
|
||||||
|
|
||||||
local tonumber, ipairs, pairs, pcall, type, next =
|
local tonumber, ipairs, pairs, pcall, type, next, setmetatable =
|
||||||
tonumber, ipairs, pairs, pcall, type, next
|
tonumber, ipairs, pairs, pcall, type, next, setmetatable
|
||||||
|
|
||||||
|
|
||||||
--- LuCI Linux and POSIX system utilities.
|
--- LuCI Linux and POSIX system utilities.
|
||||||
|
@ -617,6 +618,21 @@ end
|
||||||
-- @name luci.sys.wifi
|
-- @name luci.sys.wifi
|
||||||
wifi = {}
|
wifi = {}
|
||||||
|
|
||||||
|
--- Get wireless information for given interface.
|
||||||
|
-- @param ifname String containing the interface name
|
||||||
|
-- @return A wrapped iwinfo object instance
|
||||||
|
function wifi.getiwinfo(ifname)
|
||||||
|
local t = iwinfo.type(ifname)
|
||||||
|
if t then
|
||||||
|
local x = iwinfo[t]
|
||||||
|
return setmetatable({}, {
|
||||||
|
__index = function(t, k)
|
||||||
|
if x[k] then return x[k](ifname) end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Get iwconfig output for all wireless devices.
|
--- Get iwconfig output for all wireless devices.
|
||||||
-- @return Table of tables containing the iwconfing output for each wifi device
|
-- @return Table of tables containing the iwconfing output for each wifi device
|
||||||
function wifi.getiwconfig()
|
function wifi.getiwconfig()
|
||||||
|
|
Loading…
Reference in a new issue