1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-08 19:47:41 +02:00

Fix: Cleanup, resolve warnings in getWifiInterface()

This commit is contained in:
billz 2025-03-20 02:10:40 -07:00
parent 4e411aaa6b
commit f73f25708c

View File

@ -160,19 +160,20 @@ function sortNetworksByRSSI(&$networks)
*/
function getWifiInterface()
{
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
$iface = $_SESSION['ap_interface'] = isset($arrHostapdConf['WifiInterface']) ? $arrHostapdConf['WifiInterface'] : RASPI_WIFI_AP_INTERFACE;
// check for 2nd wifi interface -> wifi client on different interface
exec("iw dev | awk '$1==\"Interface\" && $2!=\"$iface\" {print $2}'",$iface2);
$client_iface = $_SESSION['wifi_client_interface'] = (empty($iface2) ? $iface : trim($iface2[0]));
$hostapdIni = RASPI_CONFIG . '/hostapd.ini';
$arrHostapdConf = file_exists($hostapdIni) ? parse_ini_file($hostapdIni) : [];
// specifically for rpi0W in AP-STA mode, the above check ends up with the interfaces
// crossed over (wifi_client_interface vs 'ap_interface'), because the second interface (uap0) is
// created by raspap and used as the access point.
if ($client_iface == "uap0" && ($arrHostapdConf['WifiAPEnable'] ?? 0)){
$_SESSION['wifi_client_interface'] = $iface;
$_SESSION['ap_interface'] = $client_iface;
}
$iface = $_SESSION['ap_interface'] = $arrHostapdConf['WifiInterface'] ?? RASPI_WIFI_AP_INTERFACE;
// check for 2nd wifi interface -> wifi client on different interface
exec("iw dev | awk '$1==\"Interface\" && $2!=\"$iface\" {print $2}'", $iface2);
$client_iface = $_SESSION['wifi_client_interface'] = empty($iface2) ? $iface : trim($iface2[0]);
// handle special case for RPi Zero W in AP-STA mode
if ($client_iface === "uap0" && ($arrHostapdConf['WifiAPEnable'] ?? 0)) {
$_SESSION['wifi_client_interface'] = $iface;
$_SESSION['ap_interface'] = $client_iface;
}
}
/*