diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index 07cff7675..fb8e8611c 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -64,8 +64,8 @@ function enable_wifi(state) { $('input[name="#arg[1]"]').val(state); } -function update_wifi() { - $.post('/webGui/include/Wireless.php',{cmd:'list'},function(text) { +function update_wifi(load) { + $.post('/webGui/include/Wireless.php',{cmd:'list',load:load},function(text) { if (text.length > 0) { var wifi = JSON.parse(text); $('#connected').html(wifi.active); @@ -73,7 +73,7 @@ function update_wifi() { $('#other_networks').html(wifi.other); } }); - timers.wifi = setTimeout(update_wifi,10000); + timers.wifi = setTimeout(update_wifi,5000); } function manage_wifi(ssid,task) { @@ -146,7 +146,7 @@ function showSecurity(val) { $(function() { $('#wifi').show(); - update_wifi(); + update_wifi(1); }); diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 54e82c1a8..87fdcac7f 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -74,14 +74,27 @@ function saveAttr() { switch ($cmd) { case 'list': + $load = $_POST['load'] ?? false; $title = _('Connect to WiFi network'); $port = array_key_first($wifi); $carrier = "/sys/class/net/$port/carrier"; - $wlan = scanWifi($port); $echo = []; $index = 0; + if ($load && count(array_keys($wifi)) > 1) { + foreach ($wifi as $network => $block) { + if ($network == $port) continue; + $wlan[$index]['bss'] = $block['ATTR1']; + $wlan[$index]['signal'] = $block['ATTR2']; + $wlan[$index]['security'] = $block['ATTR3'] ?? $block['SECURITY']; + $wlan[$index]['ssid'] = $network; + $index++; + } + $index = 0; + } else { + $wlan = scanWifi($port); + } if (count(array_column($wlan,'ssid'))) { - $up = file_exists($carrier) && file_get_contents($carrier)==1; + $up = is_readable($carrier) && file_get_contents($carrier)==1; $alive = $up ? exec("iw ".escapeshellarg($port)." link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; $state = $up ? _('Connected') : _('Disconnected'); $color = $up ? 'blue' : 'red'; diff --git a/emhttp/plugins/dynamix/nchan/wlan0 b/emhttp/plugins/dynamix/nchan/wlan0 index 543086726..5ec3e1b08 100755 --- a/emhttp/plugins/dynamix/nchan/wlan0 +++ b/emhttp/plugins/dynamix/nchan/wlan0 @@ -53,10 +53,12 @@ while (true) { $locale_init = _var($display,'locale'); update_translation($locale_init); } - if (file_exists($ini) && file_exists($wlan0)) { + if (is_readable($ini) && is_readable($wlan0)) { + $wifi = parse_ini_file($ini); $up = file_get_contents($wlan0)==1; - $echo['color'] = $up ? 'blue-text' : 'red-text'; - $echo['title'] = $up ? _('WiFi connected') : _('WiFi disconnected'); + $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; + $echo['color'] = $alive==$wifi['SSID'] ? 'blue-text' : 'red-text'; + $echo['title'] = $alive==$wifi['SSID'] ? _('WiFi connected') : _('WiFi disconnected'); } else { $echo['color'] = 'grey-text'; $echo['title'] = _('No active WiFi');