• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: wifi_device.h 的头文件
15  */
16 
17 
18 #ifndef SERVICE_WIFI_DEVICE_C_H
19 #define SERVICE_WIFI_DEVICE_C_H
20 
21 #include "wifi_event.h"
22 #include "station_info.h"
23 #include "wifi_scan_info.h"
24 #include "errcode.h"
25 #include "wifi_linked_info.h"
26 #include "wifi_device_config.h"
27 #include "plat_device.h"
28 
29 #ifdef __cplusplus
30 #if __cplusplus
31 extern "C" {
32 #endif
33 #endif
34 
35 /**
36  * @defgroup middleware_service_wifi_device WiFi Device
37  * @ingroup  middleware_service_wifi
38  * @{
39  */
40 
41 /**
42  * @if Eng
43  * @brief  Wifi initialize.
44  * @retval ERRCODE_SUCC        Execute successfully.
45  * @retval Other               Error code.
46  * @else
47  * @brief  Wifi初始化。
48  * @retval ERRCODE_SUCC 成功。
49  * @retval Other        失败。
50  * @endif
51  */
52 errcode_t wifi_init(void);
53 
54 /**
55  * @if Eng
56  * @brief  Wifi de-initialize.
57  * @retval ERRCODE_SUCC        Execute successfully.
58  * @retval Other               Error code.
59  * @else
60  * @brief  Wifi去初始化。
61  * @retval ERRCODE_SUCC 成功。
62  * @retval Other        失败。
63  * @endif
64  */
65 errcode_t wifi_deinit(void);
66 
67 /**
68  * @if Eng
69  * @brief  Get wifi initialize status.
70  * @retval 1 Wifi is initialized.
71  * @retval 0 Wifi is not initialized.
72  * @else
73  * @brief  获取WiFi初始化状态。
74  * @retval 1 Wifi已经初始化。
75  * @retval 0 Wifi没有初始化。
76  * @endif
77  */
78 int32_t wifi_is_wifi_inited(void);
79 
80 /**
81  * @if Eng
82  * @brief  Start WiFi station.
83  * @retval ERRCODE_SUCC        Execute successfully.
84  * @retval Other               Execute failed.
85  * @else
86  * @brief  开启STA。
87  * @retval ERRCODE_SUCC 成功。
88  * @retval Other        失败。
89  * @endif
90  */
91 errcode_t wifi_sta_enable(void);
92 
93 /**
94  * @if Eng
95  * @brief  Close wifi station.
96  * @retval ERRCODE_SUCC        Execute successfully.
97  * @retval Other               Execute failed.
98  * @else
99  * @brief  关闭STA。
100  * @retval ERRCODE_SUCC 成功。
101  * @retval Other        失败。
102  * @endif
103  */
104 errcode_t wifi_sta_disable(void);
105 
106 /**
107  * @if Eng
108  * @brief  Get sta enable status.
109  * @retval 1 sta is initialized.
110  * @retval 0 sta is not initialized.
111  * @else
112  * @brief  获取sta使能状态。
113  * @retval 1 sta已经使能。
114  * @retval 0 sta未使能。
115  * @endif
116  */
117 int32_t wifi_is_sta_enabled(void);
118 
119 /**
120  * @if Eng
121  * @brief  Get dev status.
122  * @retval NULL dev is not initialized, otherwise dev is initialized.
123  * @else
124  * @brief  获取dev使能状态。
125  * @retval NULL dev未使能,否则dev使能。
126  * @endif
127  */
128 wifi_dev_t *wifi_get_dev(wifi_iftype_t iftype);
129 
130 /**
131  * @if Eng
132  * @brief  Set Sta protocol mode.
133  * @param  [in]  mode Protocol_mode_enum.
134  * @retval ERRCODE_SUCC        Execute successfully.
135  * @retval Other               Execute failed.
136  * @else
137  * @brief  设置Sta的协议模式。
138  * @param  [in]  mode 协议模式。
139  * @retval ERRCODE_SUCC 成功。
140  * @retval Other        失败。
141  * @endif
142  */
143 errcode_t wifi_sta_set_protocol_mode(protocol_mode_enum mode);
144 
145 /**
146  * @if Eng
147  * @brief  Get Sta protocol mode.
148  * @retval protocol_mode_enum Sta Protocol mode.
149  * @else
150  * @brief  获取Sta的协议模式。
151  * @retval protocol_mode_enum Sta协议模式。
152  * @endif
153  */
154 protocol_mode_enum wifi_sta_get_protocol_mode(void);
155 
156 /**
157  * @if Eng
158  * @brief  Start sta basic scanning in all channels.
159  * @retval ERRCODE_SUCC        Execute successfully.
160  * @retval Other               Execute failed.
161  * @else
162  * @brief  station进行全信道基础扫描。
163  * @retval ERRCODE_SUCC 成功。
164  * @retval Other        失败。
165  * @endif
166  */
167 errcode_t wifi_sta_scan(void);
168 
169 /**
170  * @if Eng
171  * @brief  Start station scanning with specified parameter.
172  * @param  [in]  scan_param Parameters of scan.
173  * @retval ERRCODE_SUCC        Execute successfully.
174  * @retval Other               Execute failed.
175  * @else
176  * @brief  station执行带特定参数的扫描。
177  * @param  [in]  scan_param 扫描网络参数设置。
178  * @retval ERRCODE_SUCC 成功。
179  * @retval Other        失败。
180  * @endif
181  */
182 errcode_t wifi_sta_scan_advance(const wifi_scan_params_stru *scan_param);
183 
184 /**
185  * @if Eng
186  * @brief  Set sta scan policy.
187  * @param  [in]  iftype Interface type.
188  * @param  [in]  scan_strategy scan_strategy parament set.
189  * @retval ERRCODE_SUCC        Execute successfully.
190  * @retval Other               Execute failed.
191  * @else
192  * @brief  station设置扫描参数。
193  * @param  [in]  iftype 接口类型。
194  * @param  [in]  scan_strategy 扫描策略参数配置。
195  * @retval ERRCODE_SUCC 成功。
196  * @retval Other        失败。
197  * @endif
198  */
199 errcode_t wifi_sta_set_scan_policy(wifi_if_type_enum iftype, wifi_scan_strategy_stru *scan_strategy);
200 
201 /**
202  * @if Eng
203  * @brief  Start station scanning with specified parameter.
204  * @param  [in]  scan_param Parameters of scan.
205  * @param  [in]  cb Callback of scan result.
206  * @retval ERRCODE_SUCC        Execute successfully.
207  * @retval Other               Execute failed.
208  * @else
209  * @brief  station执行带特定参数的原始扫描(不经过wpa,回调由用户指定)。
210  * @param  [in]  scan_param 扫描网络参数设置。
211  * @param  [in]  cb 扫描完成函数回调,入参为ext_wifi_scan_result_stru。
212  * @retval ERRCODE_SUCC 成功。
213  * @retval Other        失败。
214  * @endif
215  */
216 errcode_t wifi_raw_scan(wifi_scan_params_stru *scan_param, wifi_scan_no_save_cb cb);
217 
218 /**
219  * @if Eng
220  * @brief  Stop sta scan.
221  * @retval ERRCODE_SUCC        Execute successfully.
222  * @retval Other               Execute failed.
223  * @else
224  * @brief  强制停止Sta全信道扫描。
225  * @retval ERRCODE_SUCC 成功。
226  * @retval Other        失败。
227  * @endif
228  */
229 errcode_t wifi_sta_scan_stop(void);
230 
231 /**
232  * @if Eng
233  * @brief  Get sta scan results.
234  * @param  [out]  result Scan result.
235  * @param  [out]  size Number of scan result.
236  * @retval ERRCODE_SUCC        Execute successfully.
237  * @retval Other               Execute failed.
238  * @else
239  * @brief  获取station扫描结果。
240  * @param  [out]  result 扫描的结果。
241  * @param  [out]  size 扫描到的网络数目。
242  * @retval ERRCODE_SUCC 成功。
243  * @retval Other        失败。
244  * @endif
245  */
246 errcode_t wifi_sta_get_scan_info(wifi_scan_info_stru *result, uint32_t *size);
247 
248 /**
249  * @if Eng
250  * @brief  clear sta scan results.
251  * @retval ERRCODE_SUCC        Execute successfully.
252  * @retval Other               Execute failed.
253  * @else
254  * @brief  清空station扫描结果。
255  * @retval ERRCODE_SUCC 成功。
256  * @retval Other        失败。
257  * @endif
258  */
259 errcode_t wifi_sta_scan_result_clear(void);
260 
261 /**
262  * @if Eng
263  * @brief  wifi set channel.
264  * @retval ERRCODE_SUCC        Execute successfully.
265  * @retval Other               Execute failed.
266  * @else
267  * @brief  切换信道。
268  * @retval ERRCODE_SUCC 成功。
269  * @retval Other        失败。
270  * @endif
271  */
272 errcode_t wifi_set_channel(wifi_if_type_enum iftype, int32_t channel);
273 
274 /**
275  * @if Eng
276  * @brief  wifi get channel.
277  * @retval ERRCODE_SUCC        Execute successfully.
278  * @retval Other               Execute failed.
279  * @else
280  * @brief  获取信道。
281  * @retval ERRCODE_SUCC 成功。
282  * @retval Other        失败。
283  * @endif
284  */
285 errcode_t wifi_get_channel(wifi_if_type_enum iftype, int32_t *channel);
286 
287 #ifdef CONFIG_WNM
288 /**
289  * @if Eng
290  * @brief  send bss query
291  * @retval ERRCODE_SUCC        Execute successfully.
292  * @retval Other               Execute failed.
293  * @else
294  * @brief  发送bss query报文。
295  * @retval ERRCODE_SUCC 成功。
296  * @retval Other        失败。
297  * @endif
298  */
299 errcode_t wifi_sta_wnm_bss_query(int32_t reason_code, int32_t candidate_list);
300 #endif
301 
302 /**
303  * @if Eng
304  * @brief  sta start connect.
305  * @param  [in]  config Connect parameters of network.
306  * @retval ERRCODE_SUCC        Execute successfully.
307  * @retval Other               Execute failed.
308  * @else
309  * @brief  station进行连接网络。
310  * @param  [in]  config 连接网络参数设置。
311  * @retval ERRCODE_SUCC 成功。
312  * @retval Other        失败。
313  * @endif
314  */
315 errcode_t wifi_sta_connect(const wifi_sta_config_stru *config);
316 
317 /**
318  * @if Eng
319  * @brief  Disconnect from network.
320  * @retval ERRCODE_SUCC        Execute successfully.
321  * @retval Other               Execute failed.
322  * @else
323  * @brief  station断开相连的网络。
324  * @retval ERRCODE_SUCC 成功。
325  * @retval Other        失败。
326  * @endif
327  */
328 errcode_t wifi_sta_disconnect(void);
329 
330 /**
331  * @if Eng
332  * @brief  Get status of sta.
333  * @param  [out]  result Connection status.
334  * @retval ERRCODE_SUCC        Execute successfully.
335  * @retval Other               Execute failed.
336  * @else
337  * @brief  获取station连接的网络状态。
338  * @param  [out]  result 连接状态。
339  * @retval ERRCODE_SUCC 成功。
340  * @retval Other        失败。
341  * @endif
342  */
343 errcode_t wifi_sta_get_ap_info(wifi_linked_info_stru *result);
344 
345 /**
346  * @if Eng
347  * @brief  Set reconnect policy.
348  * @param  [in]  enable Enable reconnect.
349  * @param  [in]  seconds Reconnect timeout in seconds for once, range:[2-65535].
350  * @param  [in]  period Reconnect period in seconds, range:[1-65535].
351  * @param  [in]  max_try_count Max reconnect try count number,range:[1-65535].
352  * @retval EXT_WIFI_OK        Execute successfully.
353  * @retval EXT_WIFI_FAIL      Execute failed.
354  * @else
355  * @brief  station设置重新连接网络机制。
356  * @param  [in]  enable 使能重连网络参数。
357  * @param  [in]  seconds 单次重连超时时间,取值[2-65535]。
358  * @param  [in]  period 重连间隔周期,取值[1-65535]。
359  * @param  [in]  max_try_count 最大重连次数,取值[1-65535]。
360  * @retval EXT_WIFI_OK   成功。
361  * @retval EXT_WIFI_FAIL 失败。
362  * @endif
363  */
364 errcode_t wifi_sta_set_reconnect_policy(int32_t enable, uint32_t seconds,
365     uint32_t period, uint32_t max_try_count);
366 
367 /**
368  * @if Eng
369  * @brief  Config pmf settings of sta.
370  * @retval EXT_WIFI_OK        Execute successfully.
371  * @retval EXT_WIFI_FAIL      Execute failed.
372  * @else
373  * @brief  配置station的pmf。
374  * @retval EXT_WIFI_OK   成功。
375  * @retval EXT_WIFI_FAIL 失败。
376  * @endif
377  */
378 errcode_t wifi_sta_set_pmf_mode(wifi_pmf_option_enum pmf);
379 
380 /**
381  * @if Eng
382  * @brief  Get pmf settings of sta.
383  * @retval pmf enum value                       Execute successfully.
384  * @retval WIFI_MGMT_FRAME_PROTECTION_BUTT      Execute failed.
385  * @else
386  * @brief  获取station的pmf设置。
387  * @retval pmf enum value                  成功。
388  * @retval WIFI_MGMT_FRAME_PROTECTION_BUTT 失败。
389  * @endif
390  */
391 wifi_pmf_option_enum wifi_sta_get_pmf_mode(void);
392 
393 /**
394  * @if Eng
395  * @brief  Get Status Codes for Authentication and Association Frames.
396  * @retval Status Codes value   Execute successfully.
397  * @retval -1                   Execute failed.
398  * @else
399  * @brief  查询Authentication与Association帧status code。
400  * @retval Status Codes value   成功。
401  * @retval -1                   失败。
402  * @endif
403  */
404 int16_t wifi_sta_get_connect_status_code(void);
405 
406 /**
407  * @if Eng
408  * @brief  Register receive callback for management frame.
409  * @param  [in]  data_cb Callback function pointer.
410  * @param  [in]  mode Mode of receiving management frame.
411  * @retval EXT_WIFI_OK        Execute successfully.
412  * @retval EXT_WIFI_FAIL      Execute failed.
413  * @else
414  * @brief  注册管理帧收包回调函数。
415  * @param  [in]  data_cb 管理帧上报回调函数。
416  * @param  [in]  mode 上报管理帧模式。
417  * @retval EXT_WIFI_OK        成功。
418  * @retval EXT_WIFI_FAIL      失败。
419  * @endif
420  */
421 errcode_t wifi_set_mgmt_frame_rx_cb(wifi_rx_mgmt_cb data_cb, uint8_t mode);
422 
423 /**
424  * @if Eng
425  * @brief  Set monitor mode.
426  * @param  [in]  iftype Interface type.
427  * @param  [in]  enable Enable(1) or disable(0).
428  * @param  [in]  filter Filtered frame type enum.
429  * @retval EXT_WIFI_OK        Execute successfully.
430  * @retval EXT_WIFI_FAIL      Execute failed.
431  * @else
432  * @brief  设置混杂模式。
433  * @param  [in]  iftype 接口类型。
434  * @param  [in]  enable 开启/关闭。
435  * @param  [in]  filter 过滤列表。
436  * @retval EXT_WIFI_OK   成功。
437  * @retval EXT_WIFI_FAIL 失败。
438  * @endif
439  */
440 errcode_t wifi_set_promis_mode(wifi_if_type_enum iftype, int32_t enable, const wifi_ptype_filter_stru *filter);
441 
442 /**
443  * @if Eng
444  * @brief  Register receive callback in monitor mode.
445  * @param  [in]  data_cb Callback function pointer.
446  * @retval EXT_WIFI_OK        Execute successfully.
447  * @retval EXT_WIFI_FAIL      Execute failed.
448  * @else
449  * @brief  注册混杂模式的收包回调函数。
450  * @param  [in]  data_cb 混杂模式回调函数。
451  * @retval EXT_WIFI_OK        成功。
452  * @retval EXT_WIFI_FAIL      失败。
453  * @endif
454  */
455 errcode_t wifi_set_promis_rx_pkt_cb(wifi_promis_cb data_cb);
456 
457 /**
458  * @if Eng
459  * @brief  Start fast connect.
460  * @param  [in]  fast_request  Fast connect parameters.
461  * @retval ERRCODE_SUCC        Execute successfully.
462  * @retval Other               Execute failed.
463  * @else
464  * @brief  station进行快速连接网络。
465  * @param  [in]  fast_request  快速连接网络参数。
466  * @retval ERRCODE_SUCC        成功。
467  * @retval Other               失败。
468  * @endif
469  */
470 errcode_t wifi_sta_fast_connect(const wifi_fast_connect_stru *fast_request);
471 
472 /**
473  * @if Eng
474  * @brief  Event processing interface for app registration.
475  * @param  [in]  event Callback function registered by the app.
476  * @retval ERRCODE_SUCC        Execute successfully.
477  * @retval Other               Error code.
478  * @else
479  * @brief  APP注册的事件处理接口。
480  * @param  [in]  event APP注册的回调函数。
481  * @retval ERRCODE_SUCC        成功。
482  * @retval Other               失败。
483  * @endif
484  */
485 errcode_t wifi_register_event_cb(const wifi_event_stru *event);
486 
487 /**
488  * @if Eng
489  * @brief  Event processing interface for app unregistration.
490  * @param  [in]  event Callback function to be canceled.
491  * @retval ERRCODE_SUCC        Execute successfully.
492  * @retval Other               Error code.
493  * @else
494  * @brief  APP去注册的事件处理接口。
495  * @param  [in]  event 待撤销的回调函数。
496  * @retval ERRCODE_SUCC        成功。
497  * @retval Other               失败。
498  * @endif
499  */
500 errcode_t wifi_unregister_event_cb(const wifi_event_stru *event);
501 
502 /**
503  * @if Eng
504  * @brief  Add user IEs to management frame.
505  * @param  [in]  iftype Interface type.
506  * @param  [in]  ie_index IE index, four indexes are available. That is,
507  *                        a maximum of four user-defined IEs can be inserted or deleted in a single management frame.
508  * @param  [in]  frame_type_bitmap Types of frames that can be inserted into the IE,
509  *                                 bit0 is beacon, bit1 is probe request, bit2 is probe response.
510  * @param  [in]  ie User IE value.
511  * @param  [in]  ie_len User IE length.
512  * @retval ERRCODE_SUCC        Execute successfully.
513  * @retval Other               Execute failed.
514  * @else
515  * @brief  在管理帧中添加用户IE字段。
516  * @param  [in]  iftype 接口类型。
517  * @param  [in]  ie_index ie索引,有四个索引可供选择,即在单个管理帧中最多支持4个客户自定义IE的插入或删除。
518  * @param  [in]  frame_type_bitmap 可插入IE的帧类型,bit0代表beacon,bit1代表probe request,bit2代表probe response。
519  * @param  [in]  ie 用户IE字段内容。
520  * @param  [in]  ie_len 用户IE字段内容长度。
521  * @retval ERRCODE_SUCC        成功。
522  * @retval Other               失败。
523  * @endif
524  */
525 errcode_t wifi_set_app_ie(wifi_if_type_enum iftype, ie_index_enmu ie_index, uint8_t frame_type_bitmap,
526     const uint8_t *ie, uint16_t ie_len);
527 
528 /**
529  * @if Eng
530  * @brief  Delete user IEs to management frame.
531  * @param  [in]  iftype Interface type.
532  * @param  [in]  ie_index IE index, four indexes are available. That is,
533  *                        a maximum of four user-defined IEs can be inserted or deleted in a single management frame.
534  * @param  [in]  frame_type_bitmap Types of frames that can be inserted into the IE,
535  *                                 bit0 is beacon, bit1 is probe request, bit2 is probe response.
536  * @retval ERRCODE_SUCC        Execute successfully.
537  * @retval Other               Execute failed.
538  * @else
539  * @brief  在管理帧中删除用户IE字段。
540  * @param  [in]  iftype 接口类型。
541  * @param  [in]  ie_index ie索引,有四个索引可供选择,即在单个管理帧中最多支持4个客户自定义IE的插入或删除。
542  * @param  [in]  frame_type_bitmap 可插入IE的帧类型,bit0代表beacon,bit1代表probe request,bit2代表probe response。
543  * @retval ERRCODE_SUCC        成功。
544  * @retval Other               失败。
545  * @endif
546  */
547 errcode_t wifi_del_app_ie(wifi_if_type_enum iftype, ie_index_enmu ie_index, uint8_t frame_type_bitmap);
548 
549 #ifdef _PRE_WLAN_FEATURE_WOW_OFFLOAD
550 /**
551  * @if Eng
552  * @brief  Set wow pattern mode.
553  * @param  [in]  type wow_pattern_type, Wow pattern.
554  * @param  [in]  index Location index.
555  * @param  [in]  pattern Hexadecimal TCP/UDP pattern data.
556  * @retval ERRCODE_SUCC        Execute successfully.
557  * @retval Other               Execute failed.
558  * @else
559  * @brief  设置WoW Pattern模式。
560  * @param  [in]  type Wow Pattern模式。
561  * @param  [in]  index 位置索引。
562  * @param  [in]  pattern 16进制的TCP/UDP pattern数据。
563  * @retval ERRCODE_SUCC        成功。
564  * @retval Other               失败。
565  * @endif
566  */
567 errcode_t wifi_set_wow_pattern(int32_t type, uint8_t index, int8_t *pattern);
568 
569 /**
570  * @if Eng
571  * @brief  WoW sleep enable configuration 1)The wow sleep can be enabled only in STA2.
572  *         2)The value 0 indicates that the WoW sleep is disabled,
573  *         and the value 1 indicates that the WoW sleep is enabled.
574  * @param  [in]  en Enables or disables the function.
575  * @retval ERRCODE_SUCC        Execute successfully.
576  * @retval Other               Execute failed.
577  * @else
578  * @brief  WoW休眠使能配置 1)仅在STA下才能wow休眠使能 2)0代表WoW休眠去使能,1代表WoW休眠使能。
579  * @param  [in]  en 使能和去使能该功能。
580  * @retval ERRCODE_SUCC        成功。
581  * @retval Other               失败。
582  * @endif
583  */
584 errcode_t wifi_set_wow_sleep_mode(uint8_t en);
585 #endif
586 
587 /**
588  * @if Eng
589  * @brief  Start CSI report.
590  * @retval ERRCODE_SUCC        Execute successfully.
591  * @retval Other               Execute failed.
592  * @else
593  * @brief  开启CSI上报。
594  * @retval ERRCODE_SUCC        成功。
595  * @retval Other               失败。
596  * @endif
597  */
598 errcode_t wifi_csi_start(void);
599 
600 /**
601  * @if Eng
602  * @brief  Close CSI report.
603  * @retval ERRCODE_SUCC        Execute successfully.
604  * @retval Other               Execute failed.
605  * @else
606  * @brief  关闭CSI上报。
607  * @retval ERRCODE_SUCC        成功。
608  * @retval Other               失败。
609  * @endif
610  */
611 errcode_t wifi_csi_stop(void);
612 
613 /**
614  * @if Eng
615  * @brief  Config CSI.
616  * @param  [in]  ifname Interface which enable CSI, wlan0 or ap0.
617  * @param  [in]  config CSI's configuration.
618  * @retval ERRCODE_SUCC        Execute successfully.
619  * @retval Other               Execute failed.
620  * @else
621  * @brief  配置CSI。
622  * @param  [in]  ifname 使能CSI,wlan0,ap的接口。
623  * @param  [in]  config CSI配置。
624  * @retval ERRCODE_SUCC        成功。
625  * @retval Other               失败。
626  * @endif
627  */
628 errcode_t wifi_set_csi_config(const int8_t *ifname, const csi_config_stru *config);
629 
630 /**
631  * @if Eng
632  * @brief  Register report callback of CSI.
633  * @param  [in]  data_cb Callback pointer.
634  * @retval ERRCODE_SUCC        Execute successfully.
635  * @retval Other               Error code.
636  * @else
637  * @brief  注册CSI数据上报回调函数。
638  * @param  [in]  data_cb 回调函数。
639  * @retval ERRCODE_SUCC        成功。
640  * @retval Other               失败。
641  * @endif
642  */
643 errcode_t wifi_register_csi_report_cb(wifi_csi_data_cb data_cb);
644 
645 /**
646  * @if Eng
647  * @brief  User-defined packets are sent. The packets must be encapsulated according to the 802.11 protocol format.
648  * @param  [in]  iftype Interface type.
649  * @param  [in]  data Content of the frame to be sent.
650  * @param  [in]  len Length of the frame to be sent.
651  * @retval ERRCODE_SUCC        Execute successfully.
652  * @retval Other               Execute failed.
653  * @else
654  * @brief  发送用户定制报文,报文须按照802.11协议格式封装。
655  * @param  [in]  iftype 接口类型。
656  * @param  [in]  data 待发送帧的内容。
657  * @param  [in]  len 待发送的帧长度。
658  * @retval ERRCODE_SUCC        成功。
659  * @retval Other               失败。
660  * @endif
661  */
662 errcode_t wifi_send_custom_pkt(const wifi_if_type_enum iftype, const uint8_t *data, uint32_t len);
663 
664 /**
665  * @if Eng
666  * @brief  Set maximum software retransmission count for data and mgmt packets.
667  * @param  [in]  type Frame type.
668  * @param  [in]  limit Max software retry count to set.
669  * @retval ERRCODE_SUCC        Execute successfully.
670  * @retval Other               Execute failed.
671  * @else
672  * @brief  设置数据帧和管理帧的最大软件重传次数。
673  * @param  [in]  type 帧类型。
674  * @param  [in]  limit 需要设置的软件最大重传次数。
675  * @retval ERRCODE_SUCC        成功。
676  * @retval Other               失败。
677  * @endif
678  */
679 errcode_t wifi_set_pkt_retry_policy(uint8_t type, uint8_t limit);
680 
681 /**
682  * @if Eng
683  * @brief  Reset the MAC and PHY interfaces to solve the problem of MAC and PHY suspension..
684  * @retval ERRCODE_SUCC        Execute successfully.
685  * @retval Other               Execute failed.
686  * @else
687  * @brief  复位MAC和PHY接口,解决MAC,PHY挂死问题。
688  * @retval ERRCODE_SUCC        成功。
689  * @retval Other               失败。
690  * @endif
691  */
692 errcode_t wifi_reset_mac_phy(void);
693 
694 /**
695  * @if Eng
696  * @brief  Set Linkloss paras.
697  * @param  [in]  linkloss_paras Set linkloss parameters.
698  * @retval EXT_ERR_SUCCESS        Execute successfully.
699  * @retval Other                  Error code.
700  * @else
701  * @brief  设置Linkloss的参数。
702  * @param  [in]  linkloss_paras 设置linkloss相关参数。
703  * @retval EXT_ERR_SUCCESS        成功。
704  * @retval Other                  失败。
705  * @endif
706  */
707 errcode_t wifi_set_linkloss_config(linkloss_paras_stru *linkloss_paras);
708 
709 /**
710  * @if Eng
711  * @brief  Set base mac addr.
712  * @param  [in]  mac_addr mac addr ptr.
713  * @param  [in]  mac_len mac len.
714  * @retval EXT_ERR_SUCCESS        Execute successfully.
715  * @retval Other                  Error code.
716  * @else
717  * @brief  设置基础mac地址。
718  * @param  [in]  mac_addr mac地址指针.
719  * @param  [in]  mac_len mac地址长度.
720  * @retval EXT_ERR_SUCCESS        成功。
721  * @retval Other                  失败。
722  * @endif
723  */
724 errcode_t wifi_set_base_mac_addr(const int8_t *mac_addr, uint8_t mac_len);
725 
726 /**
727  * @if Eng
728  * @brief  Get base mac addr.
729  * @param  [in]  mac_addr mac addr ptr.
730  * @param  [in]  mac_len mac len.
731  * @retval EXT_ERR_SUCCESS        Execute successfully.
732  * @retval Other                  Error code.
733  * @else
734  * @brief  获取基础mac地址。
735  * @param  [in]  mac_addr mac地址指针.
736  * @param  [in]  mac_len mac地址长度.
737  * @retval EXT_ERR_SUCCESS        成功。
738  * @retval Other                  失败。
739  * @endif
740  */
741 errcode_t wifi_get_base_mac_addr(int8_t *mac_addr, uint8_t mac_len);
742 
743 /**
744  * @if Eng
745  * @brief  Set softAP mac addr.
746  * @param  [in]  mac_addr mac addr ptr.
747  * @param  [in]  mac_len mac len.
748  * @retval EXT_ERR_SUCCESS        Execute successfully.
749  * @retval Other                  Error code.
750  * @else
751  * @brief  设置softap mac地址。
752  * @param  [in]  mac_addr mac地址指针.
753  * @param  [in]  mac_len mac地址长度.
754  * @retval EXT_ERR_SUCCESS        成功。
755  * @retval Other                  失败。
756  * @endif
757  */
758 errcode_t wifi_softap_set_mac_addr(const int8_t *mac_addr, uint8_t mac_len);
759 
760 /**
761  * @if Eng
762  * @brief  Get softAP mac addr.
763  * @param  [in]  mac_addr mac addr ptr.
764  * @param  [in]  mac_len mac len.
765  * @retval EXT_ERR_SUCCESS        Execute successfully.
766  * @retval Other                  Error code.
767  * @else
768  * @brief  获取softap mac地址。
769  * @param  [in]  mac_addr mac地址指针.
770  * @param  [in]  mac_len mac地址长度.
771  * @retval EXT_ERR_SUCCESS        成功。
772  * @retval Other                  失败。
773  * @endif
774  */
775 errcode_t wifi_softap_get_mac_addr(int8_t *mac_addr, uint8_t mac_len);
776 
777 /**
778  * @if Eng
779  * @brief  define mac derivation ptr.
780  * @param  [in]  origin_mac input mac addr ptr.
781  * @param  [in]  num input mac len.
782  * @param  [in]  type derivation type,2:sta,3:softAP,7~10:p2p..
783  * @param  [in]  output_mac outputput mac addr ptr.
784  * @param  [in]  out_put_num output mac len.
785  * @retval EXT_ERR_SUCCESS        Execute successfully.
786  * @retval Other                  Error code.
787  * @else
788  * @brief  mac派生方法指针定义。
789  * @param  [in]  origin_mac 输入mac地址。
790  * @param  [in]  num 输入mac地址长度。
791  * @param  [in]  type 派生类型 type,2:sta,3:softAP,7~10:p2p。
792  * @param  [in]  output_mac 输出mac地址。
793  * @param  [in]  out_put_num 输出mac地址长度。
794  * @retval EXT_ERR_SUCCESS        成功。
795  * @retval Other                  失败。
796  * @endif
797  */
798 typedef unsigned int(*wifi_mac_derivation_ptr)(unsigned char *origin_mac, unsigned char num, unsigned char type,
799     unsigned char *output_mac, unsigned char out_put_num);
800 
801 /**
802  * @if Eng
803  * @brief  Set mac derivation method callback.
804  * @param  [in]  ptr callback ptr.
805  * @retval EXT_ERR_SUCCESS        Execute successfully.
806  * @retval Other                  Error code.
807  * @else
808  * @brief  设置mac派生策略。
809  * @param  [in]  ptr 派生方法指针.
810  * @retval EXT_ERR_SUCCESS        成功。
811  * @retval Other                  失败。
812  * @endif
813  */
814 errcode_t wifi_set_mac_derivation_ptr(wifi_mac_derivation_ptr ptr);
815 
816 /**
817  * @if Eng
818  * @brief  Set the low start-up current mode.
819  * @param  [in]  flag Mode setting.
820  * @retval EXT_ERR_SUCCESS     Execute successfully.
821  * @retval Other               Error code.
822  * @else
823  * @brief  设置低启动电流模式。
824  * @param  [in]  flag 模式设置。
825  * @retval EXT_ERR_SUCCESS     成功。
826  * @retval Other               失败。
827  * @endif
828  */
829 errcode_t wifi_set_low_current_boot_mode(uint8_t flag);
830 
831 /**
832  * @if Eng
833  * @brief  Get country code.
834  * @param  [in]  country_code Country_code.
835  * @param  [in]  len Mac addr len.
836  * @retval WIFI_SUCCESS        Execute successfully.
837  * @retval Other               Error code.
838  * @else
839  * @brief  获取国家码。
840  * @param  [in]  country_code 国家码。
841  * @param  [in]  len 国家码数组长度。
842  * @retval WIFI_SUCCESS        成功。
843  * @retval Other               失败。
844  * @endif
845  */
846 errcode_t wifi_get_country_code(int8_t *country_code, uint8_t *len);
847 
848 /**
849  * @if Eng
850  * @brief  Set country code.
851  * @param  [in]  country_code Country_code.
852  * @param  [in]  len Mac addr len.
853  * @retval WIFI_SUCCESS        Execute successfully.
854  * @retval Other               Error code.
855  * @else
856  * @brief  设置国家码。
857  * @param  [in]  country_code 国家码。
858  * @param  [in]  len 国家码数组长度。
859  * @retval WIFI_SUCCESS        成功。
860  * @retval Other               失败。
861  * @endif
862  */
863 errcode_t wifi_set_country_code(const int8_t* country_code, uint8_t len);
864 
865 /**
866  * @if Eng
867  * @brief  Set pm mode.
868  * @param  [in]  ps_switch ps_switch.
869  * @retval WIFI_SUCCESS        Execute successfully.
870  * @retval Other               Error code.
871  * @else
872  * @brief  设置低功耗模式。
873  * @param  [in]  ps_switch 低功耗模式。
874  * @retval WIFI_SUCCESS        成功。
875  * @retval Other               失败。
876  * @endif
877  */
878 errcode_t wifi_sta_set_pm(uint8_t ps_switch);
879 
880 /**
881  * @if Eng
882  * @brief  Set sdp mode.
883  * @param  [in]  iftype Iftype.
884  * @param  [in]  enable Enable.
885  * @param  [in]  ratio Ratio.
886  * @retval WIFI_SUCCESS        Execute successfully.
887  * @retval Other               Execute failed.
888  * @else
889  * @brief  设置sdp模式。
890  * @param  [in]  iftype 接口类型.
891  * @param  [in]  enable 使能开关.
892  * @param  [in]  ratio 比例.
893  * @retval WIFI_SUCCESS        成功。
894  * @retval Other               失败。
895  * @endif
896  */
897 errcode_t wifi_set_sdp_mode(wifi_if_type_enum iftype, int32_t enable, int32_t ratio);
898 
899 /**
900  * @if Eng
901  * @brief  Set sdp subscribe.
902  * @param  [in]  iftype Iftype.
903  * @param  [in]  sdp_subscribe Sdp_subscribe.
904  * @param  [in]  local_handle Local_handle.
905  * @retval WIFI_SUCCESS        Execute successfully.
906  * @retval Other               Execute failed.
907  * @else
908  * @brief  设置sdp subscribe。
909  * @param  [in]  iftype 接口类型.
910  * @param  [in]  sdp_subscribe sdp订阅.
911  * @param  [in]  local_handle 当前句柄.
912  * @retval WIFI_SUCCESS        成功。
913  * @retval Other               失败。
914  * @endif
915  */
916 errcode_t wifi_set_sdp_subscribe(wifi_if_type_enum iftype, char *sdp_subscribe, int32_t local_handle);
917 
918 /**
919 * @if Eng
920 * @brief  WPS pbc connection.
921 * @param  [in]  bssid The bssid parameter can be set to a MAC address or null.
922 * @retval ERRCODE_SUCC        Execute successfully.
923 * @retval Other               Execute failed.
924 * @else
925 * @brief  wps pbc连接。
926 * @param  [in]  bssid bssid可以指定mac或者填NULL。
927 * @retval ERRCODE_SUCC  成功。
928 * @retval Other         失败。
929 * @endif
930 */
931 errcode_t wifi_sta_wps_pbc(uint8_t *bssid);
932 
933 /**
934 * @if Eng
935 * @brief  WPS_PIN connection.
936 * @param  [in]  pin The PIN code in WPS is only a decimal number and contains 8 bytes.
937 * @param  [in]  bssid The bssid parameter can be set to a MAC address or null.
938 * @retval ERRCODE_SUCC        Execute successfully.
939 * @retval Other               Execute failed.
940 * @else
941 * @brief  wps_pin 连接。
942 * @param  [in]  pin WPS中pin码仅限十进制,长度为8 Bytes。
943 * @param  [in]  bssid bssid可以指定mac或者填NULL。
944 * @retval ERRCODE_SUCC  成功。
945 * @retval Other         失败。
946 * @endif
947 */
948 errcode_t wifi_sta_wps_pin(int8_t *pin, uint8_t *bssid);
949 
950 /**
951 * @if Eng
952 * @brief  WPS_PIN connection.
953 * @param  [in]  pin Pin code to be obtained.
954 * @param  [in]  len Length of the PIN code.
955 * @retval ERRCODE_SUCC        Execute successfully.
956 * @retval Other               Execute failed.
957 * @else
958 * @brief  wps_pin 连接。
959 * @param  [in]  pin 待获取pin码。
960 * @param  [in]  len pin码的长度。
961 * @retval ERRCODE_SUCC  成功。
962 * @retval Other         失败。
963 * @endif
964 */
965 errcode_t wifi_sta_get_wps_pin(int8_t* pin, uint32_t len);
966 
967 /**
968 * @if Eng
969 * @brief  Set PSD mode.
970 * @param  [in]  psd_option Type psd option parameters.
971 * @retval ERRCODE_SUCC        Execute successfully.
972 * @retval Other               Execute failed.
973 * @else
974 * @brief  设置PSD模式。
975 * @param  [in]  psd_option 表示psd参数。
976 * @retval ERRCODE_SUCC  成功。
977 * @retval Other         失败。
978 * @endif
979 */
980 errcode_t wifi_set_psd_mode(ext_psd_option_param *psd_option);
981 
982 /**
983 * @if Eng
984 * @brief  Set PSD recallback interface.
985 * @param  [in]  data_cb Callback function pointer.
986 * @retval ERRCODE_SUCC        Execute successfully.
987 * @retval Other               Execute failed.
988 * @else
989 * @brief  设置PSD回调接口。
990 * @param  [in]  data_cb psd回调函数。
991 * @retval ERRCODE_SUCC  成功。
992 * @retval Other         失败。
993 * @endif
994 */
995 errcode_t wifi_set_psd_cb(wifi_psd_cb data_cb);
996 
997 /**
998  * @}
999  */
1000 
1001 #ifdef __cplusplus
1002 #if __cplusplus
1003 }
1004 #endif
1005 #endif
1006 
1007 #endif // SERVICE_WIFI_DEVICE_C_H
1008