[Feature][ZXW-257]wifi gets api that shows whether the ap/sta state and ssid are hidden

    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: Icf1878c60de8c5d92055a4b755a8b2ce36f6980d
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 91f1112..664fcbe 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,6 +11,233 @@
 #include "sc_wifi.h"
 #include "lynq-qser-wifi.h"
 
+static  lynq_wifi_event_handle wifi_event_handle = NULL;
+static void *global_arg = NULL;
+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
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static sc_wifi_auth_e lynq_to_sc_auth_mode(lynq_wifi_auth_e auth_mode)
+{
+    sc_wifi_auth_e type;
+    switch (auth_mode)
+    {
+        case LYNQ_WIFI_AUTH_OPEN:
+            type = SC_WIFI_AUTH_OPEN;
+            break;
+        case LYNQ_WIFI_AUTH_WPA2_PSK:
+            type = SC_WIFI_AUTH_WPA2_PSK;
+            break;
+        case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
+            type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
+            break;
+        case LYNQ_WIFI_AUTH_WPA3_PSK:
+            type = SC_WIFI_AUTH_WPA3_PSK;
+            break;
+        case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
+            type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
+            break;
+        default:
+            type = SC_WIFI_AUTH_MIN;
+            break;
+    }
+	return type;
+} 
+
+/********************************************************************
+* @brief: sc_to_lynq_auth_mode, The encryption mode of wifi is changed from platform to api
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static lynq_wifi_auth_e sc_to_lynq_auth_mode(sc_wifi_auth_e auth_mode)
+{
+    lynq_wifi_auth_e type;
+    switch (auth_mode)
+    {
+        case SC_WIFI_AUTH_OPEN:
+            type = LYNQ_WIFI_AUTH_OPEN;
+            break;
+        case SC_WIFI_AUTH_WPA2_PSK:
+            type = LYNQ_WIFI_AUTH_WPA2_PSK;
+            break;
+        case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
+            type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
+            break;
+        case SC_WIFI_AUTH_WPA3_PSK:
+            type = LYNQ_WIFI_AUTH_WPA3_PSK;
+            break;
+        case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
+            type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
+            break;
+        default:
+            type = LYNQ_WIFI_AUTH_MIN;
+            break;
+    }
+	return type;
+} 
+
+/********************************************************************
+* @brief: lynq_user_status, wifi startup callback
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+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);
+}
+
+/********************************************************************
+* @brief: lynq_user_wifi_service_error, wifi service status callback
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static void lynq_user_wifi_service_error(int error)
+{
+	LYINFLOG("%s: %d\n", __func__, error);
+}
+
+/********************************************************************
+* @brief: lynq_user_ap_status, wifi Obtains the ap status callback
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static void lynq_user_ap_status(sc_wifi_ap_index_e index, sc_wifi_ap_status_e pre_status, sc_wifi_ap_status_t *p_msg)
+{
+    if(wifi_event_handle != NULL && global_arg != NULL)
+    {
+        global_event.idx = (lynq_wifi_ap_index_e)index;
+        global_event.status = (lynq_wifi_status_e)pre_status;
+        wifi_event_handle(&global_event, global_arg);
+    }
+    else{
+        LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status);
+    }
+	
+}
+
+/********************************************************************
+* @brief: lynq_user_ap_sta_conn_status, wifi as ap is sta information callback
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static void lynq_user_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg)
+{
+    if(wifi_event_handle != NULL && global_arg != NULL)
+    {
+        global_event.idx = (lynq_wifi_ap_index_e)index;
+        global_event.ap_sta_info.connected = p_msg->is_connected;
+        strncpy(global_event.ap_sta_info.mac, p_msg->macaddr, 
+        sizeof(global_event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(global_event.ap_sta_info.mac):sizeof(p_msg->macaddr));
+        wifi_event_handle(&global_event, global_arg);
+    }
+    else{
+        LYINFLOG("%s:%d,%d,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr);
+    }
+	
+} 
+
+/********************************************************************
+* @brief: print_sta_status, wifi gets the status callback in sta mode
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static void print_sta_status(sc_wifi_sta_status_t *p_msg)
+{
+	LYINFLOG("%s: %d, %s, %s, %d, %d\n", __func__, p_msg->status, p_msg->ifname, p_msg->ap_bssid, 
+	p_msg->signal_level, p_msg->reason_code);
+
+	if (p_msg->has_addr == 1) {
+		char addrtxt[48] = {0};
+		inet_ntop(AF_INET, &p_msg->addr, addrtxt, sizeof(addrtxt));
+		LYINFLOG("%s : addr inet_ntop: %s\n", __func__, addrtxt);
+
+		LYINFLOG("%s : addr: %08X\n", __func__, p_msg->addr.s_addr);
+	}
+
+	if (p_msg->has_addr6 == 1) {
+		char addrtxt[48] = {0};
+		inet_ntop(AF_INET6, &p_msg->addr6, addrtxt, sizeof(addrtxt));
+		LYINFLOG("%s : addr6 inet_ntop: %s\n", __func__, addrtxt);
+
+		LYINFLOG("%s : addr6: %02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X\n",__func__, 
+		p_msg->addr6.s6_addr[0], p_msg->addr6.s6_addr[1], p_msg->addr6.s6_addr[2], p_msg->addr6.s6_addr[3], 
+		p_msg->addr6.s6_addr[4], p_msg->addr6.s6_addr[5], p_msg->addr6.s6_addr[6], p_msg->addr6.s6_addr[7], 
+		p_msg->addr6.s6_addr[8], p_msg->addr6.s6_addr[9], p_msg->addr6.s6_addr[10], p_msg->addr6.s6_addr[11], 
+		p_msg->addr6.s6_addr[12], p_msg->addr6.s6_addr[13], p_msg->addr6.s6_addr[14], p_msg->addr6.s6_addr[15]);
+	}
+	LYINFLOG("%s : sta_status end\n",__func__);
+}
+
+/********************************************************************
+* @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+static void lynq_user_sta_status_ind(sc_wifi_sta_status_e pre_status, 
+  sc_wifi_sta_status_t *p_msg)
+{	 
+	 LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status);
+	 print_sta_status(p_msg);
+}
+
+/********************************************************************
+* @brief: lynq_user_sta_scan_result_ind, wifi gets the callback of sta mode traversing the hotspot
+* @return : NA
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+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);
+	}
+}
+
+/********************************************************************
+* @brief: qser_wifi_register_handle, Register callback functions
+* @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)
+{
+    if(event_handle == NULL || arg == NULL)
+    {
+        LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg);
+        return -1;
+    }
+    wifi_event_handle = event_handle;
+    global_arg = arg;
+    return 0;
+}
+
 /********************************************************************
 * @brief: qser_wifi_enable, Enable WiFi function
 * @return : int, If equal to 0 succeeds, others fail
@@ -24,14 +251,57 @@
     ret = sc_wifi_init();
     if (0 != ret)
     {
-        LYERRLOG("[%s ] init : %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+
+    //wifi
+    ret = sc_wifi_set_enable_status_ind_cb(lynq_user_status);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_status  ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+
+    //ap
+    ret = sc_wifi_ap_set_status_ind_cb(lynq_user_ap_status);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_ap_status  ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+    ret = sc_wifi_set_ap_sta_connect_ind_cb(lynq_user_ap_sta_conn_status);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status  ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+
+	//sta
+    ret = sc_wifi_sta_set_status_ind_cb(lynq_user_sta_status_ind);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_sta_status_ind  ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+    ret = sc_wifi_sta_set_scan_result_ind_cb(lynq_user_sta_scan_result_ind);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind  ret = %d fail\n", __func__,ret);
+        return ret;
+    }
+	//proxy
+    ret = sc_wifi_set_service_error_cb(lynq_user_wifi_service_error);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] Request lynq_user_wifi_service_error  ret = %d fail\n", __func__,ret);
         return ret;
     }
 
     ret = sc_wifi_enable();
     if (0 != ret)
     {
-        LYERRLOG("[%s ] enable : %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret);
         return ret;
     }
     LYINFLOG("[%s ]\n", __func__);
@@ -117,6 +387,57 @@
 }
 
 /********************************************************************
+* @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
+* @param hide [IN]: bool, Set whether the ssid is hidden
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide)
+{
+    int ret = -1;
+    ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide);
+    return 0;
+}
+
+/********************************************************************
+* @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
+* @param hide [OUT]: bool *, Get whether the ssid is hidden
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide)
+{
+    int ret = -1;
+    sc_wifi_ap_param_t param = {0};
+    if (hide == NULL)
+    {
+        LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide);
+        return ret;
+    }
+    ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide);
+    *hide = (bool)param.ssid_hide;
+    return 0;
+}
+
+/********************************************************************
 * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of wlan0 or wlan1
 * @param idx [IN]: int, Set wlan0 or wlan1
 * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode
@@ -316,35 +637,14 @@
 int qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd)
 {
     int ret = -1;
-    sc_wifi_auth_e type;
     if (auth_passwd == NULL)
     {
         LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd);
         return ret;
     }
-    switch (auth_mode)
-    {
-        case LYNQ_WIFI_AUTH_OPEN:
-            type = SC_WIFI_AUTH_OPEN;
-            break;
-        case LYNQ_WIFI_AUTH_WPA2_PSK:
-            type = SC_WIFI_AUTH_WPA2_PSK;
-            break;
-        case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
-            type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
-            break;
-        case LYNQ_WIFI_AUTH_WPA3_PSK:
-            type = SC_WIFI_AUTH_WPA3_PSK;
-            break;
-        case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
-            type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
-            break;
-        default:
-            type = SC_WIFI_AUTH_MIN;
-            break;
-    }
+    
     sc_wifi_ap_auth_t auth;
-    auth.auth = (sc_wifi_auth_e)type;
+    auth.auth = lynq_to_sc_auth_mode(auth_mode);
     strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1);
     ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth);
     if (0 != ret)
@@ -352,7 +652,7 @@
         LYERRLOG("[%s ] ret = %d\n", __func__,ret);
         return ret;
     }
-    LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s\n", __func__, idx, auth_mode, auth_passwd);
+    LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s\n", __func__, idx, auth_mode, "******");
     return 0;
 }
 
@@ -383,29 +683,8 @@
     }
     LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd);
     strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1);
-    lynq_wifi_auth_e type;
-    switch (param.auth.auth)
-    {
-        case SC_WIFI_AUTH_OPEN:
-            type = LYNQ_WIFI_AUTH_OPEN;
-            break;
-        case SC_WIFI_AUTH_WPA2_PSK:
-            type = LYNQ_WIFI_AUTH_WPA2_PSK;
-            break;
-        case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
-            type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
-            break;
-        case SC_WIFI_AUTH_WPA3_PSK:
-            type = LYNQ_WIFI_AUTH_WPA3_PSK;
-            break;
-        case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
-            type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
-            break;
-        default:
-            type = LYNQ_WIFI_AUTH_MIN;
-            break;
-    }
-    *auth_mode = type;
+    
+    *auth_mode = sc_to_lynq_auth_mode(param.auth.auth);
     return 0;
 }
 
@@ -516,19 +795,131 @@
     ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
     if (0 != ret)
     {
-        LYERRLOG("[%s ] stop: %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] stop ret = %d\n", __func__,ret);
         return ret;
     }
     ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
     if (0 != ret)
     {
-        LYERRLOG("[%s ] start: %d ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] start ret = %d\n", __func__,ret);
         return ret;
     }
     LYINFLOG("[%s ] idx = %d \n", __func__, idx);
     return 0;
 }
 
+/********************************************************************
+* @brief: qser_wifi_sta_param_set, Set the ssid and password that you need to connect to the access point
+* @param lynq_stat [IN]: sc_wifi_sta_param_t *, Set parameters such as ssid and password that you want to connect to the access point
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_param_set(lynq_wifi_sta_param_t *lynq_stat)
+{
+    int ret = -1;
+    sc_wifi_sta_param_t stat = {0};
+    stat.auth = lynq_to_sc_auth_mode(lynq_stat->auth);
+    stat.pairwise = (sc_wifi_auth_wpa_psk_e )lynq_stat->pairwise;
+    strncpy(stat.ssid, lynq_stat->ssid, sizeof(stat.ssid));
+    strncpy(stat.passwd, lynq_stat->passwd, sizeof(stat.passwd));
+    ret = sc_wifi_sta_param_set(&stat);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] sta_param_set ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_sta_param_get, Get the ssid and password that you need to connect to the access point
+* @param lynq_stat [OUT]: sc_wifi_sta_param_t *, Get parameters such as ssid and password that you want to connect to the access point
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_param_get(lynq_wifi_sta_param_t *lynq_stat)
+{
+    int ret = -1;
+    sc_wifi_sta_param_t stat = {0};
+    ret = sc_wifi_sta_param_get(&stat);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret);
+        return ret;
+    }
+    lynq_stat->auth = sc_to_lynq_auth_mode(stat.auth);
+    lynq_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise;
+    strncpy(lynq_stat->ssid, stat.ssid, sizeof(stat.ssid));
+    strncpy(lynq_stat->passwd, stat.passwd, sizeof(stat.passwd));
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_sta_start_scan, Scan for ap nodes and return them through callback
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_start_scan(void)
+{
+    int ret = -1;
+    ret = sc_wifi_sta_start_scan();
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] scan ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_sta_start, To enable sta mode, you need to enable ap mode first
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_start(void)
+{
+    int ret = -1;
+    ret = sc_wifi_sta_start();
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] sta_start ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_sta_stop, To disable sta mode.
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_stop(void)
+{
+    int ret = -1;
+    ret = sc_wifi_sta_stop();
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] sta_stop ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
 DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI)
 
 #ifdef __cplusplus