diff --git a/htdocs/inc.setWifi.php b/htdocs/inc.setWifi.php
index b7b56f6e8..691e8a247 100755
--- a/htdocs/inc.setWifi.php
+++ b/htdocs/inc.setWifi.php
@@ -42,7 +42,7 @@
/*
* get all configured wifis
*/
-$network_confs_shell = shell_exec("sudo bash -c 'source ".$conf['scripts_abs']."/helperscripts/inc.networkHelper.sh && get_all_wireless_networks'");
+$network_confs_shell = shell_exec("sudo bash -c 'source ".$conf['scripts_abs']."/helperscripts/inc.networkHelper.sh && get_wireless_networks'");
$network_confs = explode(' ',$network_confs_shell);
$networks = array();
@@ -50,17 +50,25 @@
unset($temp_ssid);
unset($temp_pass);
unset($temp_prio);
+ unset($temp_active);
$network_conf = explode(':',$line);
$temp_ssid = trim($network_conf[0]);
$temp_pass = trim($network_conf[1]);
$temp_prio = trim($network_conf[2]);
+ $temp_active = isset($active_essid) && $temp_ssid == $active_essid;
if(isset($temp_ssid) && $temp_ssid != "" && isset($temp_pass) && $temp_pass != "") {
if(!isset($temp_prio) || !is_numeric($temp_prio)) {
$temp_prio = 0;
}
- $networks[] = array($temp_ssid, $temp_pass, $temp_prio);
+ $temp_entry = array($temp_ssid => [ $temp_pass, $temp_prio, $temp_active ]);
+ # use different methods to have the same behavior: the data of the first appearance are kept, following will be ignored
+ if($temp_active) {
+ $networks = array_merge($temp_entry, $networks);
+ } else {
+ $networks = $networks + $temp_entry;
+ }
}
}
unset($temp_ssid);
@@ -89,12 +97,12 @@
?>
$WIFIconf ) {
- $WIFIssid = $WIFIconf[0];
- $WIFIpass = $WIFIconf[1];
- $WIFIprio = $WIFIconf[2];
- $WIFIactive = isset($active_essid) && $WIFIssid == $active_essid;
+ $network_index = 0;
+ foreach ( $networks as $WIFIssid => $WIFIconf ) {
+ $WIFIpass = $WIFIconf[0];
+ $WIFIprio = $WIFIconf[1];
+ $WIFIactive = $WIFIconf[2];
+ $WIFIindex = $network_index++;
?>
-
@@ -146,27 +154,27 @@
diff --git a/scripts/helperscripts/inc.networkHelper.sh b/scripts/helperscripts/inc.networkHelper.sh
index ff18aa44a..be890f088 100644
--- a/scripts/helperscripts/inc.networkHelper.sh
+++ b/scripts/helperscripts/inc.networkHelper.sh
@@ -39,8 +39,8 @@ clear_wireless_networks() {
fi
if [[ $(is_NetworkManager_enabled) == true ]]; then
- nmcli -g NAME,TYPE,ACTIVE connection show | grep "^.*:.*:no$" | grep -F "wireless" | cut -d : -f 1 | \
- while read name; do sudo nmcli connection delete "$name"; done
+ nmcli -g UUID,TYPE,ACTIVE connection show | grep "^.*:.*:no$" | grep -F "wireless" | cut -d : -f 1 | \
+ while read uuid; do sudo nmcli connection delete "$uuid"; done
fi
}
@@ -73,7 +73,7 @@ add_wireless_network() {
}
# gets the configured wireless networks. Returns an array with the format "ssid:pass:prio ssid:pass:prio".
-get_all_wireless_networks() {
+get_wireless_networks() {
networks=()
if [[ $(is_dhcpcd_enabled) == true ]]; then
@@ -91,7 +91,7 @@ get_all_wireless_networks() {
fi
if [[ $(is_NetworkManager_enabled) == true ]]; then
- local network_profiles=$(nmcli -g NAME,TYPE connection show | grep -F "wireless" | cut -d : -f 1)
+ local network_profiles=$(nmcli -g UUID,TYPE connection show | grep -F "wireless" | cut -d : -f 1)
for network_profile in $network_profiles
do