Add Wifi Client status info (#1362)

This commit is contained in:
Tim Wilkinson 2024-08-22 13:40:29 -07:00 committed by GitHub
parent d26b4abf3e
commit 3a0bbe0c3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View File

@ -108,10 +108,38 @@
</div>
{% }
if (widx !== -1) {
const r = radio[widx].modes[radios.RADIO_WAN]; %}
const r = radio[widx].modes[radios.RADIO_WAN];
let wconnected = false;
let winternet = false;
let f = fs.popen(`/usr/sbin/iw dev wlan${widx} link 2> /dev/null`);
if (f) {
const mssid = `SSID: ${r.ssid}`;
for (let l = f.read("line"); length(l); l = f.read("line")) {
if (index(l, mssid) !== -1) {
wconnected = true;
}
}
f.close();
}
if (wconnected) {
if (system(`/bin/ping -I wlan${widx} -W 1 -c 1 1.1.1.1 > /dev/null 2>&1`, 250) === 0) {
winternet = true;
}
}
%}
<div class="section-title">WAN Client</div>
<div class="section">
<div class="cols">
<div>
{% if (wconnected && winternet) { %}
<div class="t">internet</div>
{% } else if (wconnected) { %}
<div class="t">no internet</div>
{% } else { %}
<div class="t">no connection</div>
{% } %}
<div class="s">status</div>
</div>
<div style="flex:2">
<div class="t">{{r.ssid}}</div>
<div class="s">ssid</div>

View File

@ -1362,7 +1362,8 @@ do
if oc:get("wireless", "@wifi-iface[0]", "mode") ~= config_special.wifi_mode_0 or oc:get("wireless", "@wifi-iface[1]", "mode") ~= config_special.wifi_mode_1 then
-- Only start the hostapd (etc) if we need to. This doesn't change what is currently running
-- only what automatically runs in the future
if oc:get("wireless", "@wifi-iface[0]", "mode") == "ap" or oc:get("wireless", "@wifi-iface[1]", "mode") == "ap" then
if oc:get("wireless", "@wifi-iface[0]", "mode") == "ap" or oc:get("wireless", "@wifi-iface[1]", "mode") == "ap" or
oc:get("wireless", "@wifi-iface[0]", "mode") == "sta" or oc:get("wireless", "@wifi-iface[1]", "mode") == "sta" then
os.execute("/etc/init.d/wpad enable > /dev/null 2>&1")
else
os.execute("/etc/init.d/wpad disable > /dev/null 2>&1")