[BugFix][T106][bug-view-166][wifi] If wifi fails to be enabled, other apis can still be successfully executed
Only Configure: Yes
Affected branch: master
Affected module: wifi
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update:No
Change-Id: I7213f5b64f33093a3e3ff51f230d6354b246095f
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 877afb9..f3cb0bf 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
@@ -18,6 +18,14 @@
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;
+static bool lynq_wifi_enable = false;
+#define WIFI_ENABLE_JUDGE() do{ \
+ if(lynq_wifi_enable == false) \
+ { \
+ LYINFLOG("[%s ] wifi not enable\n", __func__); \
+ return -1; \
+ } \
+}while (0);
/********************************************************************
* @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform
@@ -396,6 +404,7 @@
*********************************************************************/
int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_work_mode_e mode;
ret = sc_wifi_work_mode_get(&mode);
@@ -428,6 +437,7 @@
*********************************************************************/
int qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_work_mode_e mode;
ret = sc_wifi_work_mode_get(&mode);
@@ -478,6 +488,11 @@
*********************************************************************/
int qser_wifi_enable(void)
{
+ if(lynq_wifi_enable)
+ {
+ LYERRLOG("[%s ] The wifi is enabled\n", __func__);
+ return -1;
+ }
wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
char wifiAvailable[8] = {0};
sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable));
@@ -571,7 +586,17 @@
ret = -1;
break;
}
- LYINFLOG("[%s ]\n", __func__);
+ LYINFLOG("[%s ] ret = %d\n", __func__,ret);
+ if(ret != 0)
+ {
+ int ret_uninit = sc_wifi_uninit();
+ if (0 != ret_uninit)
+ {
+ LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret_uninit);
+ }
+ }
+ else
+ lynq_wifi_enable = true;
return ret;
}
@@ -586,6 +611,11 @@
{
int ret = -1;
wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
+ if(lynq_wifi_enable == false)
+ {
+ LYERRLOG("[%s ] WiFi not turned on\n", __func__);
+ return -1;
+ }
ret = sc_wifi_disable();
if (0 != ret)
{
@@ -622,6 +652,7 @@
LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
return ret;
}
+ lynq_wifi_enable = false;
ret = sc_wifi_uninit();
if (0 != ret)
{
@@ -642,6 +673,7 @@
*********************************************************************/
int qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_status_t stat;
ret = sc_wifi_ap_get_status((sc_wifi_ap_index_e)idx, &stat);
@@ -669,6 +701,7 @@
*********************************************************************/
int qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
if (mac_list == NULL)
{
@@ -699,6 +732,7 @@
*********************************************************************/
int qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (mac_list == NULL || acl_rule == NULL)
@@ -729,6 +763,7 @@
*********************************************************************/
int qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
if (ssid == NULL)
{
@@ -756,6 +791,7 @@
*********************************************************************/
int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
@@ -780,6 +816,7 @@
*********************************************************************/
int qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide);
if (0 != ret)
@@ -802,6 +839,7 @@
*********************************************************************/
int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (hide == NULL)
@@ -831,6 +869,7 @@
*********************************************************************/
int qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, lynq_to_sc_mode(mode));
if (0 != ret)
@@ -853,6 +892,7 @@
*********************************************************************/
int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (mode == NULL)
@@ -882,6 +922,7 @@
*********************************************************************/
int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth);
if (0 != ret)
@@ -904,6 +945,7 @@
*********************************************************************/
int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (bandwidth == NULL)
@@ -934,6 +976,7 @@
*********************************************************************/
int qser_wifi_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
if (country_code == NULL)
{
@@ -962,6 +1005,7 @@
*********************************************************************/
int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (country_code == NULL || channel == NULL)
@@ -993,6 +1037,7 @@
*********************************************************************/
int qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
if (auth_passwd == NULL)
{
@@ -1025,6 +1070,7 @@
*********************************************************************/
int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (auth_mode == NULL || auth_passwd == NULL)
@@ -1056,6 +1102,7 @@
*********************************************************************/
int qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (auth_mode == NULL)
@@ -1088,6 +1135,7 @@
*********************************************************************/
int qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num);
if (0 != ret)
@@ -1110,6 +1158,7 @@
*********************************************************************/
int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_ap_param_t param = {0};
if (max_sta_num == NULL)
@@ -1138,6 +1187,7 @@
*********************************************************************/
int qser_wifi_lanhost_get_list(lynq_lanhost_ts *lynq_arrays)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
int i = 0;
sc_lanhost_t array[32] = {0};
@@ -1178,6 +1228,7 @@
*********************************************************************/
int qser_wifi_get_ap_pkt_stats(lynq_wifi_ap_index_e idx, lynq_wifi_pkt_stats_t *pkt_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_pkt_stats_t stat = {0};
if (pkt_stat == NULL)
@@ -1216,6 +1267,7 @@
*********************************************************************/
int qser_wifi_ap_start(lynq_wifi_ap_index_e idx)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
if (0 != ret)
@@ -1237,6 +1289,7 @@
*********************************************************************/
int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
if (0 != ret)
@@ -1258,6 +1311,7 @@
*********************************************************************/
int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
if (0 != ret)
@@ -1285,6 +1339,7 @@
*********************************************************************/
int qser_wifi_sta_param_set(lynq_wifi_sta_param_t *param_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_sta_param_t stat = {0};
stat.auth = lynq_to_sc_auth_mode(param_stat->auth);
@@ -1311,6 +1366,7 @@
*********************************************************************/
int qser_wifi_sta_param_get(lynq_wifi_sta_param_t *param_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_sta_param_t stat = {0};
ret = sc_wifi_sta_param_get(&stat);
@@ -1337,6 +1393,7 @@
*********************************************************************/
int qser_wifi_sta_get_status(lynq_wifi_sta_status_t *status_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_sta_status_t stat;
ret = sc_wifi_sta_get_status(&stat);
@@ -1361,6 +1418,7 @@
*********************************************************************/
int qser_wifi_get_sta_pkt_stats(lynq_wifi_pkt_stats_t *pkt_stat)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
sc_wifi_pkt_stats_t stat = {0};
if (pkt_stat == NULL)
@@ -1397,6 +1455,7 @@
*********************************************************************/
int qser_wifi_sta_start_scan(void)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_sta_start_scan();
if (0 != ret)
@@ -1417,6 +1476,7 @@
*********************************************************************/
int qser_wifi_sta_start(void)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_sta_start();
if (0 != ret)
@@ -1437,6 +1497,7 @@
*********************************************************************/
int qser_wifi_sta_stop(void)
{
+ WIFI_ENABLE_JUDGE();
int ret = -1;
ret = sc_wifi_sta_stop();
if (0 != ret)