From 45b350c05ead444b9a5e051f271c3c1c112c451c Mon Sep 17 00:00:00 2001
From: Sukru Senli <sukru.senli@inteno.se>
Date: Mon, 30 Oct 2017 14:32:03 +0100
Subject: [PATCH] wifi: send credentials from first wifi network

---
 iopsys-brcm63xx-mips/base-files/sbin/wifi | 5 ++++-
 iopsys-ramips/base-files/sbin/wifi        | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/iopsys-brcm63xx-mips/base-files/sbin/wifi b/iopsys-brcm63xx-mips/base-files/sbin/wifi
index 339bc4b99..d3325db36 100755
--- a/iopsys-brcm63xx-mips/base-files/sbin/wifi
+++ b/iopsys-brcm63xx-mips/base-files/sbin/wifi
@@ -1001,7 +1001,10 @@ configure_wifi() {
 		# configure connected repeaters/extenders
 		for network in $(uci show network | grep "is_lan='1'" | grep -v loopback | cut -d'.' -f2); do
 			ubus call repeater get_creds '{"network":"'$network'","file":"/tmp/wificontrol.txt"}'
-			wificontrol --router -v 4 >/dev/console
+			grep -q ssid /tmp/wificontrol.txt && {
+				wificontrol --router -v 4 >/dev/console
+				break # do not continue with the rest of the networks
+			}
 		done
 	fi
 
diff --git a/iopsys-ramips/base-files/sbin/wifi b/iopsys-ramips/base-files/sbin/wifi
index e92a7d415..5924ae36c 100755
--- a/iopsys-ramips/base-files/sbin/wifi
+++ b/iopsys-ramips/base-files/sbin/wifi
@@ -702,7 +702,10 @@ else
 	killall -9 wificontrol >/dev/null 2>&1
 	for network in $(uci show network | grep "is_lan='1'" | grep -v loopback | cut -d'.' -f2); do
 		ubus call repeater get_creds '{"network":"'$network'","file":"/tmp/wificontrol.txt"}'
-		wificontrol --router -v 4 >/dev/console
+		grep -q ssid /tmp/wificontrol.txt && {
+			wificontrol --router -v 4 >/dev/console
+			break # do not continue with the rest of the networks
+		}
 	done
 fi
 
-- 
GitLab