Merge "[Bugfix][API-820][wifi] fix get connected ap's ip" into GSW3.0-No-Connman
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/suspend-service/files/autosuspend_wakeup_count.c b/meta/meta-mediatek-mt2735/recipes-lynq/suspend-service/files/autosuspend_wakeup_count.c
index 6a9827a..db652dc 100755
--- a/meta/meta-mediatek-mt2735/recipes-lynq/suspend-service/files/autosuspend_wakeup_count.c
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/suspend-service/files/autosuspend_wakeup_count.c
@@ -249,7 +249,7 @@
     lseek(wakeup_count_fd, 0, SEEK_SET);
     system("echo \"autosuspend:Sys seek\" >/dev/console");
     
-    RLOGD("suspend_ctrl: start write wakkeup_count\n");
+    RLOGD("suspend_ctrl: start read wakkeup_count\n");
     wakeup_count_len = TEMP_FAILURE_RETRY(read(wakeup_count_fd, wakeup_count,
                sizeof(wakeup_count)));
     if (wakeup_count_len < 0) {
@@ -258,7 +258,14 @@
             wakeup_count_len = 0;
             return -1;
      }
-
+    
+    RLOGD("suspend_ctrl: start write wakkeup_count\n");
+    ret = write(wakeup_count_fd, wakeup_count, wakeup_count_len);
+    if (ret < 0) {
+            strerror_r(errno, buf, sizeof(buf));
+            RLOGD("Error writing to %s: %s\n", SYS_POWER_WAKEUP_COUNT,buf);
+            return -1;
+        }
     system("echo \"autosuspend:Sys suspend\" >/dev/console");
     RLOGD("suspend_ctrl: start write reg_netsys\n");
     for(int i = 0;i < 5;i++)  //notify spm (other core) to handle pre-sleep configuration
diff --git a/src/lynq/lib/liblynq-wifi6/libwifi6.c b/src/lynq/lib/liblynq-wifi6/libwifi6.c
index 9529e2c..2bfbd1e 100755
--- a/src/lynq/lib/liblynq-wifi6/libwifi6.c
+++ b/src/lynq/lib/liblynq-wifi6/libwifi6.c
@@ -40,6 +40,7 @@
 #define CTRL_STA 0
 #define CTRL_AP 1
 #define AP_NETWORK_0 0
+#define STA_MAX_SAVED_AP_NUM 50
 
 pthread_t g_ap_watcher_pid = 0;
 volatile int g_ap_watcher_stop_flag = 0;
@@ -2676,6 +2677,7 @@
 {
     int count, net_no, index;
     int net_no_list[128];
+    char rm_net_cmd[128];
     lynq_wifi_auth_s net_auth;
     curr_status_info curr_state;
     ap_info_s ap_info;
@@ -2750,6 +2752,13 @@
 
         if (net_no < 0)
         {
+            count = lynq_get_network_number_list(idx, CTRL_STA, net_no_list, NULL);
+            for ( index = 0; index < (count - STA_MAX_SAVED_AP_NUM + 1 ) ;index++)       //+1 is for add new network
+            {
+                sprintf(rm_net_cmd,"REMOVE_NETWORK %d",net_no_list[index]);
+                RLOGD("call cmd rm_net_cmd: %s;index is %d\n",rm_net_cmd,index);
+                DO_OK_FAIL_REQUEST(rm_net_cmd);
+            }
             net_no = lynq_add_network(CTRL_STA);
             if (net_no == -1)
             {