[Feature][ZXW-257]Black and white list of wifi, ap status acquisition, new WiFi function of p56u05 baseline, sta status acquisition, etc

    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: Ifbb8443d7df0e915821708f51c1b567ec0860be5
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/include/lynq-qser-wifi.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/include/lynq-qser-wifi.h
index 0c3fdb5..8b839fd 100644
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/include/lynq-qser-wifi.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-wifi/include/lynq-qser-wifi.h
@@ -33,6 +33,24 @@
 
 typedef enum
 {
+	LYNQ_WIFI_MAC_ACL_RULE_MIN = -1,
+	LYNQ_WIFI_MAC_ACL_RULE_NONE = 0,
+	LYNQ_WIFI_MAC_ACL_RULE_WHITE,
+	LYNQ_WIFI_MAC_ACL_RULE_BLACK,
+	LYNQ_WIFI_MAC_ACL_RULE_MAX
+} lynq_wifi_mac_acl_rule_e;
+
+typedef enum {
+	LYNQ_WIFI_EVENT_MIN = -1,
+	LYNQ_WIFI_EVENT_ENABLE_STATUS = 0,
+	LYNQ_WIFI_EVENT_DISABLE_STATUS,
+	LYNQ_WIFI_EVENT_AP_STATION,
+	LYNQ_WIFI_EVENT_STA_STATUS,
+	LYNQ_WIFI_EVENT_MAX,
+} lynq_wifi_event_type_e;
+
+typedef enum
+{
 	LYNQ_WIFI_MODE_MIN = -1,
 	LYNQ_WIFI_MODE_80211B = 0,
 	LYNQ_WIFI_MODE_80211BG,
@@ -68,10 +86,12 @@
 } lynq_wifi_auth_e;
 
 typedef enum {
-	LYNQ_WIFI_STATUS_ENABLE = 0,
-	LYNQ_WIFI_STATUS_DISABLE,
-	LYNQ_WIFI_STATUS_ERR_DRIVER,
-	LYNQ_WIFI_STATUS_ERR_SOFTWARE,
+	LYNQ_WIFI_AP_STATUS_NONE = 0,
+	LYNQ_WIFI_AP_STATUS_IDLE, //or disable
+	LYNQ_WIFI_AP_STATUS_ENABLING,
+	LYNQ_WIFI_AP_STATUS_ENABLED,
+	LYNQ_WIFI_AP_STATUS_DISABLING,
+	LYNQ_WIFI_AP_STATUS_ERROR
 } lynq_wifi_status_e;
 
 typedef enum {
@@ -89,8 +109,24 @@
 	LYNQ_WIFI_AUTH_WPA_PAIRWISE_MAX
 } lynq_wifi_auth_wpa_psk_e;
 
+//pairwise,group_rekey is only used in get
+typedef struct
+{
+	lynq_wifi_auth_e auth;
+	lynq_wifi_auth_wpa_psk_e pairwise; 
+	char passwd[64 + 1];
+	int group_rekey; //in seconds
+} lynq_wifi_ap_auth_t;
+
+typedef struct
+{
+	lynq_wifi_status_e status;
+	char ifname[32];
+	char bssid[18];
+}lynq_wifi_ap_status_t;
+
 typedef struct {
-	lynq_wifi_ap_index_e idx;
+	lynq_wifi_event_type_e id;
 	union {
 	    /* the LYNQ_WIFI_ENABLE_STATUS or LYNQ_WIFI_DISABLE_STATUS event */
 		lynq_wifi_status_e status;
@@ -100,25 +136,63 @@
 		     * If connected is false, the station is disconnected wifi hotspot.
 		     */
             int connected;
-            char mac[18];
+            char mac[18]; //mac connected to WiFi device
+            char hostname[32]; //Name of the WiFi device
 		} ap_sta_info;
 		lynq_wifi_station_status_e sta_status;
 	};
 } lynq_wifi_event_s;
 
- typedef struct
- {
- 	 char ssid[33];
-	 lynq_wifi_auth_e auth; //only aic support wap3
-	 lynq_wifi_auth_wpa_psk_e pairwise;
-	 char passwd[64 + 1];
- } lynq_wifi_sta_param_t;
+typedef struct
+{
+ 	char ssid[33];
+	lynq_wifi_auth_e auth; //only aic support wap3
+	lynq_wifi_auth_wpa_psk_e pairwise;
+	char passwd[64 + 1];
+} lynq_wifi_sta_param_t;
+
+typedef enum
+{
+	LYNQ_WIFI_STA_STATUS_NONE,
+	LYNQ_WIFI_STA_STATUS_IDLE,
+	LYNQ_WIFI_STA_STATUS_CONNECTING,
+	LYNQ_WIFI_STA_STATUS_ASSOCIATED, //dhcping
+	LYNQ_WIFI_STA_STATUS_CONNECTED,
+	LYNQ_WIFI_STA_STATUS_DISCONNECTED, 
+	LYNQ_WIFI_STA_STATUS_ERROR
+} lynq_wifi_sta_status_e;
+
+typedef enum
+{
+	LYNQ_WIFI_REASON_CODE_NONE,
+	LYNQ_WIFI_REASON_CODE_WRONG_KEY,
+	LYNQ_WIFI_REASON_CODE_AUTH_FAILED,
+	LYNQ_WIFI_REASON_CODE_CONN_FAILED,
+	LYNQ_WIFI_REASON_CODE_SET_FAILED,
+	LYNQ_WIFI_REASON_CODE_DHCP_FAILED
+} lynq_wifi_reason_code_e;
+
+typedef struct
+{
+	lynq_wifi_sta_status_e status;
+	char ifname[32];
+	char ap_bssid[18]; //cur ap mac
+	//int rssi;
+	unsigned char signal_level;
+	unsigned char has_addr;
+	char addr[48]; //(addr.s_addr)
+	unsigned char has_addr6;
+	char addr6[48]; //
+	lynq_wifi_reason_code_e reason_code;
+} lynq_wifi_sta_status_t;
 
 typedef struct
 {
 	char bssid[18];//mac
 	char essid[33];
+	int signal; //dbm
 	unsigned char signal_level; //0-4, max 4
+	int frequency; //Hz
 	unsigned char channel; //1-13
 	lynq_wifi_auth_e auth;
 	lynq_wifi_auth_wpa_psk_e cipher;
@@ -134,8 +208,12 @@
 typedef void (*lynq_wifi_event_handle_sta)(lynq_wifi_sta_scan_list_t *event);
 
 int  qser_wifi_work_mode_set(lynq_wifi_work_mode_e type);
+int  qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type);
 int  qser_wifi_enable(void);
 int  qser_wifi_disable(void);
+int  qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat);
+int  qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list);
+int  qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list);
 int  qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid);
 int  qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid);
 int  qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide);
@@ -148,14 +226,16 @@
 int  qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel);
 int  qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char * auth_passwd);
 int  qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char * auth_passwd);
+int  qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode);
 int  qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num);
 int  qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num);
 int  qser_wifi_ap_start(lynq_wifi_ap_index_e idx);
 int  qser_wifi_ap_stop(lynq_wifi_ap_index_e idx);
 int  qser_wifi_ap_restart(lynq_wifi_ap_index_e idx);
 int  qser_wifi_register_handle(lynq_wifi_event_handle event_handle, lynq_wifi_event_handle_sta event_handle_sta, void *arg);
-int  qser_wifi_sta_param_set(lynq_wifi_sta_param_t *lynq_stat);
-int  qser_wifi_sta_param_get(lynq_wifi_sta_param_t *lynq_stat);
+int  qser_wifi_sta_param_set(lynq_wifi_sta_param_t *param_stat);
+int  qser_wifi_sta_param_get(lynq_wifi_sta_param_t *param_stat);
+int  qser_wifi_sta_get_status(lynq_wifi_sta_status_t *status_stat);
 int  qser_wifi_sta_start_scan(void);
 int  qser_wifi_sta_start(void);
 int  qser_wifi_sta_stop(void);
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 8ea6835..da282c8 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
@@ -14,7 +14,6 @@
 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;
 
 /********************************************************************
 * @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform
@@ -185,16 +184,25 @@
 *********************************************************************/
 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)
+    lynq_wifi_event_s event;
+    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);
+        if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS)
+        {
+            return;
+        }
+        if (*(int *)global_arg != LYNQ_WIFI_EVENT_AP_STATION)
+        {
+            LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status);
+        }
+        event.id = LYNQ_WIFI_EVENT_AP_STATION;
+        event.status = (lynq_wifi_status_e)pre_status;
+        wifi_event_handle(&event, global_arg);
     }
-    else{
+    else
+    {
         LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status);
     }
-	
 }
 
 /********************************************************************
@@ -206,19 +214,35 @@
 *********************************************************************/
 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)
+    char hostname[32] = {0};
+    lynq_wifi_event_s event;
+    int ret = sc_wifi_get_hostname_by_mac(p_msg->macaddr, hostname, sizeof(hostname));
+    if (ret == 0)
     {
-        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);
+        printf("[wifi_demo]sta ip not assigned, try again later!\n");
     }
-    else{
-        LYINFLOG("%s:%d,%d,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr);
+    if (wifi_event_handle != NULL && global_arg != NULL)
+    {
+        if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS)
+        {
+            return;
+        }
+        if (*(int *)global_arg != LYNQ_WIFI_EVENT_STA_STATUS)
+        {
+            LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname);
+        }
+        event.id = LYNQ_WIFI_EVENT_STA_STATUS;
+        event.ap_sta_info.connected = p_msg->is_connected;
+        strncpy(event.ap_sta_info.mac, p_msg->macaddr,
+                sizeof(event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(event.ap_sta_info.mac) : sizeof(p_msg->macaddr));
+        strncpy(event.ap_sta_info.hostname, hostname, sizeof(hostname));
+        wifi_event_handle(&event, global_arg);
     }
-	
-} 
+    else
+    {
+        LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname);
+    }
+}
 
 /********************************************************************
 * @brief: print_sta_status, wifi gets the status callback in sta mode
@@ -227,6 +251,7 @@
 * @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, 
@@ -253,6 +278,7 @@
 	}
 	LYINFLOG("%s : sta_status end\n",__func__);
 }
+*/
 
 /********************************************************************
 * @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode
@@ -265,7 +291,7 @@
   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);
+	 //print_sta_status(p_msg);
 }
 
 /********************************************************************
@@ -295,6 +321,8 @@
             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;
+            event.info[i].frequency = p_msg->info[i].frequency;
+            event.info[i].signal = p_msg->info[i].signal;
         }
         wifi_event_handle_sta(&event);
     }
@@ -302,8 +330,8 @@
     {
         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);
+            LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d,%d,%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,p_msg->info[i].frequency,p_msg->info[i].signal);
         }
     }
 }
@@ -319,10 +347,21 @@
 int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type)
 {
     int ret = -1;
+    sc_wifi_work_mode_e mode;
+    ret = sc_wifi_work_mode_get(&mode);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret);
+        return ret;
+    }
+    if(mode == (sc_wifi_work_mode_e)type) //The same value is returned
+    {
+        return 0;
+    }
     ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type);
     if (0 != ret)
     {
-        LYERRLOG("[%s ] work_mode ret = %d\n", __func__,ret);
+        LYERRLOG("[%s ] work_mode set ret = %d\n", __func__,ret);
         return ret;
     }
     LYINFLOG("[%s ]\n", __func__);
@@ -330,6 +369,29 @@
 }
 
 /********************************************************************
+* @brief: qser_wifi_work_mode_get, 2.4g or 5g working mode Gettings
+* @param type [OUT]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Gettings
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type)
+{
+    int ret = -1;
+    sc_wifi_work_mode_e mode;
+    ret = sc_wifi_work_mode_get(&mode);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret);
+        return ret;
+    }
+    *type = (lynq_wifi_work_mode_e)mode;
+    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
@@ -346,6 +408,11 @@
         LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg);
         return -1;
     }
+    if(*(int *)arg <= LYNQ_WIFI_EVENT_MIN || *(int *)arg >= LYNQ_WIFI_EVENT_MAX)
+    {
+        LYERRLOG("[%s ] The value of arg can only be an integer ranging from 0 to 3p, arg = %d\n", __func__, arg);
+        return -1;
+    }
     wifi_event_handle_sta = event_handle_sta;
     wifi_event_handle = event_handle;
     global_arg = arg;
@@ -450,6 +517,92 @@
 }
 
 /********************************************************************
+* @brief: qser_wifi_ap_get_status, Example Query ap working status
+* @param type [OUT]: lynq_wifi_ap_status_t *, ap working status
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat)
+{
+    int ret = -1;
+    sc_wifi_ap_status_t stat;
+    ret = sc_wifi_ap_get_status((sc_wifi_ap_index_e)idx, &stat);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] wifi_ap_get  ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] idx = %d ifname = %s status = %d bssid = %s \n", __func__, idx, stat.ifname, stat.status, stat.bssid);
+    strncpy(ap_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1);
+    ap_stat->status = (lynq_wifi_status_e)stat.status;
+    strncpy(ap_stat->bssid, stat.bssid, sizeof(stat.bssid) - 1);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_acl_set, Set the WiFi2.4G or 5G whitelist
+* @param idx [IN]: int, Set 2.4G or 5G
+* @param acl_rule [IN]: lynq_wifi_mac_acl_rule_e, Set the blacklist and whitelist mode
+* @param mac_list [IN]: char *, Set the mac address of the whitelist
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list)
+{
+    int ret = -1;
+    if (mac_list == NULL)
+    {
+        LYERRLOG("[%s ] Null pointer mac_list = 0x%p \n", __func__, mac_list);
+        return ret;
+    }
+    if(acl_rule == LYNQ_WIFI_MAC_ACL_RULE_BLACK)
+        ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, SC_WIFI_MAC_ACL_RULE_WHITE, mac_list);
+    ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, (sc_wifi_mac_acl_rule_e)acl_rule, mac_list);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+        return ret;
+    }
+    LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, acl_rule, mac_list);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_acl_get, Get the WiFi2.4G or 5G whitelist
+* @param idx [IN]: int, Set 2.4G or 5G
+* @param acl_rule [OUT]: lynq_wifi_mac_acl_rule_e *, Get the blacklist and whitelist mode
+* @param mac_list [OUT]: char *, Get the mac address of the whitelist
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list)
+{
+    int ret = -1;
+    sc_wifi_ap_param_t param = {0};
+    if (mac_list == NULL || acl_rule == NULL)
+    {
+        LYERRLOG("[%s ] Null pointer acl_rule = 0x%p mac_list = 0x%p \n", __func__, acl_rule, mac_list);
+        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;
+    }
+    *acl_rule = (lynq_wifi_mac_acl_rule_e)param.acl_rule;
+    strncpy(mac_list, param.mac_list, sizeof(param.mac_list) - 1);
+    LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, param.acl_rule, param.mac_list);
+    return 0;
+}
+
+/********************************************************************
 * @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
@@ -777,6 +930,38 @@
 }
 
 /********************************************************************
+* @brief: qser_wifi_ap_auth_get_s, Get the security authentication mode , password group_rekey and  pairwise of 2.4G or 5G
+* @param idx [IN]: int, Set 2.4G or 5G
+* @param auth_mode [OUT]: lynq_wifi_ap_auth_t *, Get the security authentication mode
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode)
+{
+    int ret = -1;
+    sc_wifi_ap_param_t param = {0};
+    if (auth_mode == NULL)
+    {
+        LYERRLOG("[%s ] Null pointer auth_mode = 0x%p\n", __func__, auth_mode);
+        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 auth = %d passwd = %s group_rekey = %d pairwise = %d\n", __func__, idx, param.auth.auth, param.auth.passwd, param.auth.group_rekey, param.auth.pairwise);
+    strncpy(auth_mode->passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1);
+    auth_mode->group_rekey = param.auth.group_rekey;
+    auth_mode->pairwise = (lynq_wifi_auth_wpa_psk_e)param.auth.pairwise;
+    auth_mode->auth = sc_to_lynq_auth_mode(param.auth.auth);
+    return 0;
+}
+
+/********************************************************************
 * @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
@@ -898,20 +1083,20 @@
 
 /********************************************************************
 * @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
+* @param param_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  qser_wifi_sta_param_set(lynq_wifi_sta_param_t *param_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));
+    stat.auth = lynq_to_sc_auth_mode(param_stat->auth);
+    stat.pairwise = (sc_wifi_auth_wpa_psk_e )param_stat->pairwise;
+    strncpy(stat.ssid, param_stat->ssid, sizeof(stat.ssid) - 1);
+    strncpy(stat.passwd, param_stat->passwd, sizeof(stat.passwd) - 1);
     ret = sc_wifi_sta_param_set(&stat);
     if (0 != ret)
     {
@@ -924,13 +1109,13 @@
 
 /********************************************************************
 * @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
+* @param param_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  qser_wifi_sta_param_get(lynq_wifi_sta_param_t *param_stat)
 {
     int ret = -1;
     sc_wifi_sta_param_t stat = {0};
@@ -940,10 +1125,48 @@
         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));
+    param_stat->auth = sc_to_lynq_auth_mode(stat.auth);
+    param_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise;
+    strncpy(param_stat->ssid, stat.ssid, sizeof(stat.ssid) - 1);
+    strncpy(param_stat->passwd, stat.passwd, sizeof(stat.passwd) -1);
+    LYINFLOG("[%s ] ret = %d \n", __func__, ret);
+    return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_sta_get_status, Gets the status value associated with sta
+* @param status_stat [OUT]: lynq_wifi_sta_status_t *, Gets the status value associated with sta
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int  qser_wifi_sta_get_status(lynq_wifi_sta_status_t *status_stat)
+{
+    int ret = -1;
+    sc_wifi_sta_status_t stat;
+    ret = sc_wifi_sta_get_status(&stat);
+    if (0 != ret)
+    {
+        LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret);
+        return ret;
+    }
+    //print_sta_status(&stat);
+    status_stat->status = (lynq_wifi_sta_status_e)stat.status;
+    status_stat->signal_level = stat.signal_level;
+    status_stat->has_addr = stat.has_addr;
+    status_stat->has_addr6 = stat.has_addr6;
+    status_stat->reason_code = (lynq_wifi_reason_code_e)stat.reason_code;
+    strncpy(status_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1);
+    strncpy(status_stat->ap_bssid, stat.ap_bssid, sizeof(stat.ap_bssid) - 1);
+    if (status_stat->has_addr == 1)
+    {
+        //inet_ntop(AF_INET, &stat.addr, status_stat->addr, sizeof(status_stat->addr));
+    }
+    if (status_stat->has_addr6 == 1)
+    {
+        //inet_ntop(AF_INET6, &stat.addr6, status_stat->addr6, sizeof(status_stat->addr6));
+    }
     LYINFLOG("[%s ] ret = %d \n", __func__, ret);
     return 0;
 }