first commit

main
Ben 1 year ago
commit c734de5d5e

@ -0,0 +1,10 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Dawn Mesh Wireless Control
LUCI_DEPENDS:=+dawn +luci-compat +luci-lib-json
LUCI_PKGARCH:=all
include ../../luci.mk
# call BuildPackage - OpenWrt buildroot signature

@ -0,0 +1,10 @@
module("luci.controller.mesh", package.seeall)
function index()
local e = entry({ "admin", "mesh" }, firstchild(), "Mesh", 60)
e.dependent = false
e.acl_depends = { "luci-app-mesh" }
entry({ "admin", "mesh", "view_network" }, cbi("mesh/mesh_network"), "Mesh Network Overview", 1)
entry({ "admin", "mesh", "view_hearing_map" }, cbi("mesh/mesh_hearing_map"), "Wireless Hearing Map", 2)
end

@ -0,0 +1,70 @@
m = Map("mesh", "Hearing Map", translate("Wireless Hearing Map"))
m.pageaction = false
s = m:section(NamedSection, "__hearingmap__")
function s.render(self, sid)
local tpl = require "luci.template"
tpl.render_string([[
<%
local utl = require "luci.util"
local xml = require "luci.xml"
local status = require "luci.tools.ieee80211"
local stat = utl.ubus("dawn", "get_hearing_map", { })
local name, macs
for name, macs in pairs(stat) do
%>
<div class="cbi-section-node">
<h3>SSID: <%= xml.pcdata(name) %></h3>
<table class="table" id="dawn_hearing_map">
<tr class="tr table-titles">
<th class="th">Client MAC</th>
<th class="th">AP MAC</th>
<th class="th">Frequency</th>
<th class="th">HT Sup</th>
<th class="th">VHT Sup</th>
<th class="th">Signal</th>
<th class="th">RCPI</th>
<th class="th">RSNI</th>
<th class="th">Channel Utilization</th>
<th class="th">Station connect to AP</th>
<th class="th">Score</th>
</tr>
<%
local mac, data
for mac, data in pairs(macs) do
local mac2, data2
local count_loop = 0
for mac2, data2 in pairs(data) do
if data2.freq ~= 0 then --prevent empty entry crashes
%>
<tr class="tr">
<td class="td"><%= (count_loop == 0) and mac or "" %></td>
<td class="td"><%= mac2 %></td>
<td class="td"><%= "%.3f" %( data2.freq / 1000 ) %> GHz Channel: <%= "%d" %( status.frequency_to_channel(data2.freq) ) %></td>
<td class="td"><%= (data2.ht_capabilities == true and data2.ht_support == true) and "True" or "False" %></td>
<td class="td"><%= (data2.vht_capabilities == true and data2.vht_support == true) and "True" or "False" %></td>
<td class="td"><%= "%d" % data2.signal %></td>
<td class="td"><%= "%d" % data2.rcpi %></td>
<td class="td"><%= "%d" % data2.rsni %></td>
<td class="td"><%= "%.2f" % (data2.channel_utilization / 2.55) %> %</td>
<td class="td"><%= "%d" % data2.num_sta %></td>
<td class="td"><%= "%d" % data2.score %></td>
</tr>
<%
count_loop = count_loop + 1
end
end
end
%>
</table>
</div>
<%
end
%>
]])
end
return m

@ -0,0 +1,94 @@
m = Map("mesh", "Network Overview", translate("Wireless Network Overview"))
m.pageaction = false
s = m:section(NamedSection, "__networkoverview__")
function s.render(self, sid)
local tpl = require "luci.template"
local json = require "luci.json"
local utl = require "luci.util"
tpl.render_string([[
<%
local status = require "luci.tools.ieee80211"
local utl = require "luci.util"
local sys = require "luci.sys"
local xml = require "luci.xml"
local hosts = sys.net.host_hints()
local stat = utl.ubus("dawn", "get_network", { })
local name, macs
for name, macs in pairs(stat) do
%>
<div class="cbi-section-node">
<h3>SSID: <%= xml.pcdata(name) %></h3>
<table class="table" id="network_overview_main">
<tr class="tr table-titles">
<th class="th">AP</th>
<th class="th">Clients</th>
</tr>
<%
local mac, data
for mac, data in pairs(macs) do
%>
<tr class="tr">
<td class="td" style="vertical-align: top;">
<table class="table" id="ap-<%= mac %>">
<tr class="tr table-titles">
<th class="th">Hostname</th>
<th class="th">Interface</th>
<th class="th">MAC</th>
<th class="th">Utilization</th>
<th class="th">Frequency</th>
<th class="th">Stations</th>
<th class="th">HT Sup</th>
<th class="th">VHT Sup</th>
</tr>
<tr class="tr">
<td class="td"><%= xml.pcdata(data.hostname) %></td>
<td class="td"><%= xml.pcdata(data.iface) %></td>
<td class="td"><%= mac %></td>
<td class="td"><%= "%.2f" %(data.channel_utilization / 2.55) %> %</td>
<td class="td"><%= "%.3f" %( data.freq / 1000 ) %> GHz (Channel: <%= "%d" %( status.frequency_to_channel(data.freq) ) %>)</td>
<td class="td"><%= "%d" % data.num_sta %></td>
<td class="td"><%= (data.ht_support == true) and "available" or "not available" %></td>
<td class="td"><%= (data.vht_support == true) and "available" or "not available" %></td>
</tr>
</table>
</td>
<td class="td" style="vertical-align: top;">
<table class="table" id="clients-<%= mac %>">
<tr class="tr table-titles">
<th class="th">MAC</th>
<th class="th">HT</th>
<th class="th">VHT</th>
<th class="th">Signal</th>
</tr>
<%
local mac2, data2
for clientmac, clientvals in pairs(data) do
if (type(clientvals) == "table") then
%>
<tr class="tr">
<td class="td"><%= clientmac %></td>
<td class="td"><%= (clientvals.ht == true) and "available" or "not available" %></td>
<td class="td"><%= (clientvals.vht == true) and "available" or "not available" %></td>
<td class="td"><%= "%d" % clientvals.signal %></td>
</tr>
<%
end
end
%>
</table>
</td>
</tr>
<%
end
%>
</table>
</div>
<%
end
%>
]])
end
return m

@ -0,0 +1,20 @@
module("luci.tools.ieee80211", package.seeall)
function frequency_to_channel(freq)
if (freq <= 2400) then
return 0;
elseif (freq == 2484) then
return 14;
elseif (freq < 2484) then
return (freq - 2407) / 5;
elseif (freq >= 4910 and freq <= 4980) then
return (freq - 4000) / 5;
elseif (freq <= 45000) then
return (freq - 5000) / 5;
elseif (freq >= 58320 and freq <= 64800) then
return (freq - 56160) / 2160;
else
return 0;
end
end

@ -0,0 +1,11 @@
{
"luci-app-mesh": {
"description": "Grant UCI access for luci-app-mesh",
"read": {
"uci": [ "mesh" ]
},
"write": {
"uci": [ "mesh" ]
}
}
}
Loading…
Cancel
Save