mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Merge branch 'zbchristian-wlan-switch' of https://github.com/billz/raspap-webgui into zbchristian-wlan-switch
This commit is contained in:
@@ -95,6 +95,7 @@ function DisplayWPAConfig()
|
||||
|
||||
nearbyWifiStations($networks);
|
||||
connectedWifiStations($networks);
|
||||
sortNetworksByRSSI($networks);
|
||||
|
||||
echo renderTemplate("configure_client", compact("status"));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ if (!defined('RASPI_CONFIG')) {
|
||||
}
|
||||
|
||||
$defaults = [
|
||||
'RASPI_VERSION' => '2.4',
|
||||
'RASPI_VERSION' => '2.4.1',
|
||||
'RASPI_CONFIG_NETWORKING' => RASPI_CONFIG.'/networking',
|
||||
'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth',
|
||||
'RASPI_WIFI_CLIENT_INTERFACE' => 'wlan0',
|
||||
|
||||
@@ -245,6 +245,9 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
$config.= 'vht_capab=[MAX-AMSDU-3839][SHORT-GI-80]'.PHP_EOL;
|
||||
$config.= 'vht_oper_chwidth=1'.PHP_EOL;
|
||||
$config.= 'vht_oper_centr_freq_seg0_idx=42'.PHP_EOL.PHP_EOL;
|
||||
} elseif ($_POST['hw_mode'] === 'w') {
|
||||
$config.= 'ieee80211w=2'.PHP_EOL;
|
||||
$config.= 'wpa_key_mgmt=WPA-EAP-SHA256'.PHP_EOL;
|
||||
} else {
|
||||
$config.= 'hw_mode='.$_POST['hw_mode'].PHP_EOL;
|
||||
$config.= 'ieee80211n=0'.PHP_EOL;
|
||||
|
||||
@@ -51,7 +51,12 @@ function RPiVersion()
|
||||
if (array_key_exists($rev, $revisions)) {
|
||||
return $revisions[$rev];
|
||||
} else {
|
||||
return 'Unknown Pi';
|
||||
exec('cat /proc/device-tree/model', $model);
|
||||
if (isset($model[0])) {
|
||||
return $model[0];
|
||||
} else {
|
||||
return 'Unknown Device';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,16 +64,30 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
}
|
||||
);
|
||||
|
||||
// get the name of the AP. Should be excluded from 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) {
|
||||
$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 invisible in 7bit ASCII or quotes -> ignore network
|
||||
if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If network is saved
|
||||
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) {
|
||||
$networks[$arrNetwork[4]]['visible'] = true;
|
||||
$networks[$arrNetwork[4]]['channel'] = ConvertToChannel($arrNetwork[1]);
|
||||
if (array_key_exists($ssid, $networks)) {
|
||||
$networks[$ssid]['visible'] = true;
|
||||
$networks[$ssid]['channel'] = ConvertToChannel($arrNetwork[1]);
|
||||
// TODO What if the security has changed?
|
||||
} else {
|
||||
$networks[$arrNetwork[4]] = array(
|
||||
$networks[$ssid] = array(
|
||||
'configured' => false,
|
||||
'protocol' => ConvertToSecurity($arrNetwork[3]),
|
||||
'channel' => ConvertToChannel($arrNetwork[1]),
|
||||
@@ -83,9 +97,11 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
);
|
||||
}
|
||||
|
||||
// Save RSSI
|
||||
if (array_key_exists(4, $arrNetwork)) {
|
||||
$networks[$arrNetwork[4]]['RSSI'] = $arrNetwork[2];
|
||||
// Save RSSI, if the current value is larger than the already stored
|
||||
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) {
|
||||
if (! array_key_exists('RSSI', $networks[$arrNetwork[4]]) || $networks[$ssid]['RSSI'] < $arrNetwork[2]) {
|
||||
$networks[$ssid]['RSSI'] = $arrNetwork[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,6 +116,24 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
function getWifiInterface()
|
||||
{
|
||||
if (empty($_SESSION['client_iface'])) {
|
||||
|
||||
Reference in New Issue
Block a user