[Bugfix][API-1369][API-1350][API-1349] fix status report when sta auto connect
Only Configure: No
Affected branch: GSW3.0-No-Connman
Affected module: wifi6
Is it affected on both ZXIC and MTK: only MTK
Self-test: Yes
Doc Update:No
Change-Id: Ib5b40f380e62a7c192569f6b34e48d808b872c93
diff --git a/lib/liblynq-wifi6/libwifi6.c b/lib/liblynq-wifi6/libwifi6.c
index 6802432..082f9bc 100755
--- a/lib/liblynq-wifi6/libwifi6.c
+++ b/lib/liblynq-wifi6/libwifi6.c
@@ -134,7 +134,7 @@
static pthread_cond_t s_global_check_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t s_global_check_mutex = PTHREAD_MUTEX_INITIALIZER;
-static inner_sta_status_s s_sta_status = INNER_STA_STATUS_INIT;
+volatile inner_sta_status_s s_sta_status = INNER_STA_STATUS_INIT;
static error_number_s s_sta_error_number = -1;
static char s_sta_current_connecting_ssid[64] = {0};
static struct timespec s_sta_connect_timeout;
@@ -510,6 +510,18 @@
return;
}
+ // youchen@2023-10-17 add for "not notify connect fail directly" begin
+ if (state == LYNQ_WIFI_STA_STATUS_CONNECT_FAIL)
+ {
+ s_sta_error_number = error_num;
+ s_sta_status = INNER_STA_STATUS_DISCONNECTED;
+ RLOGD("inner_check_connect_error line: %d, curr state %d, %d %d ------",__LINE__, state, s_sta_status, s_sta_error_number);
+ pthread_cond_signal(&s_global_check_cond);
+ pthread_mutex_unlock(&s_global_check_mutex);
+ return;
+ }
+ // youchen@2023-10-17 add for "not notify connect fail directly" end
+
if (state == LYNQ_WIFI_STATUS_EGNORE)
{
if (strstr(event_msg, try_associat_flag) != NULL && strstr(event_msg, s_sta_current_connecting_ssid) != NULL) //associating request ssid
@@ -527,12 +539,14 @@
if (s_sta_status >= INNER_STA_STATUS_ASSOCIATING && strstr(event_msg, "CTRL-EVENT-SSID-TEMP-DISABLED") != NULL && error_num != LYNQ_WAIT_CONNECT_ACTIVE)
{
s_sta_status = INNER_STA_STATUS_DISCONNECTED;
+ RLOGD("inner_check_connect_error line: %d, curr state %d, %d %d ------",__LINE__, state, s_sta_status, s_sta_error_number);
pthread_cond_signal(&s_global_check_cond);
}
}
else if (state == LYNQ_WIFI_STA_STATUS_CONNECT)
{
s_sta_status = INNER_STA_STATUS_CONNECTED;
+ RLOGD("inner_check_connect_error line: %d, curr state %d, %d %d ------",__LINE__, state, s_sta_status, s_sta_error_number);
pthread_cond_signal(&s_global_check_cond);
}
pthread_mutex_unlock(&s_global_check_mutex);
@@ -914,7 +928,8 @@
*error = LYNQ_PSW_ERROR;
*state = LYNQ_WIFI_STA_STATUS_CONNECT_FAIL;
// tmp fix sta autoconnect connect and disconnect
- if(tmpdisid != -1 && lynq_wifi_sta_stop_network(0,tmpdisid) != 0)
+ // you.chen@2023-10-17 only disable network during autoconnect
+ if(tmpdisid != -1 && s_sta_status == INNER_STA_STATUS_INIT && lynq_wifi_sta_stop_network(0,tmpdisid) != 0)
{
RLOGE("stop wlan0 network %d fail",tmpdisid);
}
@@ -1198,7 +1213,16 @@
continue;
}
get_state_error(msg_notify,&state,&error);
- notify_connect_status(state, error);
+ // youchen@2023-10-17 add for "not notify connect fail directly" begin
+ if (state == LYNQ_WIFI_STA_STATUS_CONNECT_FAIL)
+ {
+ notify_connect_status(LYNQ_WIFI_STA_STATUS_DISCONNECT, error);
+ }
+ else
+ {
+ notify_connect_status(state, error);
+ }
+ // youchen@2023-10-17 add for "not notify connect fail directly" end
if (state != LYNQ_WIFI_STA_STATUS_SCAN_RESULT)
{
@@ -1214,7 +1238,6 @@
system_call_v("%s %s", sta_status_change_script, "disconnect");
}
}
-
last_state = state;
}
}
@@ -1229,7 +1252,7 @@
size_t len = MAX_RET;
char msg_notify[MAX_RET];
error_number_s error;
- lynq_wifi_sta_status_s state, last_state = -1;
+ lynq_wifi_sta_status_s state;
int idle_count = 0;
int networkid;
struct wpa_ctrl *lynq_wpa_ctrl = NULL;
@@ -1257,22 +1280,6 @@
}
get_state_error_networkid(msg_notify,&state,&error,&networkid); // add net state error network function
notify_auto_connect_status(state, error,networkid);
- if (state != LYNQ_WIFI_STA_STATUS_SCAN_RESULT)
- {
- inner_check_connect_error(msg_notify, state, error);
- if (last_state != state)
- {
- if (state == LYNQ_WIFI_STA_STATUS_CONNECT)
- {
- system_call_v("%s %s", sta_status_change_script, "connect");
- }
- else if (state == LYNQ_WIFI_STA_STATUS_DISCONNECT)
- {
- system_call_v("%s %s", sta_status_change_script, "disconnect");
- }
- }
- last_state = state;
- }
}
}
if (lynq_wpa_ctrl != NULL)
@@ -3709,6 +3716,7 @@
system(lynq_reconnect_cmd);
pthread_mutex_lock(&s_global_check_mutex);
g_history_disconnect_valid_num = 0; //clean history_disconenct_list info
+ s_sta_status = INNER_STA_STATUS_INIT;
pthread_mutex_unlock(&s_global_check_mutex);
return 0;
}
@@ -3728,6 +3736,7 @@
int len;
pthread_mutex_lock(&s_global_check_mutex);
+ s_sta_status = INNER_STA_STATUS_INIT;
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 )