[Feature][ZXW-257]wifi 5g Settings and sta callback Settings added

    Only Configure :No
    Affected branch: master
    Affected module: wifi
    Is it affected on both ZXIC and MTK:only ZXIC
    Self-test: Yes
    Doc Update: Yes

Change-Id: I7b007bc8c9bfef2a998d12c8f9066e8cf52dc8f5
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 664fcbe..8ea6835 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,13 +11,14 @@
 #include "sc_wifi.h"
 #include "lynq-qser-wifi.h"
 
-static  lynq_wifi_event_handle wifi_event_handle = NULL;
+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 lynq_wifi_event_s global_event ;
+static lynq_wifi_event_s global_event;
 
 /********************************************************************
 * @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform
-* @return : NA
+* @return :sc_wifi_auth_e, all
 * @todo: NA
 * @see: NA
 * @warning: NA
@@ -46,12 +47,12 @@
             type = SC_WIFI_AUTH_MIN;
             break;
     }
-	return type;
-} 
+    return type;
+}
 
 /********************************************************************
-* @brief: sc_to_lynq_auth_mode, The encryption mode of wifi is changed from platform to api
-* @return : NA
+* @brief: sc_to_lynq_auth_mode, The wifi protocol moves from platform to api
+* @return :lynq_wifi_auth_e, all
 * @todo: NA
 * @see: NA
 * @warning: NA
@@ -80,8 +81,76 @@
             type = LYNQ_WIFI_AUTH_MIN;
             break;
     }
-	return type;
-} 
+    return type;
+}
+
+/********************************************************************
+* @brief: lynq_to_sc_mode, The wifi protocol is transferred from api to platform
+* @return :sc_wifi_ap_mode_type_e, all
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static sc_wifi_ap_mode_type_e lynq_to_sc_mode(lynq_wifi_mode_type_e mode)
+{
+    sc_wifi_ap_mode_type_e type;
+    switch (mode)
+    {
+        case LYNQ_WIFI_MODE_80211BGN:
+            type = SC_WIFI_AP_MODE_80211BGN;
+            break;
+        case LYNQ_WIFI_MODE_80211BGNAX_2G:
+            type = SC_WIFI_AP_MODE_80211BGNAX_2G;
+            break;
+        case LYNQ_WIFI_MODE_80211AN:
+            type = SC_WIFI_AP_MODE_80211AN;
+            break;
+        case LYNQ_WIFI_MODE_80211ANAC:
+            type = SC_WIFI_AP_MODE_80211ANAC;
+            break;
+        case LYNQ_WIFI_MODE_80211ANACAX_5G:
+            type = SC_WIFI_AP_MODE_80211ANACAX_5G;
+            break;
+        default:
+            type = SC_WIFI_AP_MODE_MIN;
+            break;
+    }
+    return type;
+}
+
+/********************************************************************
+* @brief: sc_to_lynq_mode, The encryption mode of wifi is changed from platform to api
+* @return :lynq_wifi_mode_type_e, all
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static lynq_wifi_mode_type_e sc_to_lynq_mode(sc_wifi_ap_mode_type_e mode)
+{
+    lynq_wifi_mode_type_e type;
+    switch (mode)
+    {
+        case SC_WIFI_AP_MODE_80211BGN:
+            type = LYNQ_WIFI_MODE_80211BGN;
+            break;
+        case SC_WIFI_AP_MODE_80211BGNAX_2G:
+            type = LYNQ_WIFI_MODE_80211BGNAX_2G;
+            break;
+        case SC_WIFI_AP_MODE_80211AN:
+            type = LYNQ_WIFI_MODE_80211AN;
+            break;
+        case SC_WIFI_AP_MODE_80211ANAC:
+            type = LYNQ_WIFI_MODE_80211ANAC;
+            break;
+        case SC_WIFI_AP_MODE_80211ANACAX_5G:
+            type = LYNQ_WIFI_MODE_80211ANACAX_5G;
+            break;
+        default:
+            type = LYNQ_WIFI_MODE_MIN;
+            break;
+    }
+    return type;
+}
 
 /********************************************************************
 * @brief: lynq_user_status, wifi startup callback
@@ -208,31 +277,76 @@
 *********************************************************************/
 static void lynq_user_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg)
 {
-	int i = 0;
-	LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt);
-	if (p_msg->cnt <= 0) {
-		return;
-	}
-	for (i = 0; i < p_msg->cnt; i++) {
-		LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d\n", __func__, i, p_msg->info[i].essid, sc_to_lynq_auth_mode(p_msg->info[i].auth), 
-			p_msg->info[i].cipher, p_msg->info[i].channel, p_msg->info[i].bssid, p_msg->info[i].signal_level);
-	}
+    int i = 0;
+    LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt);
+    if (p_msg->cnt <= 0)
+    {
+        return;
+    }
+    if (wifi_event_handle_sta != NULL)
+    {
+        lynq_wifi_sta_scan_list_t event;
+        event.cnt = p_msg->cnt;
+        for (i = 0; i < event.cnt; i++)
+        {
+            strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid));
+            strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid));
+            event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth);
+            event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher;
+            event.info[i].channel = p_msg->info[i].channel;
+            event.info[i].signal_level = p_msg->info[i].signal_level;
+        }
+        wifi_event_handle_sta(&event);
+    }
+    else
+    {
+        for (i = 0; i < p_msg->cnt; i++)
+        {
+            LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d\n", __func__, i, p_msg->info[i].essid, sc_to_lynq_auth_mode(p_msg->info[i].auth),
+                     p_msg->info[i].cipher, p_msg->info[i].channel, p_msg->info[i].bssid, p_msg->info[i].signal_level);
+        }
+    }
+}
+
+/********************************************************************
+* @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings
+* @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type)
+{
+    int ret = -1;
+    ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] work_mode ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ]\n", __func__);
+    return 0;
 }
 
 /********************************************************************
 * @brief: qser_wifi_register_handle, Register callback functions
+* @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function
+* @param event_handle_sta [IN]: Register sta's event callback function
+* @param arg [IN]: void *, Not currently used, but cannot pass a null pointer
 * @return :int, If equal to 0 succeeds, others fail
 * @todo: NA
 * @see: NA
 * @warning: NA
 *********************************************************************/
-int qser_wifi_register_handle(lynq_wifi_event_handle event_handle, void *arg)
+int qser_wifi_register_handle(lynq_wifi_event_handle event_handle, lynq_wifi_event_handle_sta event_handle_sta, void *arg)
 {
-    if(event_handle == NULL || arg == NULL)
+    if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL)
     {
         LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg);
         return -1;
     }
+    wifi_event_handle_sta = event_handle_sta;
     wifi_event_handle = event_handle;
     global_arg = arg;
     return 0;
@@ -321,14 +435,14 @@
     ret = sc_wifi_disable();
     if (0 != ret)
     {
-        LYERRLOG("[%s ] disable : %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
         return ret;
     }
 
     ret = sc_wifi_uninit();
     if (0 != ret)
     {
-        LYERRLOG("[%s ] uninit: %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret);
         return ret;
     }
     LYINFLOG("[%s ]\n", __func__);
@@ -336,8 +450,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param ssid [IN]: const char *, Set the ssid name
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -363,8 +477,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param ssid [OUT]: char *, Get the ssid name
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -387,8 +501,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of wlan0 or wlan1 is hidden
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param hide [IN]: bool, Set whether the ssid is hidden
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -409,8 +523,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of wlan0 or wlan1 is hidden
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param hide [OUT]: bool *, Get whether the ssid is hidden
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -438,8 +552,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_mode_set, Set the working protocol mode of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -449,20 +563,7 @@
 int  qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode)
 {
     int ret = -1;
-    sc_wifi_ap_mode_type_e type;
-    switch(mode)
-    {
-        case LYNQ_WIFI_MODE_80211BGN:
-            type = SC_WIFI_AP_MODE_80211BGN;
-            break;
-        case LYNQ_WIFI_MODE_80211BGNAX_2G:
-            type = SC_WIFI_AP_MODE_80211BGNAX_2G;
-            break;
-        default:
-            type = SC_WIFI_AP_MODE_MIN;
-            break;
-    }
-    ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, type);
+    ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, lynq_to_sc_mode(mode));
     if (0 != ret)
     {
         LYERRLOG("[%s ] ret = %d\n", __func__,ret);
@@ -473,8 +574,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_mode_get, Get the working protocol mode of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -497,26 +598,13 @@
         return ret;
     }
     LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode);
-    lynq_wifi_mode_type_e type;
-    switch(param.mode)
-    {
-        case SC_WIFI_AP_MODE_80211BGN:
-            type = LYNQ_WIFI_MODE_80211BGN;
-            break;
-        case SC_WIFI_AP_MODE_80211BGNAX_2G:
-            type = LYNQ_WIFI_MODE_80211BGNAX_2G;
-            break;
-        default:
-            type = LYNQ_WIFI_MODE_MIN;
-            break;
-    }
-    *mode = type;
+    *mode = sc_to_lynq_mode(param.mode);
     return 0;
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -537,8 +625,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -566,8 +654,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_channel_set, Set the channel for wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param country_code [IN]: const char *, Set country code
 * @param channel [IN]: int, Set the channel
 * @return : int, If equal to 0 succeeds, others fail
@@ -594,8 +682,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_channel_get, Get the channel for wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param country_code [OUT]: char *, Get country code
 * @param channel [OUT]: int *, Get the channel
 * @return : int, If equal to 0 succeeds, others fail
@@ -625,8 +713,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode
 * @param auth_passwd [IN]: const char *, Set password
 * @return : int, If equal to 0 succeeds, others fail
@@ -657,8 +745,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode
 * @param auth_passwd [OUT]: char *, Get password
 * @return : int, If equal to 0 succeeds, others fail
@@ -689,8 +777,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param max_sta_num [IN]: int, Set the maximum number
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -711,8 +799,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @param max_sta_num [OUT]: int *, Get the maximum number
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
@@ -740,8 +828,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_start, Set the ap mode of wlan0 or wlan1 to enable
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable
+* @param idx [IN]: int, Set 2.4G or 5G
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
 * @see: NA
@@ -761,8 +849,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_stop, Disable ap mode for wlan0 or wlan1
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
 * @see: NA
@@ -782,8 +870,8 @@
 }
 
 /********************************************************************
-* @brief: qser_wifi_ap_restart, Set the ap mode of wlan0 or wlan1 to restart
-* @param idx [IN]: int, Set wlan0 or wlan1
+* @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart
+* @param idx [IN]: int, Set 2.4G or 5G
 * @return : int, If equal to 0 succeeds, others fail
 * @todo: NA
 * @see: NA