Merge "[Feature][DATA][T8TSK-211]support the handle value of setup_data_call set to a valid value after timeout 2" into GSW3.0-No-Connman
diff --git a/src/lynq/lib/liblynq-wifi6/libwifi6.c b/src/lynq/lib/liblynq-wifi6/libwifi6.c
index 51b3ea2..4a3c6c9 100755
--- a/src/lynq/lib/liblynq-wifi6/libwifi6.c
+++ b/src/lynq/lib/liblynq-wifi6/libwifi6.c
@@ -1923,6 +1923,7 @@
 static int inner_check_ap_connected(lynq_wifi_index_e idx, int retry_count)
 {
     char status[64];
+    char LYNQ_WIFI_CMD[32]={0};
     curr_status_info curr_state;
 
     CHECK_WPA_CTRL(CTRL_AP);
@@ -1945,13 +1946,15 @@
             DO_REQUEST("RECONNECT");
             return inner_check_ap_connected(idx, retry_count+1);
         }
-        else if (retry_count > 10)
+        else if (retry_count > 20)
         {
             printf("retry 10 time\n");
             return -1;
         }
         else
         {
+            sprintf(LYNQ_WIFI_CMD,"SELECT_NETWORK %d",AP_NETWORK_0);
+            DO_REQUEST(LYNQ_WIFI_CMD);
             return inner_check_ap_connected(idx, retry_count+1);
         }
     }
diff --git a/src/lynq/lib/liblynq-wifi6/scripts/start_stop_ap.sh b/src/lynq/lib/liblynq-wifi6/scripts/start_stop_ap.sh
index 259aa01..25dd644 100755
--- a/src/lynq/lib/liblynq-wifi6/scripts/start_stop_ap.sh
+++ b/src/lynq/lib/liblynq-wifi6/scripts/start_stop_ap.sh
@@ -7,16 +7,20 @@
 		exit 1
 	fi
 	mkdir -p /run/wg870/dnsmasq.d
-	echo "port=0" > /run/wg870/dnsmasq.conf
-	echo "interface=ap0" >> /run/wg870/dnsmasq.conf
-	echo "listen-address=192.168.15.1" >> /run/wg870/dnsmasq.conf
-	echo "bind-interfaces"  >> /run/wg870/dnsmasq.conf
-	echo "localise-queries" >> /run/wg870/dnsmasq.conf
-	echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h"  >> /run/wg870/dnsmasq.conf
-	echo "dhcp-leasefile=/run/wg870/ap0.lease" >> /run/wg870/dnsmasq.conf
-	ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep
+	conf_file="/run/wg870/dnsmasq.conf"
+	echo "port=0" > $conf_file
+	echo "interface=ap0" >> $conf_file
+	echo "listen-address=192.168.15.1" >> $conf_file
+	echo "bind-interfaces"  >> $conf_file
+	echo "localise-queries" >> $conf_file
+	echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h"  >> $conf_file
+	echo "dhcp-option=3,192.168.15.1"  >> $conf_file
+	echo "dhcp-option=6,192.168.15.1"  >> $conf_file
+	echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h"  >> $conf_file
+	echo "dhcp-leasefile=/run/wg870/ap0.lease" >> $conf_file
+	ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep 
 	if [ $? != 0 ]; then
-		/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C /run/wg870/dnsmasq.conf -r /run/wg870
+		/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C $conf_file -r /run/wg870
 	fi
 
 elif [ "$1" == "stop" ]; then
diff --git a/src/lynq/lib/liblynq-wifi6/scripts/start_stop_sta.sh b/src/lynq/lib/liblynq-wifi6/scripts/start_stop_sta.sh
index 4fd9ef0..25ab126 100755
--- a/src/lynq/lib/liblynq-wifi6/scripts/start_stop_sta.sh
+++ b/src/lynq/lib/liblynq-wifi6/scripts/start_stop_sta.sh
@@ -8,17 +8,19 @@
 		ps -eo "%p %a" | grep "dhcpcd wlan0" | grep -v grep
 		if [ $? != 0 ];	then
 			echo "" > /tmp/wlan0_dhcpcd_router
-			echo "#!/bin/sh" > /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "if [ \"\$reason\" == \"BOUND\" -o \"\$reason\" == \"RENEW\" -o \"\$reason\" == \"REBIND\" ]; then" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "    if [ \"\$new_routers\" != \"\" ]; then" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "        for x in \$new_routers; do" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "            echo \"new_router \$x\" > /tmp/wlan0_dhcpcd_router" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "            ping -c2 \$x &" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "        done" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "    fi" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			echo "fi" >> /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			chmod +x /run/wg870/wlan0_dhcpcd_run_hooks.sh
-			dhcpcd wlan0 -t 0 -o domain_name_servers --noipv4ll -4 -B -G -c /run/wg870/wlan0_dhcpcd_run_hooks.sh &
+			mkdir -p /run/wg870/
+			hook_script="/run/wg870/wlan0_dhcpcd_run_hooks.sh"
+			echo "#!/bin/sh" > $hook_script
+			echo "if [ \"\$reason\" == \"BOUND\" -o \"\$reason\" == \"RENEW\" -o \"\$reason\" == \"REBIND\" ]; then" >> $hook_script
+			echo "    if [ \"\$new_routers\" != \"\" ]; then" >> $hook_script
+			echo "        for x in \$new_routers; do" >> $hook_script
+			echo "            echo \"new_router \$x\" > /tmp/wlan0_dhcpcd_router" >> $hook_script
+			echo "            ping -c2 \$x &" >> $hook_script
+			echo "        done" >> $hook_script
+			echo "    fi" >> $hook_script
+			echo "fi" >> $hook_script
+			chmod +x $hook_script
+			dhcpcd wlan0 -t 0 -o domain_name_servers --noipv4ll -4 -B -G -c $hook_script &
 		fi
 elif [ "$1" == "stop" ]; then
         ps -eo "%p %a" | grep "dhcpcd wlan0" | grep -v grep | awk '{print "kill "$1}' | sh