[Feature][ZXW-257]wifi status acquisition api 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: I2447228c1da37dc0f81b6dde9f91426b54ffd434
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 c14ce3a..91f1112 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
@@ -1,7 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-
+#include "liblog/lynq_deflog.h"
#ifdef __cplusplus
extern "C" {
@@ -20,12 +20,22 @@
*********************************************************************/
int qser_wifi_enable(void)
{
- int ret = sc_wifi_init();
+ int ret = -1;
+ ret = sc_wifi_init();
if (0 != ret)
{
- return -1;
+ LYERRLOG("[%s ] init : %d ret = %d\n", __func__,ret);
+ return ret;
}
- return sc_wifi_enable();
+
+ ret = sc_wifi_enable();
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] enable : %d ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ]\n", __func__);
+ return 0;
}
/********************************************************************
@@ -37,12 +47,22 @@
*********************************************************************/
int qser_wifi_disable(void)
{
- int ret = sc_wifi_disable();
+ int ret = -1;
+ ret = sc_wifi_disable();
if (0 != ret)
{
- return -1;
+ LYERRLOG("[%s ] disable : %d ret = %d\n", __func__,ret);
+ return ret;
}
- return sc_wifi_uninit();
+
+ ret = sc_wifi_uninit();
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] uninit: %d ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ]\n", __func__);
+ return 0;
}
/********************************************************************
@@ -54,9 +74,46 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_ssid_set(int idx, const char *ssid)
+int qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid)
{
- return sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid);
+ int ret = -1;
+ if (ssid == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid);
+ return ret;
+ }
+ ret = sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid);
+ return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of wlan0 or wlan1
+* @param idx [IN]: int, Set wlan0 or wlan1
+* @param ssid [OUT]: char *, Get the ssid name
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid);
+ strncpy(ssid, param.ssid, sizeof(param.ssid) - 1);
+ return 0;
}
/********************************************************************
@@ -68,8 +125,9 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_mode_set(int idx, lynq_wifi_mode_type_e mode)
+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)
{
@@ -83,7 +141,56 @@
type = SC_WIFI_AP_MODE_MIN;
break;
}
- return sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, type);
+ ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, type);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode);
+ return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_mode_get, Get the working protocol mode of wlan0 or wlan1
+* @param idx [IN]: int, Set wlan0 or wlan1
+* @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ if (mode == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode);
+ return ret;
+ }
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ 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;
+ return 0;
}
/********************************************************************
@@ -95,9 +202,46 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_bandwidth_set(int idx, lynq_wifi_bandwidth_type_e bandwidth)
+int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth)
{
- return sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth);
+ int ret = -1;
+ ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth);
+ return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of wlan0 or wlan1
+* @param idx [IN]: int, Set wlan0 or wlan1
+* @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ if (bandwidth == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth);
+ return ret;
+ }
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth);
+ *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth;
+ return 0;
}
/********************************************************************
@@ -110,9 +254,53 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_channel_set(int idx, const char *country_code, int channel)
+int qser_wifi_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel)
{
- return sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel);
+ int ret = -1;
+ if (country_code == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code);
+ return ret;
+ }
+ ret = sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel);
+ return 0;
+}
+
+/********************************************************************
+* @brief: qser_wifi_ap_channel_get, Get the channel for wlan0 or wlan1
+* @param idx [IN]: int, Set wlan0 or wlan1
+* @param country_code [OUT]: char *, Get country code
+* @param channel [OUT]: int *, Get the channel
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ if (country_code == NULL || channel == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel);
+ return ret;
+ }
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel);
+ strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1);
+ *channel = param.channel;
+ return 0;
}
/********************************************************************
@@ -125,9 +313,15 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_auth_set(int idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd)
+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:
@@ -152,7 +346,67 @@
sc_wifi_ap_auth_t auth;
auth.auth = (sc_wifi_auth_e)type;
strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1);
- return sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth);
+ ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth);
+ if (0 != ret)
+ {
+ 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);
+ return 0;
+}
+
+/********************************************************************
+* @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
+* @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
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ if (auth_mode == NULL || auth_passwd == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd);
+ return ret;
+ }
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ 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;
+ return 0;
}
/********************************************************************
@@ -164,9 +418,46 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_max_sta_set(int idx, int max_sta_num)
+int qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num)
{
- return sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num);
+ int ret = -1;
+ ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num);
+ return 0;
+}
+
+/********************************************************************
+* @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
+* @param max_sta_num [OUT]: int *, Get the maximum number
+* @return : int, If equal to 0 succeeds, others fail
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num)
+{
+ int ret = -1;
+ sc_wifi_ap_param_t param = {0};
+ if (max_sta_num == NULL)
+ {
+ LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num);
+ return ret;
+ }
+ ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num);
+ *max_sta_num = param.max_sta_num;
+ return 0;
}
/********************************************************************
@@ -177,9 +468,17 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_start(int idx)
+int qser_wifi_ap_start(lynq_wifi_ap_index_e idx)
{
- return sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
+ int ret = -1;
+ ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d \n", __func__, idx);
+ return 0;
}
/********************************************************************
@@ -190,9 +489,17 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_stop(int idx)
+int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx)
{
- return sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
+ int ret = -1;
+ ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d \n", __func__, idx);
+ return 0;
}
/********************************************************************
@@ -203,17 +510,26 @@
* @see: NA
* @warning: NA
*********************************************************************/
-int qser_wifi_ap_restart(int idx)
+int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx)
{
- int ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
+ int ret = -1;
+ ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
if (0 != ret)
{
- return -1;
+ LYERRLOG("[%s ] stop: %d ret = %d\n", __func__,ret);
+ return ret;
}
- return sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
+ ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
+ if (0 != ret)
+ {
+ LYERRLOG("[%s ] start: %d ret = %d\n", __func__,ret);
+ return ret;
+ }
+ LYINFLOG("[%s ] idx = %d \n", __func__, idx);
+ return 0;
}
-//DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI)
+DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI)
#ifdef __cplusplus
}