mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-22 07:30:23 +00:00
Applied patches from #581
This commit is contained in:
parent
ceaa7a3511
commit
b128c4106c
4 changed files with 47 additions and 19 deletions
|
@ -13,5 +13,6 @@ $ssid = null;
|
||||||
knownWifiStations($networks);
|
knownWifiStations($networks);
|
||||||
nearbyWifiStations($networks, !isset($_REQUEST["refresh"]));
|
nearbyWifiStations($networks, !isset($_REQUEST["refresh"]));
|
||||||
connectedWifiStations($networks);
|
connectedWifiStations($networks);
|
||||||
|
sortNetworksByRSSI($networks);
|
||||||
|
|
||||||
echo renderTemplate('wifi_stations', compact('networks'));
|
echo renderTemplate('wifi_stations', compact('networks'));
|
||||||
|
|
|
@ -94,6 +94,7 @@ function DisplayWPAConfig()
|
||||||
|
|
||||||
nearbyWifiStations($networks);
|
nearbyWifiStations($networks);
|
||||||
connectedWifiStations($networks);
|
connectedWifiStations($networks);
|
||||||
|
sortNetworksByRSSI($networks);
|
||||||
|
|
||||||
echo renderTemplate("configure_client", compact("status"));
|
echo renderTemplate("configure_client", compact("status"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,26 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// get the name of the AP - should be excluded von the nearby networks
|
||||||
|
exec('cat '.RASPI_HOSTAPD_CONFIG.' | sed -rn "s/ssid=(.*)\s*$/\1/p" ',$ap_ssid);
|
||||||
|
$ap_ssid = $ap_ssid[0];
|
||||||
|
|
||||||
foreach (explode("\n", $scan_results) as $network) {
|
foreach (explode("\n", $scan_results) as $network) {
|
||||||
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
||||||
|
if (!array_key_exists(4, $arrNetwork) ||
|
||||||
|
trim($arrNetwork[4]) == $ap_ssid) continue;
|
||||||
|
|
||||||
|
$ssid = trim($arrNetwork[4]);
|
||||||
|
// filter SSID string - anything invisable in 7bit ASCII or quotes -> ignore network
|
||||||
|
if( preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]',$ssid)) continue;
|
||||||
|
|
||||||
// If network is saved
|
// If network is saved
|
||||||
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) {
|
if (array_key_exists($ssid, $networks)) {
|
||||||
$networks[$arrNetwork[4]]['visible'] = true;
|
$networks[$ssid]['visible'] = true;
|
||||||
$networks[$arrNetwork[4]]['channel'] = ConvertToChannel($arrNetwork[1]);
|
$networks[$ssid]['channel'] = ConvertToChannel($arrNetwork[1]);
|
||||||
// TODO What if the security has changed?
|
// TODO What if the security has changed?
|
||||||
} else {
|
} else {
|
||||||
$networks[$arrNetwork[4]] = array(
|
$networks[$ssid] = array(
|
||||||
'configured' => false,
|
'configured' => false,
|
||||||
'protocol' => ConvertToSecurity($arrNetwork[3]),
|
'protocol' => ConvertToSecurity($arrNetwork[3]),
|
||||||
'channel' => ConvertToChannel($arrNetwork[1]),
|
'channel' => ConvertToChannel($arrNetwork[1]),
|
||||||
|
@ -82,10 +92,12 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save RSSI
|
// Save RSSI, if the current value is larger than the already stored
|
||||||
if (array_key_exists(4, $arrNetwork)) {
|
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4],$networks)) {
|
||||||
$networks[$arrNetwork[4]]['RSSI'] = $arrNetwork[2];
|
if(! array_key_exists('RSSI',$networks[$arrNetwork[4]]) || $networks[$ssid]['RSSI'] < $arrNetwork[2])
|
||||||
|
$networks[$ssid]['RSSI'] = $arrNetwork[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,3 +110,18 @@ function connectedWifiStations(&$networks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sortNetworksByRSSI(&$networks) {
|
||||||
|
$valRSSI = array();
|
||||||
|
foreach ($networks as $SSID => $net) {
|
||||||
|
if (!array_key_exists('RSSI',$net)) $net['RSSI'] = -1000;
|
||||||
|
$valRSSI[$SSID] = $net['RSSI'];
|
||||||
|
}
|
||||||
|
$nets = $networks;
|
||||||
|
arsort($valRSSI);
|
||||||
|
$networks = array();
|
||||||
|
foreach ($valRSSI as $SSID => $RSSI) {
|
||||||
|
$networks[$SSID] = $nets[$SSID];
|
||||||
|
$networks[$SSID]['RSSI'] = $RSSI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -40,16 +40,15 @@
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("RSSI"); ?></div>
|
<div class="info-item-wifi"><?php echo _("RSSI"); ?></div>
|
||||||
<div>
|
<div>
|
||||||
<?php echo htmlspecialchars($network['RSSI'], ENT_QUOTES);
|
<?php
|
||||||
|
if (isset($network['RSSI']) && $network['RSSI'] >= -200 ) {
|
||||||
|
echo htmlspecialchars($network['RSSI'], ENT_QUOTES);
|
||||||
echo "dB (";
|
echo "dB (";
|
||||||
if ($network['RSSI'] >= -50) {
|
if ($network['RSSI'] >= -50) echo 100;
|
||||||
echo 100;
|
elseif ($network['RSSI'] <= -100) echo 0;
|
||||||
} elseif ($network['RSSI'] <= -100) {
|
else echo 2*($network['RSSI'] + 100);
|
||||||
echo 0;
|
|
||||||
} else {
|
|
||||||
echo 2*($network['RSSI'] + 100);
|
|
||||||
}
|
|
||||||
echo "%)";
|
echo "%)";
|
||||||
|
} else echo " not found ";
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue