[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/sources/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
index 3e3e049..4c65350 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
@@ -15,6 +15,11 @@
#include <include/lynq-qser-wifi.h>
+void lynq_wifi_event_handle_demo(lynq_wifi_event_s *event, void *arg)
+{
+ printf("[lynq-wifi-demo] %s:%d,%d,%s - %d\n", __func__, event->idx, event->ap_sta_info.connected, event->ap_sta_info.mac, event->status);
+}
+
int main(int argc, char *argv[])
{
if (argc == 2 )
@@ -29,6 +34,10 @@
sprintf(pw, "lynq123456");
qser_wifi_enable(); //enable wifi
qser_wifi_ap_ssid_set(LYNQ_WIFI_AP_INDEX_AP0,"hello"); //Set the ssid of wlan0 to hello
+ if(strcmp(argv[0], "lynq-wifi-demo") == 0)
+ qser_wifi_ap_ssid_hide_set(LYNQ_WIFI_AP_INDEX_AP0,0);
+ else
+ qser_wifi_ap_ssid_hide_set(LYNQ_WIFI_AP_INDEX_AP0,1);
qser_wifi_ap_max_sta_set(LYNQ_WIFI_AP_INDEX_AP0,22); //Example Set the maximum number of connections to 22
qser_wifi_ap_channel_set(LYNQ_WIFI_AP_INDEX_AP0,"CN",13); //Set the country code to CN and channel to 13
qser_wifi_ap_mode_set(LYNQ_WIFI_AP_INDEX_AP0,LYNQ_WIFI_MODE_80211BGN); //Set the working protocol mode of wlan0 to 80211BGN
@@ -38,6 +47,7 @@
else if(strcmp(argv[1], "2") == 0){
char pw[65] = {0};
char ssid[33] = {0};
+ bool hidden = 0;
char country_code[12] = {0};
int channel, max_sta_num;
lynq_wifi_mode_type_e mode;
@@ -47,6 +57,8 @@
qser_wifi_enable(); //enable wifi
ret = qser_wifi_ap_ssid_get(LYNQ_WIFI_AP_INDEX_AP0,ssid); //Gets the ssid of wlan0
printf("[lynq-wifi-demo] ssid=%s ret = %d\n",ssid, ret);
+ ret = qser_wifi_ap_ssid_hide_get(LYNQ_WIFI_AP_INDEX_AP0,&hidden); //Gets whether the ssid state is hidden
+ printf("[lynq-wifi-demo] hidden=%d ret = %d\n",hidden, ret);
ret = qser_wifi_ap_max_sta_get(LYNQ_WIFI_AP_INDEX_AP0,&max_sta_num); //Gets the maximum sta number for wlan0
printf("[lynq-wifi-demo] max_sta_num = %d ret = %d\n",max_sta_num, ret);
ret = qser_wifi_ap_mode_get(LYNQ_WIFI_AP_INDEX_AP0,&mode); //Gets the working protocol mode for wlan0
@@ -58,13 +70,68 @@
ret = qser_wifi_ap_bandwidth_get(LYNQ_WIFI_AP_INDEX_AP0,&bandwidth); //Gets the bandwidth of wlan0
printf("[lynq-wifi-demo] bandwidth = %d ret = %d\n",bandwidth, ret);
}
+ else if(strcmp(argv[1], "3") == 0){
+ qser_wifi_enable(); //enable wifi
+ char ssid[33] = {0};
+ qser_wifi_register_handle(lynq_wifi_event_handle_demo, (void*)ssid);
+ while(1)
+ {
+ sleep(1);
+ }
+ }
+ else if(strcmp(argv[1], "4") == 0){
+ int ret = -1;
+ char ssid[33] = {0};
+ char cmdstr[128]={0};
+ lynq_wifi_sta_param_t stat = {0};
+ qser_wifi_enable(); //enable wifi
+ qser_wifi_register_handle(lynq_wifi_event_handle_demo, (void*)ssid);
+ qser_wifi_ap_start(LYNQ_WIFI_AP_INDEX_AP0); //Set the ap mode of wlan0
+ qser_wifi_sta_start();
+ qser_wifi_sta_start_scan();
+ memset(cmdstr,0,sizeof(cmdstr));
+
+ while (1)
+ {
+ printf("[lynq-wifi-demo]Enter the ssid and password as shown in the following example:ssid auth paris pw ||sta_param_get ||sta_stop\n");
+ if (NULL != fgets(cmdstr, sizeof(cmdstr) - 1, stdin))
+ {
+ if (1 >= strlen(cmdstr))
+ {
+ continue;
+ }
+ if(0 == strncmp(cmdstr, "sta_param_get", strlen(cmdstr) - 1))
+ {
+ ret = qser_wifi_sta_param_get(&stat);
+ printf("[wifi_demo]sta_param_get[%s, %d, %d, %s] ret=%d\n", stat.ssid, stat.auth, stat.pairwise, stat.passwd, ret);
+ continue;
+ }
+ else if(0 == strncmp(cmdstr, "sta_stop", strlen(cmdstr) - 1))
+ {
+ qser_wifi_sta_stop();
+ printf("[lynq-wifi-demo]end \n");
+ break;
+ }
+ else{
+ sscanf(cmdstr, "%s %d %d %s", stat.ssid, &stat.auth, &stat.pairwise, stat.passwd);
+ ret = qser_wifi_sta_param_set(&stat);
+ printf("[lynq-wifi-demo] qser_wifi_sta_param_set ret = %d\n", ret);
+ if(ret == 0)
+ qser_wifi_sta_start();
+ printf("[lynq-wifi-demo]cmdstr = %s\n",cmdstr);
+ }
+ }
+ }
+ }
else{
printf(" [lynq-wifi-demo]Parameter error, please re-enter\n");
}
}
else
{
- printf("[lynq-wifi-demo]Please enter one of the parameters 0,1,2\n");
+ printf("[lynq-wifi-demo]Please enter one of the parameters 0,1,2,3,4\n");
+ printf(" [lynq-wifi-demo]4: sta mode to obtain access point information and set ssid and password and other information connection\n");
+ printf(" [lynq-wifi-demo]3: Obtain sta data information in ap mode\n");
printf(" [lynq-wifi-demo]2: View information such as ssid, password, and channel in ap mode\n");
printf(" [lynq-wifi-demo]1: initializes wifi and enables and sets ap mode\n");
printf(" [lynq-wifi-demo]0: indicates off.\n");
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 fa021c0..a7ed3d5 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
@@ -54,10 +54,61 @@
LYNQ_WIFI_AUTH_MAX
} 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_status_e;
+
+typedef enum {
+ LYNQ_WIFI_STATION_DISABLE = 0, /* WiFi station is not enable */
+ LYNQ_WIFI_STATION_CONNECTED, /* WiFi station is connected hotspot */
+ LYNQ_WIFI_STATION_DISCONNECTED /* WiFi station is disconnect hotspot */
+} lynq_wifi_station_status_e;
+
+typedef enum
+{
+ LYNQ_WIFI_AUTH_WPA_PAIRWISE_MIN = -1,
+ LYNQ_WIFI_AUTH_WPA_PAIRWISE_AUTO = 0, //TKIP & AES
+ LYNQ_WIFI_AUTH_WPA_PAIRWISE_TKIP,
+ LYNQ_WIFI_AUTH_WPA_PAIRWISE_AES,
+ LYNQ_WIFI_AUTH_WPA_PAIRWISE_MAX
+} lynq_wifi_auth_wpa_psk_e;
+
+typedef struct {
+ lynq_wifi_ap_index_e idx;
+ union {
+ /* the LYNQ_WIFI_ENABLE_STATUS or LYNQ_WIFI_DISABLE_STATUS event */
+ lynq_wifi_status_e status;
+ struct {
+ /*
+ * If connected is true, the station is connected wifi hotspot.
+ * If connected is false, the station is disconnected wifi hotspot.
+ */
+ int connected;
+ char mac[18];
+ } 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 void (*lynq_wifi_event_handle)(lynq_wifi_event_s *event, void *arg);
+
int qser_wifi_enable(void);
int qser_wifi_disable(void);
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);
+int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide);
int qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode);
int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode);
int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth);
@@ -71,6 +122,13 @@
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, 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_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 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, ¶m);
+ 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