[BugFix][API-1227 1224]fix sta didn't connect after run lynq_wifi_sta_start_auto & lynq_wifi_sta_disconenct_ap fail
Only Configure
Affected branch:MR3.0-xx && GSW3.0
Affected module:wifi
Is it addected on both ZXIC and MTK: only MTK
Self-test: Yes
Doc Update: YES
Change-Id: I1f4443b8d7f2b370cd9c8383a910014c43fbf894
diff --git a/lib/liblynq-wifi6/libwifi6.c b/lib/liblynq-wifi6/libwifi6.c
index 476be41..53b6704 100755
--- a/lib/liblynq-wifi6/libwifi6.c
+++ b/lib/liblynq-wifi6/libwifi6.c
@@ -31,7 +31,6 @@
#ifdef __cplusplus
}
#endif
-
#undef LOG_TAG
#define LOG_TAG "LYNQ_WIFI"
#define MAX_CMD 128
@@ -97,6 +96,8 @@
pthread_mutex_t mutex;
};
+int g_history_disconnect_valid_num = 0;
+int g_history_disconnect_net[128];
static pthread_mutex_t s_check_wpa_ctrl_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t s_sta_callback_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -537,6 +538,13 @@
pthread_mutex_unlock(&s_global_check_mutex);
}
+static int lynq_split(char * str, int len, char delimiter, char * results[]);
+static inline char inner_convert_char(char in);
+static inline void inner_copy_ssid(char * out_ssid, const char * ssid, size_t out_ssid_len);
+static int lynq_get_network_number_list(lynq_wifi_index_e idx, int ap_sta, int net_no_list[], char * ssid);
+
+
+
/*
just tmp add for fix sta connect ap fail check ap connect info
return 0 --->Current no sta device connect this AP
@@ -770,12 +778,79 @@
sprintf(LYNQ_DISABLE_CMD,"DISABLE_NETWORK %d",networkid);
RLOGD("LYNQ_DISABLE_CMD is:%d\n",LYNQ_DISABLE_CMD);
DO_OK_FAIL_REQUEST(LYNQ_DISABLE_CMD);
- DO_OK_FAIL_REQUEST(cmd_save_config);
return 0;
}
+static int lynq_wifi_sta_enable_network(lynq_wifi_index_e idx,int networkid)
+{
+ char LYNQ_ENABLE_CMD[128]={0};
+
+ CHECK_IDX(idx, CTRL_STA);
+ CHECK_WPA_CTRL(CTRL_STA);
+
+
+ sprintf(LYNQ_ENABLE_CMD,"ENABLE_NETWORK %d",networkid);
+ RLOGD("LYNQ_ENABLE_CMD is:%d\n",LYNQ_ENABLE_CMD);
+ DO_OK_FAIL_REQUEST(LYNQ_ENABLE_CMD);
+
+ return 0;
+
+}
+
+static int lynq_tmp_enable_network(lynq_wifi_index_e idx,int net_no_list[],int len)
+{
+
+ int index,networkid;
+
+ for ( index = 0; index < len ;index++)
+ {
+ networkid = net_no_list[index];
+ if( lynq_wifi_sta_enable_network(idx,networkid != 0) )
+ {
+ RLOGE("[wifi]lynq_tmp_enable_network id is %d fail",networkid);
+ }
+ RLOGD("[wifi]lynq_tmp_enable_network id is %d",networkid);
+ }
+ return 0;
+
+}
+
+
+/*
+ dis_net_list user disconnect list
+*/
+static void lynq_two_arr_merge(int dis_net_list[],int valid_num,int out[],int * outlen)
+{
+ int count,ncount,index;
+ int flag = 0;
+ int merge_index = 0;
+ int net_no_list[128];
+
+ index =lynq_get_network_number_list(0, 0, net_no_list,NULL);
+ for( count = 0; count < index; count++)
+ {
+ for(ncount = 0; ncount < valid_num; ncount++)
+ {
+ if(net_no_list[count] == dis_net_list[ncount])
+ {
+ RLOGD("[wifi]this is history disconnect idx ----> ",net_no_list[count]);
+ flag = 1;
+ break;
+ }
+ }
+ if( flag != 1 )
+ {
+ out[merge_index] = net_no_list[count];
+ merge_index ++;
+ }
+ flag = 0;
+ }
+ * outlen =merge_index;
+ RLOGD("[wifi]lynq_two_arr_merge get len is -----> %d",* outlen);
+ return;
+}
void get_state_error(const char* modify, lynq_wifi_sta_status_s* state, error_number_s* error)
{
@@ -1386,6 +1461,7 @@
g_ap_tmp_watcher_pid = 0;
g_lynq_wpa_ctrl[0] = NULL;
g_lynq_wpa_ctrl[1] = NULL;
+ g_history_disconnect_valid_num = 0; //clean history_disconenct_list info
system("systemctl stop wg870_drv_insmod.service");
pthread_mutex_unlock(&s_check_wpa_ctrl_mutex);
return 0;
@@ -2449,9 +2525,9 @@
printf("inner_check_ap_connected %d\n", retry_count);
usleep(250*1000);
- if (0 == inner_get_status_info(idx, &curr_state))
+ if ((strcmp(status, STATE_SCANNING) == 0)|| (strcmp(status, STATE_COMPLETED) == 0))
{
- if ((strcmp(status, STATE_SCANNING) == 0)|| (strcmp(status, STATE_COMPLETED) == 0))
+ if (strcmp(status, STATE_COMPLETED) == 0)
{
return 0;
}
@@ -2482,7 +2558,9 @@
{
RLOGD("[lynq_wifi]----enter lynq_wifi_ap_start");
char LYNQ_WIFI_CMD[128]={0};
-
+ //const char *lynq_remove_all_cmd = "REMOVE_NETWORK all";
+ //const char *lynq_reconfig_cmd = "RECONFIGURE /data/wifi/wg870/wpa_supplicant.conf";
+ RLOGD("enter lynq_wifi_ap_channel_get");
CHECK_IDX(idx, CTRL_AP);
CHECK_WPA_CTRL(CTRL_AP);
@@ -2493,6 +2571,9 @@
return -1;
}
+ //DO_OK_FAIL_REQUEST(lynq_remove_all_cmd);
+ //DO_OK_FAIL_REQUEST(lynq_reconfig_cmd);
+
sprintf(LYNQ_WIFI_CMD,"SELECT_NETWORK %d",AP_NETWORK_0);
DO_OK_FAIL_REQUEST(LYNQ_WIFI_CMD);
@@ -2520,6 +2601,7 @@
RLOGD("[lynq_wifi_ap_start] creat APTmpWatcherThreadProc ok");
}
RLOGD("[lynq_wifi]----end lynq_wifi_ap_start");
+
return 0;
}
@@ -3274,7 +3356,7 @@
sprintf(lynq_pairwise_cmd,"SET_NETWORK %d pairwise CCMP", net_no);
sprintf(lynq_psk_cmd, "SET_NETWORK %d psk \"%s\"", net_no, password);
- DO_OK_FAIL_REQUEST(lynq_auth_cmd);
+ DO_OK_FAIL_REQUEST(lynq_auth_cmd);
DO_OK_FAIL_REQUEST(lynq_ket_mgmt_cmd);
DO_OK_FAIL_REQUEST(lynq_pairwise_cmd);
DO_OK_FAIL_REQUEST(lynq_psk_cmd);
@@ -3508,6 +3590,8 @@
pthread_mutex_lock(&s_global_check_mutex);
s_sta_status = INNER_STA_STATUS_DISCONNECTING;
+ g_history_disconnect_net[g_history_disconnect_valid_num] = curr_state.net_no;
+ g_history_disconnect_valid_num++;
pthread_mutex_unlock(&s_global_check_mutex);
return lynq_wifi_sta_stop_network(idx, curr_state.net_no);
@@ -3516,8 +3600,7 @@
int lynq_wifi_sta_start(lynq_wifi_index_e idx)
{
-// const char *lynq_reconfigure_cmd = "wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 RECONFIGURE /data/wifi/wg870/wpa_supplicant.conf";
-// const char *lynq_reconnect_cmd = "RECONNECT";
+
const char *lynq_enable_sta_cmd = "wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 enable_net all";
const char *lynq_reconnect_cmd = "wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 reconnect";
@@ -3533,7 +3616,9 @@
system(lynq_enable_sta_cmd);
system(lynq_reconnect_cmd);
-// DO_OK_FAIL_REQUEST(lynq_reconnect_cmd);
+ pthread_mutex_lock(&s_global_check_mutex);
+ g_history_disconnect_valid_num = 0; //clean history_disconenct_list info
+ pthread_mutex_unlock(&s_global_check_mutex);
return 0;
}
@@ -3547,21 +3632,19 @@
int lynq_wifi_sta_start_auto(lynq_wifi_index_e idx)
{
- const char *lynq_reconnect_cmd = "wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 reconnect";
+ RLOGD("[wifi]enter lynq_wifi_sta_start_auto start");
+ int tmp_open_idx[128];
+ int len;
- CHECK_IDX(idx, CTRL_STA);
- CHECK_WPA_CTRL(CTRL_STA);
-
- ret = system_call_v("%s %s", start_stop_sta_script, "start");
- if (ret != 0)
+ pthread_mutex_lock(&s_global_check_mutex);
+ lynq_two_arr_merge(g_history_disconnect_net,g_history_disconnect_valid_num,tmp_open_idx,&len);
+ pthread_mutex_unlock(&s_global_check_mutex);
+ if(lynq_tmp_enable_network(idx,tmp_open_idx,len) != 0 )
{
- RLOGE("lynq_wifi_ap_start excute script fail");
- return -1;
+ RLOGD("[wifi]lynq_tmp_enable_network error");
}
-// system(lynq_enable_sta_cmd);
- system(lynq_reconnect_cmd);
-
+ RLOGD("[wifi]enter lynq_wifi_sta_start_auto end");
return 0;
}
@@ -3603,7 +3686,9 @@
RLOGD("lynq_wifi_ap_start curr state %s", state);
usleep(SLEEP_TIME_ON_IDLE);
}
-
+ pthread_mutex_lock(&s_global_check_mutex);
+ g_history_disconnect_valid_num = 0; //clean history_disconenct_list info
+ pthread_mutex_unlock(&s_global_check_mutex);
return 0;
// return system("connmanctl disable wifi");
}