blob: 877afb94f641067ad05717459113a6ec0ba3e5c7 [file] [log] [blame]
wz.wang73504132024-03-19 16:38:37 +08001#include <stdint.h>
2#include <stdio.h>
3#include <string.h>
wz.wange5a0b912024-03-22 19:11:59 +08004#include "liblog/lynq_deflog.h"
wz.wang73504132024-03-19 16:38:37 +08005
6#ifdef __cplusplus
7extern "C" {
8#endif
9
zw.wang0044b012024-08-08 11:48:49 +080010#include <cfg_api.h>
wz.wang73504132024-03-19 16:38:37 +080011#include "sc_tel_types.h"
12#include "sc_wifi.h"
13#include "lynq-qser-wifi.h"
zw.wangf4578ce2024-08-14 10:58:38 +080014#define WIFI_ENABLE_FLAG_TIME_OUT 10
15#define WIFI_ENABLE_FLAG_DEFAULT -100
wz.wang73504132024-03-19 16:38:37 +080016
wz.wang0feef142024-04-23 18:08:39 +080017static lynq_wifi_event_handle wifi_event_handle = NULL;
18static lynq_wifi_event_handle_sta wifi_event_handle_sta = NULL;
wz.wang9f658672024-04-15 14:23:58 +080019static void *global_arg = NULL;
zw.wangf4578ce2024-08-14 10:58:38 +080020static int wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
wz.wang9f658672024-04-15 14:23:58 +080021
22/********************************************************************
23* @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform
wz.wang0feef142024-04-23 18:08:39 +080024* @return :sc_wifi_auth_e, all
wz.wang9f658672024-04-15 14:23:58 +080025* @todo: NA
26* @see: NA
27* @warning: NA
28*********************************************************************/
29static sc_wifi_auth_e lynq_to_sc_auth_mode(lynq_wifi_auth_e auth_mode)
30{
31 sc_wifi_auth_e type;
32 switch (auth_mode)
33 {
34 case LYNQ_WIFI_AUTH_OPEN:
35 type = SC_WIFI_AUTH_OPEN;
36 break;
37 case LYNQ_WIFI_AUTH_WPA2_PSK:
38 type = SC_WIFI_AUTH_WPA2_PSK;
39 break;
40 case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
41 type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
42 break;
43 case LYNQ_WIFI_AUTH_WPA3_PSK:
44 type = SC_WIFI_AUTH_WPA3_PSK;
45 break;
46 case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
47 type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
48 break;
49 default:
50 type = SC_WIFI_AUTH_MIN;
51 break;
52 }
wz.wang0feef142024-04-23 18:08:39 +080053 return type;
54}
wz.wang9f658672024-04-15 14:23:58 +080055
56/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +080057* @brief: sc_to_lynq_auth_mode, The wifi protocol moves from platform to api
58* @return :lynq_wifi_auth_e, all
wz.wang9f658672024-04-15 14:23:58 +080059* @todo: NA
60* @see: NA
61* @warning: NA
62*********************************************************************/
63static lynq_wifi_auth_e sc_to_lynq_auth_mode(sc_wifi_auth_e auth_mode)
64{
65 lynq_wifi_auth_e type;
66 switch (auth_mode)
67 {
68 case SC_WIFI_AUTH_OPEN:
69 type = LYNQ_WIFI_AUTH_OPEN;
70 break;
71 case SC_WIFI_AUTH_WPA2_PSK:
72 type = LYNQ_WIFI_AUTH_WPA2_PSK;
73 break;
74 case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH:
75 type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH;
76 break;
77 case SC_WIFI_AUTH_WPA3_PSK:
78 type = LYNQ_WIFI_AUTH_WPA3_PSK;
79 break;
80 case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH:
81 type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH;
82 break;
83 default:
84 type = LYNQ_WIFI_AUTH_MIN;
85 break;
86 }
wz.wang0feef142024-04-23 18:08:39 +080087 return type;
88}
89
90/********************************************************************
91* @brief: lynq_to_sc_mode, The wifi protocol is transferred from api to platform
92* @return :sc_wifi_ap_mode_type_e, all
93* @todo: NA
94* @see: NA
95* @warning: NA
96*********************************************************************/
97static sc_wifi_ap_mode_type_e lynq_to_sc_mode(lynq_wifi_mode_type_e mode)
98{
99 sc_wifi_ap_mode_type_e type;
100 switch (mode)
101 {
102 case LYNQ_WIFI_MODE_80211BGN:
103 type = SC_WIFI_AP_MODE_80211BGN;
104 break;
105 case LYNQ_WIFI_MODE_80211BGNAX_2G:
106 type = SC_WIFI_AP_MODE_80211BGNAX_2G;
107 break;
108 case LYNQ_WIFI_MODE_80211AN:
109 type = SC_WIFI_AP_MODE_80211AN;
110 break;
111 case LYNQ_WIFI_MODE_80211ANAC:
112 type = SC_WIFI_AP_MODE_80211ANAC;
113 break;
114 case LYNQ_WIFI_MODE_80211ANACAX_5G:
115 type = SC_WIFI_AP_MODE_80211ANACAX_5G;
116 break;
117 default:
118 type = SC_WIFI_AP_MODE_MIN;
119 break;
120 }
121 return type;
122}
123
124/********************************************************************
125* @brief: sc_to_lynq_mode, The encryption mode of wifi is changed from platform to api
126* @return :lynq_wifi_mode_type_e, all
127* @todo: NA
128* @see: NA
129* @warning: NA
130*********************************************************************/
131static lynq_wifi_mode_type_e sc_to_lynq_mode(sc_wifi_ap_mode_type_e mode)
132{
133 lynq_wifi_mode_type_e type;
134 switch (mode)
135 {
136 case SC_WIFI_AP_MODE_80211BGN:
137 type = LYNQ_WIFI_MODE_80211BGN;
138 break;
139 case SC_WIFI_AP_MODE_80211BGNAX_2G:
140 type = LYNQ_WIFI_MODE_80211BGNAX_2G;
141 break;
142 case SC_WIFI_AP_MODE_80211AN:
143 type = LYNQ_WIFI_MODE_80211AN;
144 break;
145 case SC_WIFI_AP_MODE_80211ANAC:
146 type = LYNQ_WIFI_MODE_80211ANAC;
147 break;
148 case SC_WIFI_AP_MODE_80211ANACAX_5G:
149 type = LYNQ_WIFI_MODE_80211ANACAX_5G;
150 break;
151 default:
152 type = LYNQ_WIFI_MODE_MIN;
153 break;
154 }
155 return type;
156}
wz.wang9f658672024-04-15 14:23:58 +0800157
158/********************************************************************
zw.wang0044b012024-08-08 11:48:49 +0800159* @brief: sc_to_lynq_sta_status, sc_wifi_sta_status_t to lynq_wifi_sta_status_t
160* @return :int, all
161* @todo: NA
162* @see: NA
163* @warning: NA
164*********************************************************************/
165static int sc_to_lynq_sta_status(sc_wifi_sta_status_t *stat, lynq_wifi_sta_status_t *status_stat)
166{
167 status_stat->status = (lynq_wifi_sta_status_e)stat->status;
168 status_stat->signal_level = stat->signal_level;
169 status_stat->has_addr = stat->has_addr;
170 status_stat->has_addr6 = stat->has_addr6;
171 status_stat->reason_code = (lynq_wifi_reason_code_e)stat->reason_code;
172 strncpy(status_stat->ifname, stat->ifname, sizeof(stat->ifname) - 1);
173 strncpy(status_stat->ap_bssid, stat->ap_bssid, sizeof(stat->ap_bssid) - 1);
174 if (status_stat->has_addr == 1)
175 {
176 strncpy(status_stat->addr.addr, stat->addr.addr, sizeof(status_stat->addr.addr) - 1);
177 strncpy(status_stat->addr.netmask, stat->addr.netmask, sizeof(status_stat->addr.netmask) - 1);
178 status_stat->addr.subnet_bits = stat->addr.subnet_bits;
179 strncpy(status_stat->addr.gateway, stat->addr.gateway, sizeof(status_stat->addr.gateway) - 1);
180 strncpy(status_stat->addr.dnsp, stat->addr.dnsp, sizeof(status_stat->addr.dnsp) - 1);
181 strncpy(status_stat->addr.dnss, stat->addr.dnss, sizeof(status_stat->addr.dnss) - 1);
182 }
183 if (status_stat->has_addr6 == 1)
184 {
185 strncpy(status_stat->addr6.addr, stat->addr6.addr, sizeof(status_stat->addr6.addr) - 1);
186 strncpy(status_stat->addr6.prefix, stat->addr6.prefix, sizeof(status_stat->addr6.prefix) - 1);
187 status_stat->addr6.prefix_bits = stat->addr6.prefix_bits;
188 strncpy(status_stat->addr6.gateway, stat->addr6.gateway, sizeof(status_stat->addr6.gateway) - 1);
189 strncpy(status_stat->addr6.dnsp, stat->addr6.dnsp, sizeof(status_stat->addr6.dnsp) - 1);
190 strncpy(status_stat->addr6.dnss, stat->addr6.dnss, sizeof(status_stat->addr6.dnss) - 1);
191 }
192 return 0;
193}
194
195/********************************************************************
wz.wang9f658672024-04-15 14:23:58 +0800196* @brief: lynq_user_status, wifi startup callback
197* @return : NA
198* @todo: NA
199* @see: NA
200* @warning: NA
201*********************************************************************/
202static void lynq_user_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status)
203{
zw.wangf4578ce2024-08-14 10:58:38 +0800204 wifi_enable_flag = status;
205 LYINFLOG("%s:%d,%d wifi_enable_flag:%d\n", __func__, pre_status, status, wifi_enable_flag);
wz.wang9f658672024-04-15 14:23:58 +0800206}
207
208/********************************************************************
209* @brief: lynq_user_wifi_service_error, wifi service status callback
210* @return : NA
211* @todo: NA
212* @see: NA
213* @warning: NA
214*********************************************************************/
215static void lynq_user_wifi_service_error(int error)
216{
217 LYINFLOG("%s: %d\n", __func__, error);
218}
219
220/********************************************************************
221* @brief: lynq_user_ap_status, wifi Obtains the ap status callback
222* @return : NA
223* @todo: NA
224* @see: NA
225* @warning: NA
226*********************************************************************/
227static 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)
228{
wz.wang5bbe6d62024-05-29 13:39:35 +0800229 lynq_wifi_event_s event;
230 if (wifi_event_handle != NULL && global_arg != NULL)
wz.wang9f658672024-04-15 14:23:58 +0800231 {
wz.wang5bbe6d62024-05-29 13:39:35 +0800232 if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS)
233 {
234 return;
235 }
zw.wang0044b012024-08-08 11:48:49 +0800236 LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status);
wz.wang5bbe6d62024-05-29 13:39:35 +0800237 event.id = LYNQ_WIFI_EVENT_AP_STATION;
zw.wangf6fbbc02024-09-02 11:43:46 +0800238 event.status = (lynq_wifi_status_e)p_msg->status;
wz.wang5bbe6d62024-05-29 13:39:35 +0800239 wifi_event_handle(&event, global_arg);
wz.wang9f658672024-04-15 14:23:58 +0800240 }
wz.wang5bbe6d62024-05-29 13:39:35 +0800241 else
242 {
wz.wang9f658672024-04-15 14:23:58 +0800243 LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status);
244 }
wz.wang9f658672024-04-15 14:23:58 +0800245}
246
247/********************************************************************
248* @brief: lynq_user_ap_sta_conn_status, wifi as ap is sta information callback
249* @return : NA
250* @todo: NA
251* @see: NA
252* @warning: NA
253*********************************************************************/
254static void lynq_user_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg)
255{
wz.wang5bbe6d62024-05-29 13:39:35 +0800256 char hostname[32] = {0};
257 lynq_wifi_event_s event;
258 int ret = sc_wifi_get_hostname_by_mac(p_msg->macaddr, hostname, sizeof(hostname));
259 if (ret == 0)
wz.wang9f658672024-04-15 14:23:58 +0800260 {
zw.wang0044b012024-08-08 11:48:49 +0800261 LYINFLOG("sta ip not assigned, try again later!\n");
wz.wang9f658672024-04-15 14:23:58 +0800262 }
wz.wang5bbe6d62024-05-29 13:39:35 +0800263 if (wifi_event_handle != NULL && global_arg != NULL)
264 {
265 if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS)
266 {
267 return;
268 }
zw.wang0044b012024-08-08 11:48:49 +0800269 LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname);
270 event.id = LYNQ_WIFI_EVENT_AP_STA_STATUS;
wz.wang5bbe6d62024-05-29 13:39:35 +0800271 event.ap_sta_info.connected = p_msg->is_connected;
272 strncpy(event.ap_sta_info.mac, p_msg->macaddr,
273 sizeof(event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(event.ap_sta_info.mac) : sizeof(p_msg->macaddr));
274 strncpy(event.ap_sta_info.hostname, hostname, sizeof(hostname));
275 wifi_event_handle(&event, global_arg);
wz.wang9f658672024-04-15 14:23:58 +0800276 }
wz.wang5bbe6d62024-05-29 13:39:35 +0800277 else
278 {
279 LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname);
280 }
281}
wz.wang9f658672024-04-15 14:23:58 +0800282
283/********************************************************************
284* @brief: print_sta_status, wifi gets the status callback in sta mode
285* @return : NA
286* @todo: NA
287* @see: NA
288* @warning: NA
289*********************************************************************/
290static void print_sta_status(sc_wifi_sta_status_t *p_msg)
291{
wz.wang72c432c2024-06-18 09:16:26 +0800292 LYINFLOG("%s: %d, %s, %s, %d, %d\n", __func__, p_msg->status, p_msg->ifname, p_msg->ap_bssid,
293 p_msg->signal_level, p_msg->reason_code);
wz.wang9f658672024-04-15 14:23:58 +0800294
wz.wang72c432c2024-06-18 09:16:26 +0800295 if (p_msg->has_addr == 1)
296 {
297 LYINFLOG("[%s]addr ip:%s, netmask:%s, subnet_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__,
298 p_msg->addr.addr, p_msg->addr.netmask, p_msg->addr.subnet_bits,
299 p_msg->addr.gateway, p_msg->addr.dnsp, p_msg->addr.dnss);
300 }
wz.wang9f658672024-04-15 14:23:58 +0800301
wz.wang72c432c2024-06-18 09:16:26 +0800302 if (p_msg->has_addr6 == 1)
303 {
304 LYINFLOG("[%s]addr6 ip:%s, prefix:%s, prefix_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__,
305 p_msg->addr6.addr, p_msg->addr6.prefix, p_msg->addr6.prefix_bits,
306 p_msg->addr6.gateway, p_msg->addr6.dnsp, p_msg->addr6.dnss);
307 }
308 LYINFLOG("%s : sta_status end\n", __func__);
wz.wang9f658672024-04-15 14:23:58 +0800309}
310
311/********************************************************************
312* @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode
313* @return : NA
314* @todo: NA
315* @see: NA
316* @warning: NA
317*********************************************************************/
318static void lynq_user_sta_status_ind(sc_wifi_sta_status_e pre_status,
319 sc_wifi_sta_status_t *p_msg)
320{
zw.wang0044b012024-08-08 11:48:49 +0800321 if (wifi_event_handle != NULL && global_arg != NULL)
322 {
323 lynq_wifi_event_s event;
324 if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS)
325 {
326 return;
327 }
328 LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status);
329 event.id = LYNQ_WIFI_EVENT_STA_STATUS;
330 if(p_msg->status == SC_WIFI_STA_STATUS_CONNECTED)
331 event.sta_status = LYNQ_WIFI_STATION_CONNECTED;
332 else if(p_msg->status == SC_WIFI_STA_STATUS_DISCONNECTED)
333 event.sta_status = LYNQ_WIFI_STATION_DISCONNECTED;
334 else
335 event.sta_status = LYNQ_WIFI_STATION_DISABLE;
336 sc_to_lynq_sta_status(p_msg, &event.sta_status_all);
337 event.sta_status_all.sta_status = event.sta_status;
338 wifi_event_handle(&event, global_arg);
339 }
340 else
341 {
342 print_sta_status(p_msg);
343 }
344
wz.wang9f658672024-04-15 14:23:58 +0800345}
346
347/********************************************************************
348* @brief: lynq_user_sta_scan_result_ind, wifi gets the callback of sta mode traversing the hotspot
349* @return : NA
350* @todo: NA
351* @see: NA
352* @warning: NA
353*********************************************************************/
354static void lynq_user_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg)
355{
wz.wang0feef142024-04-23 18:08:39 +0800356 int i = 0;
357 LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt);
358 if (p_msg->cnt <= 0)
359 {
360 return;
361 }
362 if (wifi_event_handle_sta != NULL)
363 {
364 lynq_wifi_sta_scan_list_t event;
365 event.cnt = p_msg->cnt;
366 for (i = 0; i < event.cnt; i++)
367 {
368 strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid));
369 strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid));
370 event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth);
371 event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher;
372 event.info[i].channel = p_msg->info[i].channel;
373 event.info[i].signal_level = p_msg->info[i].signal_level;
wz.wang5bbe6d62024-05-29 13:39:35 +0800374 event.info[i].frequency = p_msg->info[i].frequency;
375 event.info[i].signal = p_msg->info[i].signal;
wz.wang0feef142024-04-23 18:08:39 +0800376 }
377 wifi_event_handle_sta(&event);
378 }
379 else
380 {
381 for (i = 0; i < p_msg->cnt; i++)
382 {
wz.wang5bbe6d62024-05-29 13:39:35 +0800383 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),
384 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);
wz.wang0feef142024-04-23 18:08:39 +0800385 }
386 }
387}
388
389/********************************************************************
390* @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings
391* @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings
392* @return : int, If equal to 0 succeeds, others fail
393* @todo: NA
394* @see: NA
395* @warning: NA
396*********************************************************************/
397int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type)
398{
399 int ret = -1;
wz.wang5bbe6d62024-05-29 13:39:35 +0800400 sc_wifi_work_mode_e mode;
401 ret = sc_wifi_work_mode_get(&mode);
402 if (0 != ret)
403 {
404 LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret);
405 return ret;
406 }
407 if(mode == (sc_wifi_work_mode_e)type) //The same value is returned
408 {
409 return 0;
410 }
wz.wang0feef142024-04-23 18:08:39 +0800411 ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type);
412 if (0 != ret)
413 {
wz.wang5bbe6d62024-05-29 13:39:35 +0800414 LYERRLOG("[%s ] work_mode set ret = %d\n", __func__,ret);
wz.wang0feef142024-04-23 18:08:39 +0800415 return ret;
416 }
417 LYINFLOG("[%s ]\n", __func__);
418 return 0;
wz.wang9f658672024-04-15 14:23:58 +0800419}
420
421/********************************************************************
wz.wang5bbe6d62024-05-29 13:39:35 +0800422* @brief: qser_wifi_work_mode_get, 2.4g or 5g working mode Gettings
423* @param type [OUT]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Gettings
424* @return : int, If equal to 0 succeeds, others fail
425* @todo: NA
426* @see: NA
427* @warning: NA
428*********************************************************************/
429int qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type)
430{
431 int ret = -1;
432 sc_wifi_work_mode_e mode;
433 ret = sc_wifi_work_mode_get(&mode);
434 if (0 != ret)
435 {
436 LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret);
437 return ret;
438 }
439 *type = (lynq_wifi_work_mode_e)mode;
440 LYINFLOG("[%s ]\n", __func__);
441 return 0;
442}
443
444/********************************************************************
wz.wang9f658672024-04-15 14:23:58 +0800445* @brief: qser_wifi_register_handle, Register callback functions
wz.wang0feef142024-04-23 18:08:39 +0800446* @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function
447* @param event_handle_sta [IN]: Register sta's event callback function
448* @param arg [IN]: void *, Not currently used, but cannot pass a null pointer
wz.wang9f658672024-04-15 14:23:58 +0800449* @return :int, If equal to 0 succeeds, others fail
450* @todo: NA
451* @see: NA
452* @warning: NA
453*********************************************************************/
wz.wang0feef142024-04-23 18:08:39 +0800454int qser_wifi_register_handle(lynq_wifi_event_handle event_handle, lynq_wifi_event_handle_sta event_handle_sta, void *arg)
wz.wang9f658672024-04-15 14:23:58 +0800455{
wz.wang0feef142024-04-23 18:08:39 +0800456 if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL)
wz.wang9f658672024-04-15 14:23:58 +0800457 {
458 LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg);
459 return -1;
460 }
wz.wang5bbe6d62024-05-29 13:39:35 +0800461 if(*(int *)arg <= LYNQ_WIFI_EVENT_MIN || *(int *)arg >= LYNQ_WIFI_EVENT_MAX)
462 {
463 LYERRLOG("[%s ] The value of arg can only be an integer ranging from 0 to 3p, arg = %d\n", __func__, arg);
464 return -1;
465 }
wz.wang0feef142024-04-23 18:08:39 +0800466 wifi_event_handle_sta = event_handle_sta;
wz.wang9f658672024-04-15 14:23:58 +0800467 wifi_event_handle = event_handle;
468 global_arg = arg;
469 return 0;
470}
471
wz.wang73504132024-03-19 16:38:37 +0800472/********************************************************************
473* @brief: qser_wifi_enable, Enable WiFi function
474* @return : int, If equal to 0 succeeds, others fail
475* @todo: NA
476* @see: NA
477* @warning: NA
478*********************************************************************/
479int qser_wifi_enable(void)
480{
zw.wangf4578ce2024-08-14 10:58:38 +0800481 wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
zw.wang0044b012024-08-08 11:48:49 +0800482 char wifiAvailable[8] = {0};
483 sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable));
484 if (!strcmp(wifiAvailable, "0"))
485 {
486 LYERRLOG("[%s ] wifiAvailable has been set to 0. If WiFi is used, set 1 to enable it\n", __func__);
487 return -1;
488 }
wz.wange5a0b912024-03-22 19:11:59 +0800489 int ret = -1;
490 ret = sc_wifi_init();
wz.wang73504132024-03-19 16:38:37 +0800491 if (0 != ret)
492 {
wz.wang9f658672024-04-15 14:23:58 +0800493 LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret);
494 return ret;
495 }
496
497 //wifi
498 ret = sc_wifi_set_enable_status_ind_cb(lynq_user_status);
499 if (0 != ret)
500 {
501 LYERRLOG("[%s ] Request lynq_user_status ret = %d fail\n", __func__,ret);
502 return ret;
503 }
504
505 //ap
506 ret = sc_wifi_ap_set_status_ind_cb(lynq_user_ap_status);
507 if (0 != ret)
508 {
509 LYERRLOG("[%s ] Request lynq_user_ap_status ret = %d fail\n", __func__,ret);
510 return ret;
511 }
512 ret = sc_wifi_set_ap_sta_connect_ind_cb(lynq_user_ap_sta_conn_status);
513 if (0 != ret)
514 {
515 LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status ret = %d fail\n", __func__,ret);
516 return ret;
517 }
518
519 //sta
520 ret = sc_wifi_sta_set_status_ind_cb(lynq_user_sta_status_ind);
521 if (0 != ret)
522 {
523 LYERRLOG("[%s ] Request lynq_user_sta_status_ind ret = %d fail\n", __func__,ret);
524 return ret;
525 }
526 ret = sc_wifi_sta_set_scan_result_ind_cb(lynq_user_sta_scan_result_ind);
527 if (0 != ret)
528 {
529 LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind ret = %d fail\n", __func__,ret);
530 return ret;
531 }
532 //proxy
533 ret = sc_wifi_set_service_error_cb(lynq_user_wifi_service_error);
534 if (0 != ret)
535 {
536 LYERRLOG("[%s ] Request lynq_user_wifi_service_error ret = %d fail\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +0800537 return ret;
wz.wang73504132024-03-19 16:38:37 +0800538 }
wz.wange5a0b912024-03-22 19:11:59 +0800539
540 ret = sc_wifi_enable();
541 if (0 != ret)
542 {
wz.wang9f658672024-04-15 14:23:58 +0800543 LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +0800544 return ret;
545 }
zw.wangf4578ce2024-08-14 10:58:38 +0800546 for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++)
547 {
548 if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT)
549 sleep(1);
550 else
551 break;
552 }
553 switch (wifi_enable_flag)
554 {
555 case SC_WIFI_STATUS_DISABLED:
556 ret = 1;
557 break;
558 case SC_WIFI_STATUS_ENABLED:
559 ret = 0;
560 break;
561 case SC_WIFI_STATUS_INVALID_MAC:
562 ret = 7;
563 break;
564 case SC_WIFI_STATUS_DEV_INIT_FAIL:
565 ret = 6;
566 break;
567 case SC_WIFI_STATUS_FIRMWARE_CRASH:
568 ret = 12;
569 break;
570 default:
571 ret = -1;
572 break;
573 }
wz.wange5a0b912024-03-22 19:11:59 +0800574 LYINFLOG("[%s ]\n", __func__);
zw.wangf4578ce2024-08-14 10:58:38 +0800575 return ret;
wz.wang73504132024-03-19 16:38:37 +0800576}
577
578/********************************************************************
579* @brief: qser_wifi_disable, Turn off WiFi
580* @return : int, If equal to 0 succeeds, others fail
581* @todo: NA
582* @see: NA
583* @warning: NA
584*********************************************************************/
585int qser_wifi_disable(void)
586{
wz.wange5a0b912024-03-22 19:11:59 +0800587 int ret = -1;
zw.wangf4578ce2024-08-14 10:58:38 +0800588 wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT;
wz.wange5a0b912024-03-22 19:11:59 +0800589 ret = sc_wifi_disable();
wz.wang73504132024-03-19 16:38:37 +0800590 if (0 != ret)
591 {
wz.wang0feef142024-04-23 18:08:39 +0800592 LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +0800593 return ret;
wz.wang73504132024-03-19 16:38:37 +0800594 }
zw.wangf4578ce2024-08-14 10:58:38 +0800595 for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++)
596 {
597 if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT)
598 sleep(1);
599 else
600 break;
601 }
602 switch (wifi_enable_flag)
603 {
604 case SC_WIFI_STATUS_DISABLED:
605 ret = 0;
606 break;
607 case SC_WIFI_STATUS_INVALID_MAC:
608 ret = 7;
609 break;
610 case SC_WIFI_STATUS_DEV_INIT_FAIL:
611 ret = 6;
612 break;
613 case SC_WIFI_STATUS_FIRMWARE_CRASH:
614 ret = 12;
615 break;
616 default:
617 ret = -1;
618 break;
619 }
620 if (0 != ret)
621 {
622 LYERRLOG("[%s ] disable ret = %d\n", __func__,ret);
623 return ret;
624 }
wz.wange5a0b912024-03-22 19:11:59 +0800625 ret = sc_wifi_uninit();
626 if (0 != ret)
627 {
wz.wang0feef142024-04-23 18:08:39 +0800628 LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +0800629 return ret;
630 }
631 LYINFLOG("[%s ]\n", __func__);
632 return 0;
wz.wang73504132024-03-19 16:38:37 +0800633}
634
635/********************************************************************
wz.wang5bbe6d62024-05-29 13:39:35 +0800636* @brief: qser_wifi_ap_get_status, Example Query ap working status
637* @param type [OUT]: lynq_wifi_ap_status_t *, ap working status
638* @return : int, If equal to 0 succeeds, others fail
639* @todo: NA
640* @see: NA
641* @warning: NA
642*********************************************************************/
643int qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat)
644{
645 int ret = -1;
646 sc_wifi_ap_status_t stat;
647 ret = sc_wifi_ap_get_status((sc_wifi_ap_index_e)idx, &stat);
648 if (0 != ret)
649 {
650 LYERRLOG("[%s ] wifi_ap_get ret = %d\n", __func__,ret);
651 return ret;
652 }
653 LYINFLOG("[%s ] idx = %d ifname = %s status = %d bssid = %s \n", __func__, idx, stat.ifname, stat.status, stat.bssid);
654 strncpy(ap_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1);
655 ap_stat->status = (lynq_wifi_status_e)stat.status;
656 strncpy(ap_stat->bssid, stat.bssid, sizeof(stat.bssid) - 1);
657 return 0;
658}
659
660/********************************************************************
661* @brief: qser_wifi_ap_acl_set, Set the WiFi2.4G or 5G whitelist
662* @param idx [IN]: int, Set 2.4G or 5G
663* @param acl_rule [IN]: lynq_wifi_mac_acl_rule_e, Set the blacklist and whitelist mode
664* @param mac_list [IN]: char *, Set the mac address of the whitelist
665* @return : int, If equal to 0 succeeds, others fail
666* @todo: NA
667* @see: NA
668* @warning: NA
669*********************************************************************/
670int qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list)
671{
672 int ret = -1;
673 if (mac_list == NULL)
674 {
675 LYERRLOG("[%s ] Null pointer mac_list = 0x%p \n", __func__, mac_list);
676 return ret;
677 }
678 if(acl_rule == LYNQ_WIFI_MAC_ACL_RULE_BLACK)
679 ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, SC_WIFI_MAC_ACL_RULE_WHITE, mac_list);
680 ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, (sc_wifi_mac_acl_rule_e)acl_rule, mac_list);
681 if (0 != ret)
682 {
683 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
684 return ret;
685 }
686 LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, acl_rule, mac_list);
687 return 0;
688}
689
690/********************************************************************
691* @brief: qser_wifi_ap_acl_get, Get the WiFi2.4G or 5G whitelist
692* @param idx [IN]: int, Set 2.4G or 5G
693* @param acl_rule [OUT]: lynq_wifi_mac_acl_rule_e *, Get the blacklist and whitelist mode
694* @param mac_list [OUT]: char *, Get the mac address of the whitelist
695* @return : int, If equal to 0 succeeds, others fail
696* @todo: NA
697* @see: NA
698* @warning: NA
699*********************************************************************/
700int qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list)
701{
702 int ret = -1;
703 sc_wifi_ap_param_t param = {0};
704 if (mac_list == NULL || acl_rule == NULL)
705 {
706 LYERRLOG("[%s ] Null pointer acl_rule = 0x%p mac_list = 0x%p \n", __func__, acl_rule, mac_list);
707 return ret;
708 }
709 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
710 if (0 != ret)
711 {
712 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
713 return ret;
714 }
715 *acl_rule = (lynq_wifi_mac_acl_rule_e)param.acl_rule;
716 strncpy(mac_list, param.mac_list, sizeof(param.mac_list) - 1);
717 LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, param.acl_rule, param.mac_list);
718 return 0;
719}
720
721/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800722* @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G
723* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +0800724* @param ssid [IN]: const char *, Set the ssid name
725* @return : int, If equal to 0 succeeds, others fail
726* @todo: NA
727* @see: NA
728* @warning: NA
729*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +0800730int qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid)
wz.wang73504132024-03-19 16:38:37 +0800731{
wz.wange5a0b912024-03-22 19:11:59 +0800732 int ret = -1;
733 if (ssid == NULL)
734 {
735 LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid);
736 return ret;
737 }
738 ret = sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid);
739 if (0 != ret)
740 {
741 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
742 return ret;
743 }
744 LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid);
745 return 0;
746}
747
748/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800749* @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G
750* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +0800751* @param ssid [OUT]: char *, Get the ssid name
752* @return : int, If equal to 0 succeeds, others fail
753* @todo: NA
754* @see: NA
755* @warning: NA
756*********************************************************************/
757int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid)
758{
759 int ret = -1;
760 sc_wifi_ap_param_t param = {0};
761 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
762 if (0 != ret)
763 {
764 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
765 return ret;
766 }
767 LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid);
768 strncpy(ssid, param.ssid, sizeof(param.ssid) - 1);
769 return 0;
wz.wang73504132024-03-19 16:38:37 +0800770}
771
772/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800773* @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden
774* @param idx [IN]: int, Set 2.4G or 5G
wz.wang9f658672024-04-15 14:23:58 +0800775* @param hide [IN]: bool, Set whether the ssid is hidden
776* @return : int, If equal to 0 succeeds, others fail
777* @todo: NA
778* @see: NA
779* @warning: NA
780*********************************************************************/
781int qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide)
782{
783 int ret = -1;
784 ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide);
785 if (0 != ret)
786 {
787 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
788 return ret;
789 }
790 LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide);
791 return 0;
792}
793
794/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800795* @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden
796* @param idx [IN]: int, Set 2.4G or 5G
wz.wang9f658672024-04-15 14:23:58 +0800797* @param hide [OUT]: bool *, Get whether the ssid is hidden
798* @return : int, If equal to 0 succeeds, others fail
799* @todo: NA
800* @see: NA
801* @warning: NA
802*********************************************************************/
803int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide)
804{
805 int ret = -1;
806 sc_wifi_ap_param_t param = {0};
807 if (hide == NULL)
808 {
809 LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide);
810 return ret;
811 }
812 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
813 if (0 != ret)
814 {
815 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
816 return ret;
817 }
818 LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide);
819 *hide = (bool)param.ssid_hide;
820 return 0;
821}
822
823/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800824* @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G
825* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +0800826* @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode
827* @return : int, If equal to 0 succeeds, others fail
828* @todo: NA
829* @see: NA
830* @warning: NA
831*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +0800832int qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode)
wz.wang73504132024-03-19 16:38:37 +0800833{
wz.wange5a0b912024-03-22 19:11:59 +0800834 int ret = -1;
wz.wang0feef142024-04-23 18:08:39 +0800835 ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, lynq_to_sc_mode(mode));
wz.wange5a0b912024-03-22 19:11:59 +0800836 if (0 != ret)
837 {
838 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
839 return ret;
840 }
841 LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode);
842 return 0;
843}
844
845/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800846* @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G
847* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +0800848* @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode
849* @return : int, If equal to 0 succeeds, others fail
850* @todo: NA
851* @see: NA
852* @warning: NA
853*********************************************************************/
854int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode)
855{
856 int ret = -1;
857 sc_wifi_ap_param_t param = {0};
858 if (mode == NULL)
859 {
860 LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode);
861 return ret;
862 }
863 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
864 if (0 != ret)
865 {
866 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
867 return ret;
868 }
869 LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode);
wz.wang0feef142024-04-23 18:08:39 +0800870 *mode = sc_to_lynq_mode(param.mode);
wz.wange5a0b912024-03-22 19:11:59 +0800871 return 0;
wz.wang73504132024-03-19 16:38:37 +0800872}
873
874/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800875* @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G
876* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +0800877* @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth
878* @return : int, If equal to 0 succeeds, others fail
879* @todo: NA
880* @see: NA
881* @warning: NA
882*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +0800883int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth)
wz.wang73504132024-03-19 16:38:37 +0800884{
wz.wange5a0b912024-03-22 19:11:59 +0800885 int ret = -1;
886 ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth);
887 if (0 != ret)
888 {
889 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
890 return ret;
891 }
892 LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth);
893 return 0;
894}
895
896/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800897* @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G
898* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +0800899* @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth
900* @return : int, If equal to 0 succeeds, others fail
901* @todo: NA
902* @see: NA
903* @warning: NA
904*********************************************************************/
905int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth)
906{
907 int ret = -1;
908 sc_wifi_ap_param_t param = {0};
909 if (bandwidth == NULL)
910 {
911 LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth);
912 return ret;
913 }
914 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
915 if (0 != ret)
916 {
917 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
918 return ret;
919 }
920 LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth);
921 *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth;
922 return 0;
wz.wang73504132024-03-19 16:38:37 +0800923}
924
925/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800926* @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G
927* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +0800928* @param country_code [IN]: const char *, Set country code
929* @param channel [IN]: int, Set the channel
930* @return : int, If equal to 0 succeeds, others fail
931* @todo: NA
932* @see: NA
933* @warning: NA
934*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +0800935int qser_wifi_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel)
wz.wang73504132024-03-19 16:38:37 +0800936{
wz.wange5a0b912024-03-22 19:11:59 +0800937 int ret = -1;
938 if (country_code == NULL)
939 {
940 LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code);
941 return ret;
942 }
943 ret = sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel);
944 if (0 != ret)
945 {
946 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
947 return ret;
948 }
949 LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel);
950 return 0;
951}
952
953/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800954* @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G
955* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +0800956* @param country_code [OUT]: char *, Get country code
957* @param channel [OUT]: int *, Get the channel
958* @return : int, If equal to 0 succeeds, others fail
959* @todo: NA
960* @see: NA
961* @warning: NA
962*********************************************************************/
963int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel)
964{
965 int ret = -1;
966 sc_wifi_ap_param_t param = {0};
967 if (country_code == NULL || channel == NULL)
968 {
969 LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel);
970 return ret;
971 }
972 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
973 if (0 != ret)
974 {
975 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
976 return ret;
977 }
978 LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel);
979 strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1);
980 *channel = param.channel;
981 return 0;
wz.wang73504132024-03-19 16:38:37 +0800982}
983
984/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +0800985* @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G
986* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +0800987* @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode
988* @param auth_passwd [IN]: const char *, Set password
989* @return : int, If equal to 0 succeeds, others fail
990* @todo: NA
991* @see: NA
992* @warning: NA
993*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +0800994int qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd)
wz.wang73504132024-03-19 16:38:37 +0800995{
wz.wange5a0b912024-03-22 19:11:59 +0800996 int ret = -1;
wz.wange5a0b912024-03-22 19:11:59 +0800997 if (auth_passwd == NULL)
998 {
999 LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd);
1000 return ret;
1001 }
wz.wang9f658672024-04-15 14:23:58 +08001002
wz.wang73504132024-03-19 16:38:37 +08001003 sc_wifi_ap_auth_t auth;
wz.wang9f658672024-04-15 14:23:58 +08001004 auth.auth = lynq_to_sc_auth_mode(auth_mode);
wz.wang73504132024-03-19 16:38:37 +08001005 strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1);
wz.wange5a0b912024-03-22 19:11:59 +08001006 ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth);
1007 if (0 != ret)
1008 {
1009 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1010 return ret;
1011 }
wz.wang9f658672024-04-15 14:23:58 +08001012 LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s\n", __func__, idx, auth_mode, "******");
wz.wange5a0b912024-03-22 19:11:59 +08001013 return 0;
1014}
1015
1016/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001017* @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G
1018* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +08001019* @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode
1020* @param auth_passwd [OUT]: char *, Get password
1021* @return : int, If equal to 0 succeeds, others fail
1022* @todo: NA
1023* @see: NA
1024* @warning: NA
1025*********************************************************************/
1026int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd)
1027{
1028 int ret = -1;
1029 sc_wifi_ap_param_t param = {0};
1030 if (auth_mode == NULL || auth_passwd == NULL)
1031 {
1032 LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd);
1033 return ret;
1034 }
1035 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
1036 if (0 != ret)
1037 {
1038 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1039 return ret;
1040 }
1041 LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd);
1042 strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1);
wz.wang9f658672024-04-15 14:23:58 +08001043
1044 *auth_mode = sc_to_lynq_auth_mode(param.auth.auth);
wz.wange5a0b912024-03-22 19:11:59 +08001045 return 0;
wz.wang73504132024-03-19 16:38:37 +08001046}
1047
1048/********************************************************************
wz.wang5bbe6d62024-05-29 13:39:35 +08001049* @brief: qser_wifi_ap_auth_get_s, Get the security authentication mode , password group_rekey and pairwise of 2.4G or 5G
1050* @param idx [IN]: int, Set 2.4G or 5G
1051* @param auth_mode [OUT]: lynq_wifi_ap_auth_t *, Get the security authentication mode
1052* @return : int, If equal to 0 succeeds, others fail
1053* @todo: NA
1054* @see: NA
1055* @warning: NA
1056*********************************************************************/
1057int qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode)
1058{
1059 int ret = -1;
1060 sc_wifi_ap_param_t param = {0};
1061 if (auth_mode == NULL)
1062 {
1063 LYERRLOG("[%s ] Null pointer auth_mode = 0x%p\n", __func__, auth_mode);
1064 return ret;
1065 }
1066 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
1067 if (0 != ret)
1068 {
1069 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1070 return ret;
1071 }
1072 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);
1073 strncpy(auth_mode->passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1);
1074 auth_mode->group_rekey = param.auth.group_rekey;
1075 auth_mode->pairwise = (lynq_wifi_auth_wpa_psk_e)param.auth.pairwise;
1076 auth_mode->auth = sc_to_lynq_auth_mode(param.auth.auth);
1077 return 0;
1078}
1079
1080/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001081* @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G
1082* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +08001083* @param max_sta_num [IN]: int, Set the maximum number
1084* @return : int, If equal to 0 succeeds, others fail
1085* @todo: NA
1086* @see: NA
1087* @warning: NA
1088*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +08001089int qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num)
wz.wang73504132024-03-19 16:38:37 +08001090{
wz.wange5a0b912024-03-22 19:11:59 +08001091 int ret = -1;
1092 ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num);
1093 if (0 != ret)
1094 {
1095 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1096 return ret;
1097 }
1098 LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num);
1099 return 0;
1100}
1101
1102/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001103* @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G
1104* @param idx [IN]: int, Set 2.4G or 5G
wz.wange5a0b912024-03-22 19:11:59 +08001105* @param max_sta_num [OUT]: int *, Get the maximum number
1106* @return : int, If equal to 0 succeeds, others fail
1107* @todo: NA
1108* @see: NA
1109* @warning: NA
1110*********************************************************************/
1111int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num)
1112{
1113 int ret = -1;
1114 sc_wifi_ap_param_t param = {0};
1115 if (max_sta_num == NULL)
1116 {
1117 LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num);
1118 return ret;
1119 }
1120 ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, &param);
1121 if (0 != ret)
1122 {
1123 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1124 return ret;
1125 }
1126 LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num);
1127 *max_sta_num = param.max_sta_num;
1128 return 0;
wz.wang73504132024-03-19 16:38:37 +08001129}
1130
1131/********************************************************************
wz.wang72c432c2024-06-18 09:16:26 +08001132* @brief: qser_wifi_lanhost_get_list, Get sta device information received as an ap for 2.4G or 5G
1133* @param lynq_arrays [OUT]: lynq_lanhost_ts *, Get sta device information received as an ap
1134* @return : int, If equal to 0 succeeds, others fail
1135* @todo: NA
1136* @see: NA
1137* @warning: NA
1138*********************************************************************/
1139int qser_wifi_lanhost_get_list(lynq_lanhost_ts *lynq_arrays)
1140{
1141 int ret = -1;
1142 int i = 0;
1143 sc_lanhost_t array[32] = {0};
1144 if (lynq_arrays == NULL)
1145 {
1146 LYERRLOG("[%s ] Null pointer lynq_arrays = 0x%p\n", __func__, lynq_arrays);
1147 return ret;
1148 }
1149 lynq_arrays->array_len = 32;
zw.wang0044b012024-08-08 11:48:49 +08001150 ret = sc_wifi_lanhost_get_list(array, &lynq_arrays->array_len);
wz.wang72c432c2024-06-18 09:16:26 +08001151 if (0 != ret)
1152 {
1153 LYERRLOG("[%s ] ret = %d\n", __func__, ret);
1154 return ret;
1155 }
1156 LYINFLOG("[%s]ap_lanhost len[%d]\n", __func__, lynq_arrays->array_len);
1157 for (i = 0; i < lynq_arrays->array_len; i++)
1158 {
1159 LYINFLOG("[%s]Element : [%d] ifname = %s macaddr = %s addr = %s name = %s uptime = %d\n", __func__, i,
1160 array[i].ifname, array[i].macaddr, array[i].addr, array[i].name, array[i].uptime);
1161 strncpy(lynq_arrays->array[i].ifname, array[i].ifname, sizeof(lynq_arrays->array[i].ifname) - 1);
1162 strncpy(lynq_arrays->array[i].macaddr, array[i].macaddr, sizeof(lynq_arrays->array[i].macaddr) - 1);
1163 strncpy(lynq_arrays->array[i].addr, array[i].addr, sizeof(lynq_arrays->array[i].addr) - 1);
1164 strncpy(lynq_arrays->array[i].name, array[i].name, sizeof(lynq_arrays->array[i].name) - 1);
1165 lynq_arrays->array[i].uptime = array[i].uptime;
1166 }
1167 return 0;
1168}
1169
1170/********************************************************************
1171* @brief: qser_wifi_get_ap_pkt_stats, Obtain data packets sent and received by ap for 2.4G or 5G
1172* @param idx [IN]: int, Set 2.4G or 5G
1173* @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by ap
1174* @return : int, If equal to 0 succeeds, others fail
1175* @todo: NA
1176* @see: NA
1177* @warning: NA
1178*********************************************************************/
1179int qser_wifi_get_ap_pkt_stats(lynq_wifi_ap_index_e idx, lynq_wifi_pkt_stats_t *pkt_stat)
1180{
1181 int ret = -1;
1182 sc_wifi_pkt_stats_t stat = {0};
1183 if (pkt_stat == NULL)
1184 {
1185 LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat);
1186 return ret;
1187 }
1188 idx = LYNQ_WIFI_AP_INDEX_AP0;
1189 ret = sc_wifi_get_ap_pkt_stats((sc_wifi_ap_index_e)idx, &stat);
1190 if (0 != ret)
1191 {
1192 LYERRLOG("[%s ] ret = %d\n", __func__, ret);
1193 return ret;
1194 }
1195 LYINFLOG("[%s ]ap_pkt_get[%d] rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, idx,
1196 stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped,
1197 stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped);
1198 pkt_stat->rx_packets = stat.rx_packets;
1199 pkt_stat->rx_bytes = stat.rx_bytes;
1200 pkt_stat->rx_errors = stat.rx_errors;
1201 pkt_stat->rx_dropped = stat.rx_dropped;
1202 pkt_stat->tx_packets = stat.tx_packets;
1203 pkt_stat->tx_bytes = stat.tx_bytes;
1204 pkt_stat->tx_errors = stat.tx_errors;
1205 pkt_stat->tx_dropped = stat.tx_dropped;
1206 return 0;
1207}
1208
1209/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001210* @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable
1211* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +08001212* @return : int, If equal to 0 succeeds, others fail
1213* @todo: NA
1214* @see: NA
1215* @warning: NA
1216*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +08001217int qser_wifi_ap_start(lynq_wifi_ap_index_e idx)
wz.wang73504132024-03-19 16:38:37 +08001218{
wz.wange5a0b912024-03-22 19:11:59 +08001219 int ret = -1;
1220 ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
1221 if (0 != ret)
1222 {
1223 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1224 return ret;
1225 }
1226 LYINFLOG("[%s ] idx = %d \n", __func__, idx);
1227 return 0;
wz.wang73504132024-03-19 16:38:37 +08001228}
1229
1230/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001231* @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G
1232* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +08001233* @return : int, If equal to 0 succeeds, others fail
1234* @todo: NA
1235* @see: NA
1236* @warning: NA
1237*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +08001238int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx)
wz.wang73504132024-03-19 16:38:37 +08001239{
wz.wange5a0b912024-03-22 19:11:59 +08001240 int ret = -1;
1241 ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
1242 if (0 != ret)
1243 {
1244 LYERRLOG("[%s ] ret = %d\n", __func__,ret);
1245 return ret;
1246 }
1247 LYINFLOG("[%s ] idx = %d \n", __func__, idx);
1248 return 0;
wz.wang73504132024-03-19 16:38:37 +08001249}
1250
1251/********************************************************************
wz.wang0feef142024-04-23 18:08:39 +08001252* @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart
1253* @param idx [IN]: int, Set 2.4G or 5G
wz.wang73504132024-03-19 16:38:37 +08001254* @return : int, If equal to 0 succeeds, others fail
1255* @todo: NA
1256* @see: NA
1257* @warning: NA
1258*********************************************************************/
wz.wange5a0b912024-03-22 19:11:59 +08001259int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx)
wz.wang73504132024-03-19 16:38:37 +08001260{
wz.wange5a0b912024-03-22 19:11:59 +08001261 int ret = -1;
1262 ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx);
wz.wang73504132024-03-19 16:38:37 +08001263 if (0 != ret)
1264 {
wz.wang9f658672024-04-15 14:23:58 +08001265 LYERRLOG("[%s ] stop ret = %d\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +08001266 return ret;
wz.wang73504132024-03-19 16:38:37 +08001267 }
wz.wange5a0b912024-03-22 19:11:59 +08001268 ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx);
1269 if (0 != ret)
1270 {
wz.wang9f658672024-04-15 14:23:58 +08001271 LYERRLOG("[%s ] start ret = %d\n", __func__,ret);
wz.wange5a0b912024-03-22 19:11:59 +08001272 return ret;
1273 }
1274 LYINFLOG("[%s ] idx = %d \n", __func__, idx);
1275 return 0;
wz.wang73504132024-03-19 16:38:37 +08001276}
1277
wz.wang9f658672024-04-15 14:23:58 +08001278/********************************************************************
1279* @brief: qser_wifi_sta_param_set, Set the ssid and password that you need to connect to the access point
wz.wang5bbe6d62024-05-29 13:39:35 +08001280* @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
wz.wang9f658672024-04-15 14:23:58 +08001281* @return : int, If equal to 0 succeeds, others fail
1282* @todo: NA
1283* @see: NA
1284* @warning: NA
1285*********************************************************************/
wz.wang5bbe6d62024-05-29 13:39:35 +08001286int qser_wifi_sta_param_set(lynq_wifi_sta_param_t *param_stat)
wz.wang9f658672024-04-15 14:23:58 +08001287{
1288 int ret = -1;
1289 sc_wifi_sta_param_t stat = {0};
wz.wang5bbe6d62024-05-29 13:39:35 +08001290 stat.auth = lynq_to_sc_auth_mode(param_stat->auth);
1291 stat.pairwise = (sc_wifi_auth_wpa_psk_e )param_stat->pairwise;
1292 strncpy(stat.ssid, param_stat->ssid, sizeof(stat.ssid) - 1);
1293 strncpy(stat.passwd, param_stat->passwd, sizeof(stat.passwd) - 1);
wz.wang9f658672024-04-15 14:23:58 +08001294 ret = sc_wifi_sta_param_set(&stat);
1295 if (0 != ret)
1296 {
1297 LYERRLOG("[%s ] sta_param_set ret = %d\n", __func__,ret);
1298 return ret;
1299 }
1300 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1301 return 0;
1302}
1303
1304/********************************************************************
1305* @brief: qser_wifi_sta_param_get, Get the ssid and password that you need to connect to the access point
wz.wang5bbe6d62024-05-29 13:39:35 +08001306* @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
wz.wang9f658672024-04-15 14:23:58 +08001307* @return : int, If equal to 0 succeeds, others fail
1308* @todo: NA
1309* @see: NA
1310* @warning: NA
1311*********************************************************************/
wz.wang5bbe6d62024-05-29 13:39:35 +08001312int qser_wifi_sta_param_get(lynq_wifi_sta_param_t *param_stat)
wz.wang9f658672024-04-15 14:23:58 +08001313{
1314 int ret = -1;
1315 sc_wifi_sta_param_t stat = {0};
1316 ret = sc_wifi_sta_param_get(&stat);
1317 if (0 != ret)
1318 {
1319 LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret);
1320 return ret;
1321 }
wz.wang5bbe6d62024-05-29 13:39:35 +08001322 param_stat->auth = sc_to_lynq_auth_mode(stat.auth);
1323 param_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise;
1324 strncpy(param_stat->ssid, stat.ssid, sizeof(stat.ssid) - 1);
1325 strncpy(param_stat->passwd, stat.passwd, sizeof(stat.passwd) -1);
1326 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1327 return 0;
1328}
1329
1330/********************************************************************
1331* @brief: qser_wifi_sta_get_status, Gets the status value associated with sta
1332* @param status_stat [OUT]: lynq_wifi_sta_status_t *, Gets the status value associated with sta
1333* @return : int, If equal to 0 succeeds, others fail
1334* @todo: NA
1335* @see: NA
1336* @warning: NA
1337*********************************************************************/
wz.wang72c432c2024-06-18 09:16:26 +08001338int qser_wifi_sta_get_status(lynq_wifi_sta_status_t *status_stat)
wz.wang5bbe6d62024-05-29 13:39:35 +08001339{
1340 int ret = -1;
1341 sc_wifi_sta_status_t stat;
1342 ret = sc_wifi_sta_get_status(&stat);
1343 if (0 != ret)
1344 {
wz.wang72c432c2024-06-18 09:16:26 +08001345 LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__, ret);
wz.wang5bbe6d62024-05-29 13:39:35 +08001346 return ret;
1347 }
wz.wang72c432c2024-06-18 09:16:26 +08001348 print_sta_status(&stat);
zw.wang0044b012024-08-08 11:48:49 +08001349 sc_to_lynq_sta_status(&stat, status_stat);
wz.wang9f658672024-04-15 14:23:58 +08001350 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1351 return 0;
1352}
1353
1354/********************************************************************
wz.wang72c432c2024-06-18 09:16:26 +08001355* @brief: qser_wifi_get_sta_pkt_stats, Obtain data packets sent and received by sta for 2.4G or 5G
1356* @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by sta
1357* @return : int, If equal to 0 succeeds, others fail
1358* @todo: NA
1359* @see: NA
1360* @warning: NA
1361*********************************************************************/
1362int qser_wifi_get_sta_pkt_stats(lynq_wifi_pkt_stats_t *pkt_stat)
1363{
1364 int ret = -1;
1365 sc_wifi_pkt_stats_t stat = {0};
1366 if (pkt_stat == NULL)
1367 {
1368 LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat);
1369 return ret;
1370 }
1371 ret = sc_wifi_get_sta_pkt_stats(&stat);
1372 if (0 != ret)
1373 {
1374 LYERRLOG("[%s ] ret = %d\n", __func__, ret);
1375 return ret;
1376 }
1377 LYINFLOG("[%s ]sta_pkt_get rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__,
1378 stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped,
1379 stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped);
1380 pkt_stat->rx_packets = stat.rx_packets;
1381 pkt_stat->rx_bytes = stat.rx_bytes;
1382 pkt_stat->rx_errors = stat.rx_errors;
1383 pkt_stat->rx_dropped = stat.rx_dropped;
1384 pkt_stat->tx_packets = stat.tx_packets;
1385 pkt_stat->tx_bytes = stat.tx_bytes;
1386 pkt_stat->tx_errors = stat.tx_errors;
1387 pkt_stat->tx_dropped = stat.tx_dropped;
1388 return 0;
1389}
1390
1391/********************************************************************
wz.wang9f658672024-04-15 14:23:58 +08001392* @brief: qser_wifi_sta_start_scan, Scan for ap nodes and return them through callback
1393* @return : int, If equal to 0 succeeds, others fail
1394* @todo: NA
1395* @see: NA
1396* @warning: NA
1397*********************************************************************/
1398int qser_wifi_sta_start_scan(void)
1399{
1400 int ret = -1;
1401 ret = sc_wifi_sta_start_scan();
1402 if (0 != ret)
1403 {
1404 LYERRLOG("[%s ] scan ret = %d\n", __func__,ret);
1405 return ret;
1406 }
1407 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1408 return 0;
1409}
1410
1411/********************************************************************
1412* @brief: qser_wifi_sta_start, To enable sta mode, you need to enable ap mode first
1413* @return : int, If equal to 0 succeeds, others fail
1414* @todo: NA
1415* @see: NA
1416* @warning: NA
1417*********************************************************************/
1418int qser_wifi_sta_start(void)
1419{
1420 int ret = -1;
1421 ret = sc_wifi_sta_start();
1422 if (0 != ret)
1423 {
1424 LYERRLOG("[%s ] sta_start ret = %d\n", __func__,ret);
1425 return ret;
1426 }
1427 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1428 return 0;
1429}
1430
1431/********************************************************************
1432* @brief: qser_wifi_sta_stop, To disable sta mode.
1433* @return : int, If equal to 0 succeeds, others fail
1434* @todo: NA
1435* @see: NA
1436* @warning: NA
1437*********************************************************************/
1438int qser_wifi_sta_stop(void)
1439{
1440 int ret = -1;
1441 ret = sc_wifi_sta_stop();
1442 if (0 != ret)
1443 {
1444 LYERRLOG("[%s ] sta_stop ret = %d\n", __func__,ret);
1445 return ret;
1446 }
1447 LYINFLOG("[%s ] ret = %d \n", __func__, ret);
1448 return 0;
1449}
1450
wz.wange5a0b912024-03-22 19:11:59 +08001451DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI)
wz.wang73504132024-03-19 16:38:37 +08001452
1453#ifdef __cplusplus
1454}
1455#endif