modules/freifunk: Wifi status was not showing on brcm47xx.
This commit is contained in:
parent
698f7fde5e
commit
3f7179869f
1 changed files with 70 additions and 91 deletions
|
@ -1,11 +1,12 @@
|
||||||
<%
|
<%
|
||||||
local sys = require "luci.sys"
|
require "luci.sys"
|
||||||
local twa = require "luci.tools.webadmin"
|
require "luci.tools.webadmin"
|
||||||
|
|
||||||
-- System
|
-- System
|
||||||
local system, model, memtotal, memcached, membuffers, memfree = sys.sysinfo()
|
|
||||||
local uptime = twa.date_format(tonumber(sys.uptime()))
|
local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
||||||
local_time = os.date("%c")
|
local uptime = luci.sys.uptime()
|
||||||
local load1, load5, load15 = sys.loadavg()
|
local load1, load5, load15 = luci.sys.loadavg()
|
||||||
local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15)
|
local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15)
|
||||||
local memory = string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
local memory = string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
||||||
tonumber(memtotal) / 1024,
|
tonumber(memtotal) / 1024,
|
||||||
|
@ -16,18 +17,24 @@ local memory = string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
|
||||||
100 * memfree / memtotal,
|
100 * memfree / memtotal,
|
||||||
tostring(translate("free"))
|
tostring(translate("free"))
|
||||||
)
|
)
|
||||||
|
local_time = os.date("%c")
|
||||||
|
local uptime = luci.tools.webadmin.date_format(tonumber(uptime))
|
||||||
|
|
||||||
-- wireless
|
-- Wireless
|
||||||
local ntm = require "luci.model.network".init()
|
local uci = require "luci.model.uci".cursor()
|
||||||
local devices = ntm:get_wifidevs()
|
ifaces = {}
|
||||||
local netlist = { }
|
uci:foreach("wireless", "wifi-iface", function(s)
|
||||||
local netdevs = { }
|
if s.network then
|
||||||
local dev
|
table.insert(ifaces, s.network)
|
||||||
local has_iwinfo = pcall(require, "iwinfo")
|
if (uci:get("network", s.network, "ifname")) then
|
||||||
|
has_ifaces = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- Routes
|
-- Routes
|
||||||
local defroutev4 = sys.net.defaultroute()
|
local defroutev4 = luci.sys.net.defaultroute()
|
||||||
local defroutev6 = sys.net.defaultroute6 ()
|
local defroutev6 = luci.sys.net.defaultroute6 ()
|
||||||
|
|
||||||
%>
|
%>
|
||||||
<%+header%>
|
<%+header%>
|
||||||
|
@ -44,18 +51,9 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if devices[1] then %>
|
<% if has_ifaces == true then %>
|
||||||
|
|
||||||
<div class="cbi-map">
|
<div class="cbi-map">
|
||||||
<h2><%:Wireless Overview%></h2>
|
<h2><%:Wireless Overview%></h2>
|
||||||
|
|
||||||
<% if not has_iwinfo then %>
|
|
||||||
<div class="errorbox">
|
|
||||||
<strong><%:Package libiwinfo required!%></strong><br />
|
|
||||||
<%_The <em>libiwinfo</em> package is not installed. You must install this component for working wireless configuration!%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="cbi-section">
|
<div class="cbi-section">
|
||||||
<div class="cbi-section-node">
|
<div class="cbi-section-node">
|
||||||
<table class="cbi-section-table">
|
<table class="cbi-section-table">
|
||||||
|
@ -65,22 +63,18 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
<th class="cbi-section-table-cell"><%:SSID%></th>
|
<th class="cbi-section-table-cell"><%:SSID%></th>
|
||||||
<th class="cbi-section-table-cell"><%:BSSID%></th>
|
<th class="cbi-section-table-cell"><%:BSSID%></th>
|
||||||
<th class="cbi-section-table-cell"><%:Channel%></th>
|
<th class="cbi-section-table-cell"><%:Channel%></th>
|
||||||
<th class="cbi-section-table-cell"><%:Mode%></th>
|
<th class="cbi-section-table-cell"><%:Mode%></th><th><%:TX%>-<%:Power%></th>
|
||||||
<th class="cbi-section-table-cell"><%:TX%>-<%:Power%></th>
|
|
||||||
<th class="cbi-section-table-cell"><%:Interface%></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
|
||||||
for _, dev in ipairs(devices) do
|
|
||||||
local net
|
|
||||||
for _, net in ipairs(dev:get_wifinets()) do
|
|
||||||
netlist[#netlist+1] = net:ifname()
|
|
||||||
netdevs[net:ifname()] = dev:name()
|
|
||||||
|
|
||||||
if net.iwdata.ifname then
|
|
||||||
local signal = net.iwinfo.signal or "N/A"
|
<% for k,v in pairs(ifaces) do
|
||||||
local noise = net.iwinfo.noise or "N/A"
|
local iface = uci:get("network", v, "ifname")
|
||||||
local q = net.iwinfo.quality or "0"
|
if iface then
|
||||||
local qmax = net.iwinfo.quality_max or "100"
|
iwinf = luci.sys.wifi.getiwinfo(iface)
|
||||||
|
local signal = iwinf.signal
|
||||||
|
local noise = iwinf.noise
|
||||||
|
local q = iwinf.quality
|
||||||
|
local qmax = iwinf.quality_max
|
||||||
local qperc = q / qmax * 100
|
local qperc = q / qmax * 100
|
||||||
|
|
||||||
if qperc == 0 then
|
if qperc == 0 then
|
||||||
|
@ -99,19 +93,12 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
|
|
||||||
signal_string = "<img src='"..resource.."/icons/"..icon.."' title='Signal: "..signal.." db / Noise: "..noise.." db' alt='Signal Quality'></img>"
|
signal_string = "<img src='"..resource.."/icons/"..icon.."' title='Signal: "..signal.." db / Noise: "..noise.." db' alt='Signal Quality'></img>"
|
||||||
|
|
||||||
local ssid = net.iwinfo.ssid or "N/A"
|
local ssid = iwinf.ssid
|
||||||
local bssid = net.iwinfo.bssid or "N/A"
|
local bssid = iwinf.bssid
|
||||||
local chan = net.iwinfo.channel or "N/A"
|
local chan = iwinf.channel
|
||||||
local mode = net.iwinfo.mode or "N/A"
|
local mode = iwinf.mode
|
||||||
local txpwr = net.iwinfo.txpower or "N/A"
|
local txpwr = iwinf.txpower.." dbm"
|
||||||
if txpwr ~= "N/A" then
|
local bitrate = (iwinf.bitrate / 1000).."Mb/s"
|
||||||
txpwr = txpwr.." dbm"
|
|
||||||
end
|
|
||||||
local bitrate = net.iwinfo.bitrate or "N/A"
|
|
||||||
if bitrate ~= "N/A" then
|
|
||||||
bitrate = ( bitrate / 1000 ).."Mb/s"
|
|
||||||
end
|
|
||||||
local interface = net.iwdata.ifname or "N/A"
|
|
||||||
%>
|
%>
|
||||||
<tr class="cbi-section-table-row cbi-rowstyle-1">
|
<tr class="cbi-section-table-row cbi-rowstyle-1">
|
||||||
<td class="cbi-value-field"><%=signal_string%></td>
|
<td class="cbi-value-field"><%=signal_string%></td>
|
||||||
|
@ -119,13 +106,10 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
<td class="cbi-value-field"><%=ssid%></td>
|
<td class="cbi-value-field"><%=ssid%></td>
|
||||||
<td class="cbi-value-field"><%=bssid%></td>
|
<td class="cbi-value-field"><%=bssid%></td>
|
||||||
<td class="cbi-value-field"><%=chan%></td>
|
<td class="cbi-value-field"><%=chan%></td>
|
||||||
<td class="cbi-value-field"><%=mode%></td>
|
<td class="cbi-value-field"><%=mode%></td><td><%=txpwr%></td>
|
||||||
<td class="cbi-value-field"><%=txpwr%></td>
|
|
||||||
<td class="cbi-value-field"><%=interface%></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end
|
<% end %>
|
||||||
end
|
<% end %>
|
||||||
end %>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -137,7 +121,6 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
<div class="cbi-section">
|
<div class="cbi-section">
|
||||||
<div class="cbi-section-node">
|
<div class="cbi-section-node">
|
||||||
<table class="cbi-section-table">
|
<table class="cbi-section-table">
|
||||||
|
|
||||||
<% if not defroutev4 and not defroutev6 then %>
|
<% if not defroutev4 and not defroutev6 then %>
|
||||||
<%:No defaultroutes known.%>
|
<%:No defaultroutes known.%>
|
||||||
<%else%>
|
<%else%>
|
||||||
|
@ -147,32 +130,28 @@ local defroutev6 = sys.net.defaultroute6 ()
|
||||||
<th class="cbi-section-table-cell"><%:Gateway%></th>
|
<th class="cbi-section-table-cell"><%:Gateway%></th>
|
||||||
<th class="cbi-section-table-cell"><%:Metric%></th>
|
<th class="cbi-section-table-cell"><%:Metric%></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% if defroutev4 then %>
|
<% if defroutev4 then %>
|
||||||
|
|
||||||
<tr class="cbi-section-table-row cbi-rowstyle-1">
|
<tr class="cbi-section-table-row cbi-rowstyle-1">
|
||||||
<td class="cbi-value-field"><%=defroutev4.dest:string()%></td>
|
<td class="cbi-value-field"><%=defroutev4.dest:string()%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev4.device%></td>
|
<td class="cbi-value-field"><%=defroutev4.device%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev4.gateway:string()%></td>
|
<td class="cbi-value-field"><%=defroutev4.gateway:string()%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev4.metric%></td>
|
<td class="cbi-value-field"><%=defroutev4.metric%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
||||||
<% end
|
<% if defroutev6 then %>
|
||||||
if defroutev6 then %>
|
|
||||||
|
|
||||||
<tr class="cbi-section-table-row cbi-rowstyle-2">
|
<tr class="cbi-section-table-row cbi-rowstyle-2">
|
||||||
<td class="cbi-value-field"><%=defroutev6.dest:string()%></td>
|
<td class="cbi-value-field"><%=defroutev6.dest:string()%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev6.device%></td>
|
<td class="cbi-value-field"><%=defroutev6.device%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev6.nexthop:string()%></td>
|
<td class="cbi-value-field"><%=defroutev6.nexthop:string()%></td>
|
||||||
<td class="cbi-value-field"><%=defroutev6.metric%></td>
|
<td class="cbi-value-field"><%=defroutev6.metric%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%+footer%>
|
<%+footer%>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue