Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
modified: package/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_…
Browse files Browse the repository at this point in the history
…overview.htm

	modified:   package/mt/luci-app-mtwifi/root/usr/lib/lua/mtkwifi.lua
  • Loading branch information
Azexios committed Dec 3, 2021
1 parent 740893e commit 23d676a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ <h2><a name="content">Wireless Overview</a></h2>
<% if dev.apcli.status == "Connected" then %>
<strong>BSSID:</strong> <%=dev.apcli.bssid%> |
<strong>SSID:</strong> <%=dev.apcli.ssid%>
<br/>
<strong>Bit Rate:</strong> <%=dev.apcli.rate%>
<% else %>
Wireless is disabled or not associated
<% end %>
Expand All @@ -105,7 +107,7 @@ <h2><a name="content">Wireless Overview</a></h2>
<% if dev.apcli.state == "up" then %>
<% if dev.apcli.status == "Connected" then %>
<input class="cbi-button cbi-button-reload" style="width:100px" title="Reload Wi-Fi network" value="Reload" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname,dev.apcli.vifname)%>")' />
<input class="cbi-button cbi-button-remove" style="width:100px" title="Disable Wi-Fi network" value="Disable" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>")' />
<input class="cbi-button cbi-button-remove" style="width:100px" title="Disconnect Wi-Fi network" value="Disconnect" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>")' />
<% else %>
<input class="cbi-button cbi-button-reload" style="width:100px" title="Connect Wi-Fi network" value="Connect" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname,dev.apcli.vifname)%>")' />
<input class="cbi-button cbi-button-remove" style="width:100px" title="Disable Wi-Fi network" value="Disable" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>")' />
Expand All @@ -123,29 +125,34 @@ <h2><a name="content">Wireless Overview</a></h2>
</fieldset>
<% end %>

<!--
<h2><a id="content" name="content"><%:Station List%></a></h2>
<style type="text/css">
.table2 {
word-spacing: 100vw;
}
</style>

<fieldset class="cbi-section">
<table class="cbi-section-table" style="margin:10px" id="iw-assoclist">
<tr class="cbi-section-table-titles">
<th class="cbi-section-table-cell"></th>
<th class="cbi-section-table-cell"><%:SSID%></th>
<th class="cbi-section-table-cell"><%:MAC-Address%></th>
<th class="cbi-section-table-cell"><%:IPv4-Address%></th>
<th class="cbi-section-table-cell"><%:Signal%></th>
<th class="cbi-section-table-cell"><%:Noise%></th>
<th class="cbi-section-table-cell"><%:RX Rate%></th>
<th class="cbi-section-table-cell"><%:TX Rate%></th>
</tr>
<tr class="cbi-section-table-row cbi-rowstyle-2">
<td class="cbi-value-field" colspan="8">
<em><%:Collecting data...%></em>
</td>
</tr>
</table>
</fieldset>
-->
<h2><a id="content" name="content">Associated Stations</a></h2>
<%=dme%>
<fieldset class="cbi-section">
<table align="left">
<thead>
<tr style="text-align:left">
<th style="width:160px">MAC-Address</th>
<th style="width:130px">RSSI - 0/1/2/3</th>
<th style="width:100px">BW (T/R)</th>
<th style="width:100px">Rate (T/R) Mb/s</th>
</tr>
</thead>
<tbody>
<tr>
<td><div class="table2"><%=MAC%></div></td>
<td><div class="table2"><%=RSSI%></div></td>
<td><div class="table2"><%=BW%></div></td>
<td><div class="table2"><%=rate%></div></td>
</tr>
</tbody>
</table>
</fieldset>

<script type="text/javascript">
function wifi_reload(url) {
Expand Down
8 changes: 8 additions & 0 deletions package/mt/luci-app-mtwifi/root/usr/lib/lua/mtkwifi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ function mtkwifi.read_pipe(pipe)
return txt
end

-- Associated Stations
dme = mtkwifi.read_pipe("dmesg -c > /dev/null && iwpriv ra0 show stainfo & iwpriv rai0 show stainfo & sleep 1") or "?"
MAC = mtkwifi.read_pipe("dmesg | grep -ioE '([a-z0-9]{2}:){5}..' 2>/dev/null") or "?"
RSSI = mtkwifi.read_pipe("dmesg | grep -ioE '([-0-9]{3}/){3}...' 2>/dev/null") or "?"
BW = mtkwifi.read_pipe("dmesg | grep -ioE '([0-9]{2,3}[a-z]{1}/).{3,4}' 2>/dev/null" ) or "?"
rate = mtkwifi.read_pipe("dmesg | grep -i -B 1 '0%' | grep -ioE '([0-9]{1,4}/[0-9]{1,4})' 2>/dev/null" ) or "?"

function mtkwifi.load_profile(path, raw)
local cfgs = {}
local content
Expand Down Expand Up @@ -538,6 +545,7 @@ function mtkwifi.__setup_apcli(cfgs, devname, mainidx, subidx)
end
apcli.devname = apcli_name
apcli.bssid = mtkwifi.read_pipe("iwconfig "..apcli_name.." | grep Point | sed 's/.*Point: //' 2>/dev/null") or "?"
apcli.rate = mtkwifi.read_pipe("iwconfig "..apcli_name.." | grep Rate= | sed 's/.*Rate=//' 2>/dev/null") or "?"
local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0
apcli.ifstatus = flags%2 == 1 and "up" or ""
return apcli
Expand Down

0 comments on commit 23d676a

Please sign in to comment.