libs/core: fix network counting in luci.model.wireless
This commit is contained in:
parent
7ae988f342
commit
687861c498
1 changed files with 30 additions and 26 deletions
|
@ -36,13 +36,14 @@ function init(cursor)
|
|||
st = uci.cursor_state()
|
||||
ifs = { }
|
||||
|
||||
local count = 0
|
||||
local count = { }
|
||||
|
||||
ub.uci:foreach("wireless", "wifi-iface",
|
||||
function(s)
|
||||
count = count + 1
|
||||
if s.device then
|
||||
count[s.device] = count[s.device] and count[s.device] + 1 or 1
|
||||
|
||||
local id = "%s.network%d" %{ s.device, count }
|
||||
local id = "%s.network%d" %{ s.device, count[s.device] }
|
||||
|
||||
ifs[id] = {
|
||||
id = id,
|
||||
|
@ -54,11 +55,11 @@ function init(cursor)
|
|||
or st:get("wireless", s['.name'], "device")
|
||||
|
||||
local wtype = dev and iwi.type(dev)
|
||||
|
||||
if dev and wtype then
|
||||
ifs[id].winfo = iwi[wtype]
|
||||
ifs[id].wdev = dev
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -230,7 +231,7 @@ network:property("bssid")
|
|||
network:property("network")
|
||||
|
||||
function network._init(self, sid)
|
||||
local count = 0
|
||||
local count = { }
|
||||
|
||||
local parent_dev = st:get("wireless", sid, "device")
|
||||
or ub.uci:get("wireless", sid, "device")
|
||||
|
@ -241,9 +242,11 @@ function network._init(self, sid)
|
|||
if dev then
|
||||
ub.uci:foreach("wireless", "wifi-iface",
|
||||
function(s)
|
||||
count = count + 1
|
||||
if s.device then
|
||||
count[s.device] = count[s.device]
|
||||
and count[s.device] + 1 or 1
|
||||
if s['.name'] == sid then
|
||||
self.id = "%s.network%d" %{ parent_dev, count }
|
||||
self.id = "%s.network%d" %{ parent_dev, count[s.device] }
|
||||
|
||||
local wtype = iwi.type(dev)
|
||||
if dev and wtype then
|
||||
|
@ -251,6 +254,7 @@ function network._init(self, sid)
|
|||
self.wdev = dev
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
@ -302,7 +306,8 @@ function network.active_bssid(self)
|
|||
end
|
||||
|
||||
function network.active_encryption(self)
|
||||
return self.winfo and self.winfo.enctype(self.wdev) or "-"
|
||||
local enc = self.winfo and self.winfo.encryption(self.wdev)
|
||||
return enc and enc.description or "-"
|
||||
end
|
||||
|
||||
function network.assoclist(self)
|
||||
|
@ -360,4 +365,3 @@ function network.signal_percent(self)
|
|||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue