Merge pull request #2009 from RaspAP/fix/security-open

Fix: Define constant for Open security protocol
This commit is contained in:
Bill Zimmerman
2025-11-23 09:53:20 +01:00
committed by GitHub
2 changed files with 8 additions and 3 deletions

View File

@@ -78,7 +78,7 @@ function DisplayWPAConfig()
$ok = true;
foreach ($tmp_networks as $ssid => $network) {
if ($network['protocol'] === 'Open') {
if ($network['protocol'] === $wifi::SECURITY_OPEN) {
fwrite($wpa_file, "network={".PHP_EOL);
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
fwrite($wpa_file, "\tkey_mgmt=NONE".PHP_EOL);

View File

@@ -16,6 +16,7 @@ class WiFiManager
private const MIN_RSSI = -100;
private const MAX_RSSI = -55;
const SECURITY_OPEN = 'OPEN';
public function knownWifiStations(&$networks)
{
@@ -127,7 +128,7 @@ class WiFiManager
$networks[$ssid] = [
'ssid' => $ssid,
'configured' => false,
'protocol' => $current['security'] ?? 'OPEN',
'protocol' => $current['security'] ?? self::SECURITY_OPEN,
'channel' => $channel,
'passphrase' => '',
'visible' => true,
@@ -138,6 +139,10 @@ class WiFiManager
++$index;
}
};
if (is_string($scan_results)) {
$scan_results = explode("\n", trim($scan_results));
}
foreach ($scan_results as $line) {
$line = trim($line);
@@ -149,7 +154,7 @@ class WiFiManager
'ssid' => '',
'signal' => null,
'freq' => null,
'security' => 'OPEN'
'security' => self::SECURITY_OPEN
];
continue;
}