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,28 +36,29 @@ function init(cursor)
|
||||||
st = uci.cursor_state()
|
st = uci.cursor_state()
|
||||||
ifs = { }
|
ifs = { }
|
||||||
|
|
||||||
local count = 0
|
local count = { }
|
||||||
|
|
||||||
ub.uci:foreach("wireless", "wifi-iface",
|
ub.uci:foreach("wireless", "wifi-iface",
|
||||||
function(s)
|
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] = {
|
ifs[id] = {
|
||||||
id = id,
|
id = id,
|
||||||
sid = s['.name'],
|
sid = s['.name'],
|
||||||
count = count
|
count = count
|
||||||
}
|
}
|
||||||
|
|
||||||
local dev = st:get("wireless", s['.name'], "ifname")
|
local dev = st:get("wireless", s['.name'], "ifname")
|
||||||
or st:get("wireless", s['.name'], "device")
|
or st:get("wireless", s['.name'], "device")
|
||||||
|
|
||||||
local wtype = dev and iwi.type(dev)
|
local wtype = dev and iwi.type(dev)
|
||||||
|
if dev and wtype then
|
||||||
if dev and wtype then
|
ifs[id].winfo = iwi[wtype]
|
||||||
ifs[id].winfo = iwi[wtype]
|
ifs[id].wdev = dev
|
||||||
ifs[id].wdev = dev
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -129,7 +130,7 @@ end
|
||||||
function shortname(self, iface)
|
function shortname(self, iface)
|
||||||
if iface.wdev and iface.winfo then
|
if iface.wdev and iface.winfo then
|
||||||
return "%s %q" %{
|
return "%s %q" %{
|
||||||
i18n.translate(iface:active_mode()),
|
i18n.translate(iface:active_mode()),
|
||||||
iface:active_ssid() or i18n.translate("(hidden)")
|
iface:active_ssid() or i18n.translate("(hidden)")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -230,7 +231,7 @@ network:property("bssid")
|
||||||
network:property("network")
|
network:property("network")
|
||||||
|
|
||||||
function network._init(self, sid)
|
function network._init(self, sid)
|
||||||
local count = 0
|
local count = { }
|
||||||
|
|
||||||
local parent_dev = st:get("wireless", sid, "device")
|
local parent_dev = st:get("wireless", sid, "device")
|
||||||
or ub.uci:get("wireless", sid, "device")
|
or ub.uci:get("wireless", sid, "device")
|
||||||
|
@ -241,14 +242,17 @@ function network._init(self, sid)
|
||||||
if dev then
|
if dev then
|
||||||
ub.uci:foreach("wireless", "wifi-iface",
|
ub.uci:foreach("wireless", "wifi-iface",
|
||||||
function(s)
|
function(s)
|
||||||
count = count + 1
|
if s.device then
|
||||||
if s['.name'] == sid then
|
count[s.device] = count[s.device]
|
||||||
self.id = "%s.network%d" %{ parent_dev, count }
|
and count[s.device] + 1 or 1
|
||||||
|
if s['.name'] == sid then
|
||||||
|
self.id = "%s.network%d" %{ parent_dev, count[s.device] }
|
||||||
|
|
||||||
local wtype = iwi.type(dev)
|
local wtype = iwi.type(dev)
|
||||||
if dev and wtype then
|
if dev and wtype then
|
||||||
self.winfo = iwi[wtype]
|
self.winfo = iwi[wtype]
|
||||||
self.wdev = dev
|
self.wdev = dev
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -302,7 +306,8 @@ function network.active_bssid(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function network.active_encryption(self)
|
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
|
end
|
||||||
|
|
||||||
function network.assoclist(self)
|
function network.assoclist(self)
|
||||||
|
@ -360,4 +365,3 @@ function network.signal_percent(self)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue