1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Merge pull request #53 from RaspAP/zbchristian-fix-wifi-client-connect

Zbchristian fix wifi client connect
This commit is contained in:
Bill Zimmerman 2021-11-24 00:13:00 +01:00 committed by GitHub
commit 872d76e9c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -6,9 +6,11 @@ function knownWifiStations(&$networks)
{ {
// Find currently configured networks // Find currently configured networks
exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $known_return); exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $known_return);
$index = 0;
foreach ($known_return as $line) { foreach ($known_return as $line) {
if (preg_match('/network\s*=/', $line)) { if (preg_match('/network\s*=/', $line)) {
$network = array('visible' => false, 'configured' => true, 'connected' => false); $network = array('visible' => false, 'configured' => true, 'connected' => false, 'index' => $index);
++$index;
} elseif (isset($network) && $network !== null) { } elseif (isset($network) && $network !== null) {
if (preg_match('/^\s*}\s*$/', $line)) { if (preg_match('/^\s*}\s*$/', $line)) {
$networks[$ssid] = $network; $networks[$ssid] = $network;
@ -68,6 +70,12 @@ function nearbyWifiStations(&$networks, $cached = true)
exec('cat '.RASPI_HOSTAPD_CONFIG.' | sed -rn "s/ssid=(.*)\s*$/\1/p" ', $ap_ssid); exec('cat '.RASPI_HOSTAPD_CONFIG.' | sed -rn "s/ssid=(.*)\s*$/\1/p" ', $ap_ssid);
$ap_ssid = $ap_ssid[0]; $ap_ssid = $ap_ssid[0];
$index = 0;
if ( !empty($networks) ) {
$lastnet = end($networks);
if ( isset($lastnet['index']) ) $index = $lastnet['index'] + 1;
}
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
@ -84,8 +92,6 @@ function nearbyWifiStations(&$networks, $cached = true)
continue; continue;
} }
$networks[$ssid]['ssid'] = $ssid;
// If network is saved // If network is saved
if (array_key_exists($ssid, $networks)) { if (array_key_exists($ssid, $networks)) {
$networks[$ssid]['visible'] = true; $networks[$ssid]['visible'] = true;
@ -93,13 +99,16 @@ function nearbyWifiStations(&$networks, $cached = true)
// TODO What if the security has changed? // TODO What if the security has changed?
} else { } else {
$networks[$ssid] = array( $networks[$ssid] = array(
'ssid' => $ssid,
'configured' => false, 'configured' => false,
'protocol' => ConvertToSecurity($arrNetwork[3]), 'protocol' => ConvertToSecurity($arrNetwork[3]),
'channel' => ConvertToChannel($arrNetwork[1]), 'channel' => ConvertToChannel($arrNetwork[1]),
'passphrase' => '', 'passphrase' => '',
'visible' => true, 'visible' => true,
'connected' => false 'connected' => false,
'index' => $index
); );
++$index;
} }
// Save RSSI, if the current value is larger than the already stored // Save RSSI, if the current value is larger than the already stored

View File

@ -14,12 +14,11 @@
</div> </div>
<?php endif ?> <?php endif ?>
<?php $index = 0; ?>
<?php if (!empty($connected)): ?> <?php if (!empty($connected)): ?>
<h4 class="h-underlined my-3"><?php echo _("Connected") ?></h4> <h4 class="h-underlined my-3"><?php echo _("Connected") ?></h4>
<div class="card-grid"> <div class="card-grid">
<?php foreach ($connected as $network) : ?> <?php foreach ($connected as $network) : ?>
<?php $index = isset($network['index']) ? $network['index'] : -1; ?>
<?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?> <?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?>
<?php $index++; ?> <?php $index++; ?>
<?php endforeach ?> <?php endforeach ?>
@ -30,6 +29,7 @@
<h4 class="h-underlined my-3"><?php echo _("Known") ?></h4> <h4 class="h-underlined my-3"><?php echo _("Known") ?></h4>
<div class="card-grid"> <div class="card-grid">
<?php foreach ($known as $network) : ?> <?php foreach ($known as $network) : ?>
<?php $index = isset($network['index']) ? $network['index'] : -1; ?>
<?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?> <?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?>
<?php $index++; ?> <?php $index++; ?>
<?php endforeach ?> <?php endforeach ?>
@ -40,6 +40,7 @@
<h4 class="h-underlined my-3"><?php echo _("Nearby") ?></h4> <h4 class="h-underlined my-3"><?php echo _("Nearby") ?></h4>
<div class="card-grid"> <div class="card-grid">
<?php foreach ($nearby as $network) : ?> <?php foreach ($nearby as $network) : ?>
<?php $index = isset($network['index']) ? $network['index'] : -1; ?>
<?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?> <?php echo renderTemplate("wifi_stations/network", compact('network', 'index')) ?>
<?php $index++; ?> <?php $index++; ?>
<?php endforeach ?> <?php endforeach ?>