[BugFix][T106][bug-view-74][WIFI] If the customer switches the WIFI repeatedly, the WiFi will be stuck, and the AT can not be used
Only Configure: Yes
Affected branch: master
Affected module: wifi
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update:Yes
Change-Id: If6525e427b146c9a600cee5b1fc50fb807351eb5
(cherry picked from commit f4578ce5e9fce9facc3e7a2e31aacd8ce4fd069f)
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
index c444199..8c7d6c2 100644
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/lynq-qser-wifi.cpp
@@ -11,10 +11,13 @@
#include "sc_tel_types.h"
#include "sc_wifi.h"
#include "lynq-qser-wifi.h"
+#define WIFI_ENABLE_FLAG_TIME_OUT 10
+#define WIFI_ENABLE_FLAG_DEFAULT -100
static lynq_wifi_event_handle wifi_event_handle = NULL;
static lynq_wifi_event_handle_sta wifi_event_handle_sta = NULL;
static void *global_arg = NULL;
+static int wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
/********************************************************************
* @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform
@@ -198,7 +201,8 @@
*********************************************************************/
static void lynq_user_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status)
{
- LYINFLOG("%s:%d,%d\n", __func__, pre_status, status);
+ wifi_enable_flag = status;
+ LYINFLOG("%s:%d,%d wifi_enable_flag:%d\n", __func__, pre_status, status, wifi_enable_flag);
}
/********************************************************************
@@ -474,6 +478,7 @@
*********************************************************************/
int qser_wifi_enable(void)
{
+ wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
char wifiAvailable[8] = {0};
sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable));
if (!strcmp(wifiAvailable, "0"))
@@ -538,8 +543,36 @@
LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret);
return ret;
}
+ for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++)
+ {
+ if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT)
+ sleep(1);
+ else
+ break;
+ }
+ switch (wifi_enable_flag)
+ {
+ case SC_WIFI_STATUS_DISABLED:
+ ret = 1;
+ break;
+ case SC_WIFI_STATUS_ENABLED:
+ ret = 0;
+ break;
+ case SC_WIFI_STATUS_INVALID_MAC:
+ ret = 7;
+ break;
+ case SC_WIFI_STATUS_DEV_INIT_FAIL:
+ ret = 6;
+ break;
+ case SC_WIFI_STATUS_FIRMWARE_CRASH:
+ ret = 12;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
LYINFLOG("[%s ]\n", __func__);
- return 0;
+ return ret;
}
/********************************************************************
@@ -552,13 +585,43 @@
int qser_wifi_disable(void)
{
int ret = -1;
+ wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
ret = sc_wifi_disable();
if (0 != ret)
{
LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
return ret;
}
-
+ for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++)
+ {
+ if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT)
+ sleep(1);
+ else
+ break;
+ }
+ switch (wifi_enable_flag)
+ {
+ case SC_WIFI_STATUS_DISABLED:
+ ret = 0;
+ break;
+ case SC_WIFI_STATUS_INVALID_MAC:
+ ret = 7;
+ break;
+ case SC_WIFI_STATUS_DEV_INIT_FAIL:
+ ret = 6;
+ break;
+ case SC_WIFI_STATUS_FIRMWARE_CRASH:
+ ret = 12;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
+ return ret;
+ }
ret = sc_wifi_uninit();
if (0 != ret)
{