• Home
Name Date Size #Lines LOC

..--

client/12-May-2024-6,6915,867

figures/12-May-2024-

hal/12-May-2024-1,6091,305

hdi_service/12-May-2024-2,1731,888

interfaces/include/12-May-2024-890134

test/12-May-2024-7,1594,893

BUILD.gnD12-May-2024762 2321

README.mdD12-May-202417.1 KiB260226

README_zh.mdD12-May-202429.2 KiB435390

bundle.jsonD12-May-2024972 4443

wlan.gniD12-May-2024722 1816

README.md

1# WLAN<a name="EN-US_TOPIC_0000001078436908"></a>
2
3-   [Introduction](#section11660541593)
4-   [Directory Structure](#section161941989596)
5-   [Available APIs](#section1564411661810)
6-   [Usage Guidelines](#section19806524151819)
7-   [Repositories Involved](#section1371113476307)
8
9## Introduction<a name="section11660541593"></a>
10
11This repository defines and implements the WLAN-related Hardware Driver Interfaces \(HDIs\) which provide the following functionalities:
12
131.  Creating and stopping a channel between the hardware abstraction layer \(HAL\) and the WLAN driver
142.  Obtaining the WLAN features supported by the device
153.  Creating a WLAN feature instance
16
17**Figure  1**  WLAN driver module architecture<a name="fig14142101381112"></a>
18![](figures/wlan-driver-module-architecture.png "wlan-driver-module-architecture")
19
20## Directory Structure<a name="section161941989596"></a>
21
22The directory structure of the WLAN repository is as follows:
23
24```
25/drivers/peripheral/wlan
26├── client             # Client that implements the communication between the user space and kernel space
27│   └── include       # Client header files
28│   └── src           # Client code
29├── hal                # HAL code
30│   └── include       # HAL header files
31│   └── src           # HAL code implementation
32├── interfaces         # APIs exposed externally
33│   └── include       # Header files containing APIs exposed externally
34```
35
36## Available APIs<a name="section1564411661810"></a>
37
38The WLAN HAL module provides APIs for the Wi-Fi service, such as creating and destroying an  **IWiFi**  object and setting the MAC address. The following table lists the APIs.
39
40**Table  1**  APIs provided by the WLAN HAL module
41
42<a name="table1521573319472"></a>
43<table><thead align="left"><tr id="row121519334474"><th class="cellrowborder" valign="top" width="15.079999999999998%" id="mcps1.2.4.1.1"><p id="p1221510339475"><a name="p1221510339475"></a><a name="p1221510339475"></a>Header File</p>
44</th>
45<th class="cellrowborder" valign="top" width="60.33%" id="mcps1.2.4.1.2"><p id="p0215153344716"><a name="p0215153344716"></a><a name="p0215153344716"></a>API</p>
46</th>
47<th class="cellrowborder" valign="top" width="24.59%" id="mcps1.2.4.1.3"><p id="p1421503315478"><a name="p1421503315478"></a><a name="p1421503315478"></a>Description</p>
48</th>
49</tr>
50</thead>
51<tbody><tr id="row112150333476"><td class="cellrowborder" rowspan="12" valign="top" width="15.079999999999998%" headers="mcps1.2.4.1.1 "><p id="p2155710125317"><a name="p2155710125317"></a><a name="p2155710125317"></a>wifi_hal.h</p>
52<p id="p189132019183"><a name="p189132019183"></a><a name="p189132019183"></a></p>
53</td>
54<td class="cellrowborder" valign="top" width="60.33%" headers="mcps1.2.4.1.2 "><p id="p363110387399"><a name="p363110387399"></a><a name="p363110387399"></a>int32_t WifiConstruct(struct IWiFi **wifiInstance);</p>
55</td>
56<td class="cellrowborder" valign="top" width="24.59%" headers="mcps1.2.4.1.3 "><p id="p1363012387393"><a name="p1363012387393"></a><a name="p1363012387393"></a>Creates an <strong id="b1851191156"><a name="b1851191156"></a><a name="b1851191156"></a>IWiFi</strong> object with basic capabilities.</p>
57</td>
58</tr>
59<tr id="row112151233194714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7629163817393"><a name="p7629163817393"></a><a name="p7629163817393"></a>int32_t WifiDestruct(struct IWiFi **wifiInstance);</p>
60</td>
61<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2627638173917"><a name="p2627638173917"></a><a name="p2627638173917"></a>Destroys an <strong id="b1088016455520"><a name="b1088016455520"></a><a name="b1088016455520"></a>IWiFi</strong> object.</p>
62</td>
63<tr id="row1214611564542"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4950434142314"><a name="p4950434142314"></a><a name="p4950434142314"></a>int32_t (*start)(struct IWiFi *);</p>
64</td>
65<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1162543816393"><a name="p1162543816393"></a><a name="p1162543816393"></a>Creates a channel between the HAL and the driver and obtains the NIC supported by the driver.</p>
66</td>
67</tr>
68<tr id="row167876105514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162433816392"><a name="p162433816392"></a><a name="p162433816392"></a>int32_t (*stop)(struct IWiFi *);</p>
69</td>
70<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p186235383393"><a name="p186235383393"></a><a name="p186235383393"></a>Stops the channel between the HAL and the driver.</p>
71</td>
72</tr>
73<tr id="row77607815516"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6760128135514"><a name="p6760128135514"></a><a name="p6760128135514"></a>int32_t (*getSupportFeature)(uint8_t *supType, uint32_t size);</p>
74</td>
75<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1176014845516"><a name="p1176014845516"></a><a name="p1176014845516"></a>Obtains the WLAN features available for the device no matter whether it works as an AP, STA, or P2P server/client.</p>
76</td>
77</tr>
78<tr id="row93918373572"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2039103714572"><a name="p2039103714572"></a><a name="p2039103714572"></a>int32_t (*getSupportCombo)(uint64_t *combo, uint32_t size);</p>
79</td>
80<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p13916375570"><a name="p13916375570"></a><a name="p13916375570"></a>Obtains the WLAN features available for the device that plays different roles simultaneously (any combination of AP, STA, and P2P server/client).</p>
81</td>
82</tr>
83<tr id="row25031321195815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13503142195814"><a name="p13503142195814"></a><a name="p13503142195814"></a>int32_t (*createFeature)(int32_t type, struct IWiFiBaseFeature **ifeature);</p>
84</td>
85<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11503172115585"><a name="p11503172115585"></a><a name="p11503172115585"></a>Creates an <strong id="b85498454446"><a name="b85498454446"></a><a name="b85498454446"></a>IWiFiBaseFeature</strong> object of a specified type.</p>
86</td>
87</tr>
88<tr id="row14371833185819"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1443863325820"><a name="p1443863325820"></a><a name="p1443863325820"></a>int32_t (*getFeatureByIfName)(const char *ifName, struct IWiFiBaseFeature **ifeature);</p>
89</td>
90<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1343819334584"><a name="p1343819334584"></a><a name="p1343819334584"></a>Obtains an <strong id="b1678312213451"><a name="b1678312213451"></a><a name="b1678312213451"></a>IWiFiBaseFeature</strong> object based on a specified network interface name.</p>
91</td>
92</tr>
93<tr id="row03398561587"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1933965615812"><a name="p1933965615812"></a><a name="p1933965615812"></a>int32_t (*registerEventCallback)(CallbackFunc cbFunc);</p>
94</td>
95<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p103396560587"><a name="p103396560587"></a><a name="p103396560587"></a>Registers a callback to listen for IWiFi asynchronous events.</p>
96</td>
97</tr>
98<tr id="row894162955918"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1694112914590"><a name="p1694112914590"></a><a name="p1694112914590"></a>int32_t (*unRegisterEventCallback)(void);</p>
99</td>
100<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p18948295597"><a name="p18948295597"></a><a name="p18948295597"></a>Unregisters an <strong id="b1979834134512"><a name="b1979834134512"></a><a name="b1979834134512"></a>IWiFi</strong> callback.</p>
101</td>
102</tr>
103<tr id="row122731451103"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2273125104"><a name="p2273125104"></a><a name="p2273125104"></a>int32_t (*destroyFeature)(struct IWiFiBaseFeature *ifeature);</p>
104</td>
105<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p92731553017"><a name="p92731553017"></a><a name="p92731553017"></a>Destroys a specified <strong id="b15348165794518"><a name="b15348165794518"></a><a name="b15348165794518"></a>IWiFiBaseFeature</strong> object.</p>
106</td>
107</tr>
108<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*resetDriver)(const uint8_t chipId);</p>
109</td>
110<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>Resets the WLAN driver with a specified chip ID.</p>
111</td>
112</tr>
113<tr id="row27321001058"><td class="cellrowborder" rowspan="2" valign="top" width="15.079999999999998%" headers="mcps1.2.4.1.1 "><p id="p134208191041"><a name="p134208191041"></a><a name="p134208191041"></a>wifi_hal_ap_feature.h</p>
114</td>
115<td class="cellrowborder" valign="top" width="60.33%" headers="mcps1.2.4.1.2 "><p id="p77321105516"><a name="p77321105516"></a><a name="p77321105516"></a>int32_t (*getAssociatedStas)(const struct IWiFiAp *apFeature, struct StaInfo *staInfo, uint32_t count, uint32_t *num);</p>
116</td>
117<td class="cellrowborder" valign="top" width="24.59%" headers="mcps1.2.4.1.3 "><p id="p1673213014513"><a name="p1673213014513"></a><a name="p1673213014513"></a>Obtains information (MAC addresses only in the current version) about all the connected STAs.</p>
118</td>
119</tr>
120<tr id="row39802291664"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149801729465"><a name="p149801729465"></a><a name="p149801729465"></a>int32_t (*setCountryCode)(const struct IWiFiAp *apFeature, const char *code, uint32_t len);</p>
121</td>
122<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p098022910610"><a name="p098022910610"></a><a name="p098022910610"></a>Sets the country/region code.</p>
123</td>
124<tr id="row14149145512411"><td class="cellrowborder" rowspan="1" valign="top" width="15.079999999999998%" headers="mcps1.2.4.1.1 "><p id="p18149155246"><a name="p18149155246"></a><a name="p18149155246"></a>wifi_hal_sta_feature.h</p>
125</td>
126<td class="cellrowborder" valign="top" width="60.33%" headers="mcps1.2.4.1.2 "><p id="p17149165511414"><a name="p17149165511414"></a><a name="p17149165511414"></a>int32_t (*setScanningMacAddres)(const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len);</p>
127</td>
128<td class="cellrowborder" valign="top" width="24.59%" headers="mcps1.2.4.1.3 "><p id="p181491255149"><a name="p181491255149"></a><a name="p181491255149"></a>Sets a single MAC address to scan for.</p>
129</td>
130<tr id="row451796205011"><td class="cellrowborder" rowspan="8" valign="top" width="15.079999999999998%" headers="mcps1.2.4.1.1 "><p id="p2659417135013"><a name="p2659417135013"></a><a name="p2659417135013"></a>wifi_hal_base_feature.h</p>
131</td>
132<td class="cellrowborder" valign="top" width="60.33%" headers="mcps1.2.4.1.2 "><p id="p73831421111010"><a name="p73831421111010"></a><a name="p73831421111010"></a>const char *(*getNetworkIfaceName)(const struct IWiFiBaseFeature *baseFeature);</p>
133</td>
134<td class="cellrowborder" valign="top" width="24.59%" headers="mcps1.2.4.1.3 "><p id="p16363321101014"><a name="p16363321101014"></a><a name="p16363321101014"></a>Obtains the name of a network interface.</p>
135</td>
136</tr>
137<tr id="row1657914017107"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15117233152315"><a name="p15117233152315"></a><a name="p15117233152315"></a>int32_t (*getFeatureType)(const struct IWiFiBaseFeature *);</p>
138</td>
139<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p195182610507"><a name="p195182610507"></a><a name="p195182610507"></a>Obtains the feature type.</p>
140</td>
141</tr>
142<tr id="row5518663503"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p125181260501"><a name="p125181260501"></a><a name="p125181260501"></a>int32_t (*setMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);</p>
143</td>
144<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1151815635014"><a name="p1151815635014"></a><a name="p1151815635014"></a>Sets the MAC address.</p>
145</td>
146</tr>
147<tr id="row851915617503"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p20519865500"><a name="p20519865500"></a><a name="p20519865500"></a>int32_t (*getDeviceMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);</p>
148</td>
149<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p14519469509"><a name="p14519469509"></a><a name="p14519469509"></a>Obtains the device MAC address.</p>
150</td>
151</tr>
152<tr id="row986761516115"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2867181581116"><a name="p2867181581116"></a><a name="p2867181581116"></a>int32_t (*getValidFreqsWithBand)(const struct IWiFiBaseFeature *baseFeature, int32_t band, int32_t *freqs, uint32_t count, uint32_t *num);</p>
153</td>
154<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15867101551112"><a name="p15867101551112"></a><a name="p15867101551112"></a>Obtains the frequencies supported by the 2.4 GHz or 5 GHz band.</p>
155</td>
156</tr>
157<tr id="row18232258171117"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p145195620502"><a name="p145195620502"></a><a name="p145195620502"></a>int32_t (*setTxPower)(const struct IWiFiBaseFeature *, int32_t);</p>
158</td>
159<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p175191863503"><a name="p175191863503"></a><a name="p175191863503"></a>Sets the transmit power.</p>
160</td>
161</tr>
162<tr id="row1744948201219"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7449128101215"><a name="p7449128101215"></a><a name="p7449128101215"></a>int32_t (*getChipId)(const struct IWiFiBaseFeature *baseFeature, uint8_t *chipId);</p>
163</td>
164<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1244998131219"><a name="p1244998131219"></a><a name="p1244998131219"></a>Obtains the chip ID of the current driver.</p>
165</td>
166</tr>
167<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>int32_t (*getIfNamesByChipId)(const uint8_t chipId, char **ifNames, uint32_t *num);</p>
168</td>
169<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>Obtains names of all the NICs of the current chip based on the chip ID.</p>
170</td>
171</tbody>
172</table>
173
174## Usage Guidelines<a name="section19806524151819"></a>
175
176The following describes how to use the WLAN HAL module.
177
1781.  Call the  **WifiConstruct**  function to create an  **IWiFi**  object.
1792.  Use the created  **IWiFi**  object to call the  **start**  function to create a channel between the HAL and the driver and obtain the driver NIC information.
1803.  Call the  **createFeature**  function to create an AP feature or STA feature. You can call functions to perform operations on the created feature \(use an AP feature as an example\).
1814.  Call functions to perform operations, such as calling the  **setMacAddress**  function to set the MAC address and calling the  **getDeviceMacAddress**  function to obtain the device MAC address.
1825.  Call the  **destroyFeature**  function to destroy the created feature.
1836.  Call the  **stop**  function to stop the channel between the HAL and the driver.
1847.  Call the  **WifiDestruct**  function to destroy the  **IWiFi**  object.
185
186The sample code is as follows:
187
188```
189#include "wifi_hal.h"
190#include "wifi_hal_sta_feature.h"
191#include "wifi_hal_ap_feature.h"
192#include "wifi_hal_cmd.h"
193#include "wifi_hal_event.h"
194
195#define MAC_LEN 6
196
197static void *hal_main()
198{
199    int ret;
200    struct IWiFi *wifi;
201
202    /* Create an IWiFi object. */
203    ret = WifiConstruct(&wifi);
204    if (ret != 0 || wifi == NULL) {
205        return;
206    }
207
208    /* Create a channel between the HAL and the driver. */
209    ret = wifi->start(wifi);
210    if (ret != 0) {
211        return;
212    }
213
214    /* Create an AP feature. */
215    ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
216    if (ret != 0) {
217        return;
218    }
219
220    /* Obtain the device MAC address. */
221    unsigned char mac[MAC_LEN] = {0};
222    ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN);
223    if (ret != 0) {
224        return;
225    }
226
227    /* Destroy the created AP feature. */
228    ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
229    if (ret != 0) {
230        return;
231    }
232
233    /* Stop the created channel. */
234    ret = wifi->stop(wifi);
235    if (ret != 0) {
236        return;
237    }
238
239    /* Destroy the created IWiFi object. */
240    ret = WifiDestruct(&wifi);
241    if (ret != 0) {
242        return;
243    }
244    return;
245}
246```
247
248## Repositories Involved<a name="section1371113476307"></a>
249
250[Driver subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/driver.md)
251
252[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README.md)
253
254[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README.md)
255
256[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README.md)
257
258[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral)
259
260

README_zh.md

1# WLAN<a name="ZH-CN_TOPIC_0000001078436908"></a>
2
3## 简介<a name="section11660541593"></a>
4
5该仓下主要包含WLAN相关HDI和HAL接口与实现,提供主要功能包括:
6
71.  创建和销毁IWiFi对象。
82.  创建和销毁HAL层和WLAN驱动的通道。
93.  设置MAC地址、设置国家码、获取网络设备信息等。
10
11**图 1**  WLAN驱动模块架构图<a name="fig14142101381112"></a>
12
13![](figures/wlan-driver-module-architecture_zh.png "wlan-driver-module-architecture_zh")
14
15## 目录<a name="section161941989596"></a>
16
17WLAN源代码目录结构如下所示:
18
19```
20/drivers/peripheral/wlan
21├── client              # 实现用户态与内核态通信的client模块存放目录
22│   └── include         # client相关头文件存放目录
23│   └── src             # client代码存放目录
24├── hal                 # hal层框架代码
25│   └── include         # hal层相关头文件存放目录
26│   └── src             # hal层代码存放目录
27├── hdi_service         # hdi层框架代码
28│   └── service_common  # hdi层通用接口存放目录
29│   └── service_extend  # hdi扩展接口存放目录
30├── interfaces          # hal接口的存放目录
31│   └── include         # 对外提供的接口头文件存放目录
32```
33
34### 接口说明<a name="section1564411661810"></a>
35
36WLAN驱动模块通过HAL/HDI层(HAL是直调,HDI是通过IPC调用)对Wi-Fi Service提供接口,主要功能有:创建/销毁IWiFi对象、设置MAC地址等。提供的接口说明如下表所示:
37
38**表 1**  hal层和hdi层对外接口
39
40<a name="table1521573319472"></a>
41<table><thead align="left"><tr id="row121519334474"><th class="cellrowborder" valign="top" w idth="10.950000000000001%" id="mcps1.2.4.1.1"><p id="p1221510339475"><a name="p1221510339475"></a><a name="p1221510339475"></a>头文件</p>
42</th>
43<th class="cellrowborder" valign="top" width="30.91%" id="mcps1.2.4.1.2"><p id="p0215153344716"><a name="p0215153344716"></a><a name="p0215153344716"></a>HDI接口名称</p>
44</th>
45<th class="cellrowborder" valign="top" width="6.950000000000001%" id="mcps1.2.4.1.1"><p id="p1221510339475"><a name="p1221510339475"></a><a name="p1221510339475"></a>头文件</p>
46</th>
47<th class="cellrowborder" valign="top" width="30.91%" id="mcps1.2.4.1.2"><p id="p0215153344716"><a name="p0215153344716"></a><a name="p0215153344716"></a>HAL接口名称</p>
48</th>
49<th class="cellrowborder" valign="top" width="20.14%" id="mcps1.2.4.1.3"><p id="p1421503315478"><a name="p1421503315478"></a><a name="p1421503315478"></a>功能描述</p>
50</th>
51</tr>
52</thead>
53<tbody><tr id="row112150333476">
54<td class="cellrowborder" rowspan="31" valign="top" width="10.950000000000001%" headers="mcps1.2.4.1.1 "><p id="p2155710125317"><a name="p2155710125317"></a><a name="p2155710125317"></a>v1_1/iwlan_interface.h(V1_1为版本号,随着接口的增加而改变)</p>
55<p id="p189132019183"><a name="p189132019183"></a><a name="p189132019183"></a></p>
56</td>
57<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4950434142314"><a name="p4950434142314"></a><a name="p4950434142314"></a>int32_t (*Start)(struct IWlanInterface *self);</p>
58</td>
59<td class="cellrowborder" rowspan="15" valign="top" width="6.950000000000001%" headers="mcps1.2.4.1.1 "><p id="p2155710125317"><a name="p2155710125317"></a><a name="p2155710125317"></a>wifi_hal.h</p>
60<p id="p189132019183"><a name="p189132019183"></a><a name="p189132019183"></a></p>
61</td>
62<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4950434142314"><a name="p4950434142314"></a><a name="p4950434142314"></a>int32_t (*start)(struct IWiFi *);</p>
63</td>
64<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1162543816393"><a name="p1162543816393"></a><a name="p1162543816393"></a>创建HAL和驱动之间的通道及获取驱动支持的网卡信息。</p>
65</td>
66</tr>
67<tr id="row167876105514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162433816392"><a name="p162433816392"></a><a name="p162433816392"></a>int32_t (*Stop)(struct IWlanInterface *self);</p>
68</td>
69<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162433816392"><a name="p162433816392"></a><a name="p162433816392"></a>int32_t (*stop)(struct IWiFi *);</p>
70</td>
71<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p186235383393"><a name="p186235383393"></a><a name="p186235383393"></a>销毁通道。</p>
72</td>
73</tr>
74<tr id="row77607815516"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6760128135514"><a name="p6760128135514"></a><a name="p6760128135514"></a>int32_t (*GetSupportFeature)(struct IWlanInterface *self, uint8_t* supType, uint32_t* supTypeLen);</p>
75</td>
76<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6760128135514"><a name="p6760128135514"></a><a name="p6760128135514"></a>int32_t (*getSupportFeature)(uint8_t *supType, uint32_t size);</p>
77</td>
78<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1176014845516"><a name="p1176014845516"></a><a name="p1176014845516"></a>获取该设备支持的WLAN特性(不考虑当前的使用状态)。</p>
79</td>
80</tr>
81<tr id="row93918373572"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2039103714572"><a name="p2039103714572"></a><a name="p2039103714572"></a>int32_t (*GetSupportCombo)(struct IWlanInterface *self, uint64_t* combo);</p>
82</td>
83<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2039103714572"><a name="p2039103714572"></a><a name="p2039103714572"></a>int32_t (*getSupportCombo)(uint64_t *combo, uint32_t size);</p>
84</td>
85<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p13916375570"><a name="p13916375570"></a><a name="p13916375570"></a>获取多网卡共存情况。</p>
86</td>
87</tr>
88<tr id="row25031321195815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13503142195814"><a name="p13503142195814"></a><a name="p13503142195814"></a>int32_t (*CreateFeature)(struct IWlanInterface *self, int32_t type, struct HdfFeatureInfo* ifeature);</p>
89</td>
90<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13503142195814"><a name="p13503142195814"></a><a name="p13503142195814"></a>int32_t (*createFeature)(int32_t type, struct IWiFiBaseFeature **ifeature);</p>
91</td>
92<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11503172115585"><a name="p11503172115585"></a><a name="p11503172115585"></a>根据输入类型创建对应的特性。</p>
93</td>
94</tr>
95<tr id="row14371833185819"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1443863325820"><a name="p1443863325820"></a><a name="p1443863325820"></a>int32_t (*GetFeatureByIfName)(struct IWlanInterface *self, const char* ifName, struct HdfFeatureInfo* ifeature);</p>
96</td>
97<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1443863325820"><a name="p1443863325820"></a><a name="p1443863325820"></a>int32_t (*getFeatureByIfName)(const char *ifName, struct IWiFiBaseFeature **ifeature);</p>
98</td>
99<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1343819334584"><a name="p1343819334584"></a><a name="p1343819334584"></a>通过网络接口名字获取对应的特性。</p>
100</td>
101</tr>
102<tr id="row03398561587"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1933965615812"><a name="p1933965615812"></a><a name="p1933965615812"></a>int32_t (*RegisterEventCallback)(struct IWlanInterface *self, struct IWlanCallback* cbFunc, const char* ifName);</p>
103</td>
104<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1933965615812"><a name="p1933965615812"></a><a name="p1933965615812"></a>int32_t (*registerEventCallback)(CallbackFunc cbFunc);</p>
105</td>
106<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p103396560587"><a name="p103396560587"></a><a name="p103396560587"></a>注册IWiFi的回调函数,监听异步事件。</p>
107</td>
108</tr>
109<tr id="row894162955918"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1694112914590"><a name="p1694112914590"></a><a name="p1694112914590"></a>int32_t (*UnregisterEventCallback)(struct IWlanInterface *self, struct IWlanCallback* cbFunc, const char* ifName);</p>
110</td>
111<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1694112914590"><a name="p1694112914590"></a><a name="p1694112914590"></a>int32_t (*unRegisterEventCallback)(void);</p>
112</td>
113<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p18948295597"><a name="p18948295597"></a><a name="p18948295597"></a>去注册IWiFi的回调函数。</p>
114</td>
115</tr>
116<tr id="row122731451103"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2273125104"><a name="p2273125104"></a><a name="p2273125104"></a>int32_t (*DestroyFeature)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature);</p>
117</td>
118<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2273125104"><a name="p2273125104"></a><a name="p2273125104"></a>int32_t (*destroyFeature)(struct IWiFiBaseFeature *ifeature);</p>
119</td>
120<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p92731553017"><a name="p92731553017"></a><a name="p92731553017"></a>销毁对应的特性。</p>
121</td>
122</tr>
123<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*ResetDriver)(struct IWlanInterface *self, uint8_t chipId, const char* ifName);</p>
124</td>
125<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*resetDriver)(const uint8_t chipId);</p>
126</td>
127<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>WLAN驱动进行重置。</p>
128</td>
129</tr>
130<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*GetPowerMode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t* mode);</p>
131</td>
132<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*getPowerMode)(const char *ifName, uint8_t *mode);</p>
133</td>
134<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>获取正在使用的功率模式。</p>
135</td>
136</tr>
137<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*SetPowerMode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t mode);</p>
138</td>
139<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*setPowerMode)(const char *ifName, uint8_t mode);</p>
140</td>
141<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>设置功率模式。</p>
142</td>
143</tr>
144<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*StartChannelMeas)(struct IWlanInterface *self, const char* ifName, const struct MeasChannelParam* measChannelParam);</p>
145</td>
146<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*startChannelMeas)(const char *ifName, const struct MeasParam *measParam);</p>
147</td>
148<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>通过ioctl向底层驱动发送信道测量命令。</p>
149</td>
150</tr>
151<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*GetNetDevInfo)(struct IWlanInterface *self, struct HdfNetDeviceInfoResult* netDeviceInfoResult);</p>
152</td>
153<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*getNetDevInfo)(struct NetDeviceInfoResult *netDeviceInfoResult);</p>
154</td>
155<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>获取网络设备信息(设备索引、网卡名字、MAC等信息)。</p>
156</td>
157</tr>
158<tr id="row172153335473"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*GetChannelMeasResult)(struct IWlanInterface *self, const char* ifName, struct MeasChannelResult* measChannelResult);</p>
159</td>
160<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1292417115515"><a name="p1292417115515"></a><a name="p1292417115515"></a>int32_t (*getChannelMeasResult)(const char *ifName, struct MeasResult *measResult);</p>
161</td>
162<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17272317145516"><a name="p17272317145516"></a><a name="p17272317145516"></a>获取底层上报上来的测量结果。</p>
163</td>
164</tr>
165<tr id="row27321001058"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p77321105516"><a name="p77321105516"></a><a name="p77321105516"></a>int32_t (*GetAssociatedStas)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature,struct HdfStaInfo* staInfo, uint32_t* staInfoLen, uint32_t* num);</p>
166</td>
167<td class="cellrowborder" rowspan="2" valign="top" width="6.950000000000001%" headers="mcps1.2.4.1.1 "><p id="p134208191041"><a name="p134208191041"></a><a name="p134208191041"></a>wifi_hal_ap_feature.h</p>
168</td>
169<td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p77321105516"><a name="p77321105516"></a><a name="p77321105516"></a>int32_t (*getAssociatedStas)(const struct IWiFiAp *apFeature, struct StaInfo *staInfo, uint32_t count, uint32_t *num);</p>
170</td>
171<td class="cellrowborder" valign="top" width="20.14%" headers="mcps1.2.4.1.3 "><p id="p1673213014513"><a name="p1673213014513"></a><a name="p1673213014513"></a>获取连接上的所有STA的信息(目前只包含MAC地址)。</p>
172</td>
173</tr>
174<tr id="row39802291664"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149801729465"><a name="p149801729465"></a><a name="p149801729465"></a>int32_t (*SetCountryCode)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const char* code, uint32_t len);</p>
175</td>
176<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149801729465"><a name="p149801729465"></a><a name="p149801729465"></a>int32_t (*setCountryCode)(const struct IWiFiAp *apFeature, const char *code, uint32_t len);</p>
177</td>
178<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p098022910610"><a name="p098022910610"></a><a name="p098022910610"></a>设置国家码。</p>
179</td>
180</tr>
181<tr id="row14149145512411"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p17149165511414"><a name="p17149165511414"></a><a name="p17149165511414"></a>int32_t (*SetScanningMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const uint8_t* scanMac, uint32_t scanMacLen);</p>
182</td>
183<td class="cellrowborder" rowspan="2" valign="top" width="6.950000000000001%" headers="mcps1.2.4.1.1 "><p id="p18149155246"><a name="p18149155246"></a><a name="p18149155246"></a>wifi_hal_sta_feature.h</p>
184</td>
185<td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p17149165511414"><a name="p17149165511414"></a><a name="p17149165511414"></a>int32_t (*setScanningMacAddres)(const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len);</p>
186</td>
187<td class="cellrowborder" valign="top" width="20.14%" headers="mcps1.2.4.1.3 "><p id="p181491255149"><a name="p181491255149"></a><a name="p181491255149"></a>设置扫描单个MAC地址。</p>
188</td>
189</tr>
190<tr id="row39802291664"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149801729465"><a name="p149801729465"></a><a name="p149801729465"></a>int32_t (*StartScan)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const struct HdfWifiScan* scan);</p>
191</td>
192<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149801729465"><a name="p149801729465"></a><a name="p149801729465"></a>int32_t (*startScan)(const char *ifName, WifiScan *scan);</p>
193</td>
194<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p098022910610"><a name="p098022910610"></a><a name="p098022910610"></a>启动扫描。</p>
195</td>
196</tr>
197<tr id="row451796205011"><td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p73831421111010"><a name="p73831421111010"></a><a name="p73831421111010"></a>int32_t (*GetNetworkIfaceName)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, char* ifName, uint32_t ifNameLen);</p>
198</td>
199<td class="cellrowborder" rowspan="12" valign="top" width="6.950000000000001%" headers="mcps1.2.4.1.1 "><p id="p2659417135013"><a name="p2659417135013"></a><a name="p2659417135013"></a>wifi_hal_base_feature.h</p>
200</td>
201<td class="cellrowborder" valign="top" width="30.91%" headers="mcps1.2.4.1.2 "><p id="p73831421111010"><a name="p73831421111010"></a><a name="p73831421111010"></a>const char *(*getNetworkIfaceName)(const struct IWiFiBaseFeature *baseFeature);</p>
202</td>
203<td class="cellrowborder" valign="top" width="20.14%" headers="mcps1.2.4.1.3 "><p id="p16363321101014"><a name="p16363321101014"></a><a name="p16363321101014"></a>获取网络接口的名字。</p>
204</td>
205</tr>
206<tr id="row1657914017107"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15117233152315"><a name="p15117233152315"></a><a name="p15117233152315"></a>int32_t (*GetFeatureType)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, int32_t* featureType);</p>
207</td>
208<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15117233152315"><a name="p15117233152315"></a><a name="p15117233152315"></a>int32_t (*getFeatureType)(const struct IWiFiBaseFeature *);</p>
209</td>
210<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p195182610507"><a name="p195182610507"></a><a name="p195182610507"></a>获取特性的类型。</p>
211</td>
212</tr>
213<tr id="row5518663503"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p125181260501"><a name="p125181260501"></a><a name="p125181260501"></a>int32_t (*SetMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const uint8_t* mac, uint32_t macLen);</p>
214</td>
215<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p125181260501"><a name="p125181260501"></a><a name="p125181260501"></a>int32_t (*setMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);</p>
216</td>
217<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1151815635014"><a name="p1151815635014"></a><a name="p1151815635014"></a>设置MAC地址。</p>
218</td>
219</tr>
220<tr id="row851915617503"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p20519865500"><a name="p20519865500"></a><a name="p20519865500"></a>int32_t (*GetDeviceMacAddress)(struct IWlanInterface *self, const struct HdfFeatureInfo *ifeature, uint8_t* mac, uint32_t* macLen, uint8_t len)</p>
221</td>
222<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p20519865500"><a name="p20519865500"></a><a name="p20519865500"></a>int32_t (*getDeviceMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);</p>
223</td>
224<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p14519469509"><a name="p14519469509"></a><a name="p14519469509"></a>获取设备持久化的MAC地址。</p>
225</td>
226</tr>
227<tr id="row986761516115"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15867101551112"><a name="p15867101551112"></a><a name="p15867101551112"></a>int32_t (*GetFreqsWithBand)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, const struct HdfWifiInfo* wifiInfo, int32_t* freq, uint32_t* freqLen);</p>
228</td>
229<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2867181581116"><a name="p2867181581116"></a><a name="p2867181581116"></a>int32_t (*getValidFreqsWithBand)(const struct IWiFiBaseFeature *baseFeature, int32_t band, int32_t *freqs, uint32_t count, uint32_t *num);</p>
230</td>
231<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15867101551112"><a name="p15867101551112"></a><a name="p15867101551112"></a>获取指定频段(2.4G或者5G)下支持的频率。</p>
232</td>
233</tr>
234<tr id="row18232258171117"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p175191863503"><a name="p175191863503"></a><a name="p175191863503"></a>int32_t (*SetTxPower)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, int32_t power);</p>
235</td>
236<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p145195620502"><a name="p145195620502"></a><a name="p145195620502"></a>int32_t (*setTxPower)(const struct IWiFiBaseFeature *, int32_t);</p>
237</td>
238<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p175191863503"><a name="p175191863503"></a><a name="p175191863503"></a>设置发射功率。</p>
239</td>
240</tr>
241<tr id="row1744948201219"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7449128101215"><a name="p7449128101215"></a><a name="p7449128101215"></a>int32_t (*GetChipId)(struct IWlanInterface *self, const struct HdfFeatureInfo* ifeature, uint8_t* chipId);</p>
242</td>
243<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7449128101215"><a name="p7449128101215"></a><a name="p7449128101215"></a>int32_t (*getChipId)(const struct IWiFiBaseFeature *baseFeature, uint8_t *chipId);</p>
244</td>
245<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1244998131219"><a name="p1244998131219"></a><a name="p1244998131219"></a>获得当前驱动的芯片ID。</p>
246</td>
247</tr>
248<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>int32_t (*GetIfNamesByChipId)(struct IWlanInterface *self, uint8_t chipId, char* ifName, uint32_t ifNameLen, uint32_t* num);</p>
249</td>
250<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>int32_t (*getIfNamesByChipId)(const uint8_t chipId, char **ifNames, uint32_t *num);</p>
251</td>
252<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>通过芯片ID获得当前芯片所有的网卡名。</p>
253</td>
254</tr>
255<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>struct IWlanInterface *WlanInterfaceGetInstance(const char *serviceName);</p>
256</td>
257<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a></p>
258</td>
259<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>获取WLAN服务对象。</p>
260</td>
261</tr>
262<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>struct IWlanCallback *WlanCallbackServiceGet(void);</p>
263</td>
264<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a></p>
265</td>
266<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>获取WLAN回调服务。</p>
267</td>
268</tr>
269<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>void WlanInterfaceRelease(struct IWlanCallback *instance);</p>
270</td>
271<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a></p>
272</td>
273<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>销毁WLAN服务对象。</p>
274</td>
275</tr>
276<tr id="row34351131216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a>void WlanCallbackServiceRelease(struct IWlanCallback *instance);</p>
277</td>
278<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p743711161213"><a name="p743711161213"></a><a name="p743711161213"></a></p>
279</td>
280<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p164361118121"><a name="p164361118121"></a><a name="p164361118121"></a>销毁WLAN回调服务。</p>
281</td>
282</tr>
283</tbody>
284</table>
285
286### 使用说明(HAL接口)<a name="section19806524151819"></a>
287
288HAL接口使用步骤:
289
2901.  使用WifiConstruct创建一个WiFi实体。
2912.  用创建的WiFi实体调用start开启HAL和驱动之间的通道,获得驱动网卡信息。
2923.  通过createFeature函数创建一个apFeature或者staFeature。后面可通过apFeature或者staFeature去调用具体的实现接口,下面代码示例基于创建的apFeature。
2934.  调用和使用相关接口:如setMacAddress设置MAC地址、getDeviceMacAddress获取设备的MAC地址等。
2945.  调用destroyFeature,销毁创建的Feature。
2956.  调用stop销毁创建的通道。
2967.  执行WifiDestruct销毁创建的WiFi实体。
297
298代码示例:
299
300```
301#include "wifi_hal.h"
302#include "wifi_hal_sta_feature.h"
303#include "wifi_hal_ap_feature.h"
304#include "wifi_hal_cmd.h"
305#include "wifi_hal_event.h"
306
307#define MAC_LEN 6
308#define HDF_SUCCESS 0
309#define HDF_FAILURE (-1)
310
311static int32_t hal_main()
312{
313    int32_t ret;
314    struct IWiFi *wifi;
315
316    /* 创建一个WiFi实体 */
317    ret = WifiConstruct(&wifi);
318    if (ret != HDF_SUCCESS || wifi == NULL) {
319        return HDF_FAILURE;
320    }
321
322    /* 开启HAL和驱动之间的通道 */
323    ret = wifi->start(wifi);
324    if (ret != HDF_SUCCESS) {
325        return HDF_FAILURE;
326    }
327
328    /* 创建apFeature */
329    ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
330    if (ret != HDF_SUCCESS) {
331        return HDF_FAILURE;
332    }
333
334    /* 获取设备的MAC地址 */
335    unsigned char mac[MAC_LEN] = {0};
336    ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN);
337    if (ret != HDF_SUCCESS) {
338        return HDF_FAILURE;
339    }
340
341    /* 销毁掉创建的这个Feature */
342    ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
343    if (ret != HDF_SUCCESS) {
344        return HDF_FAILURE;
345    }
346
347    /* 销毁创建的通道 */
348    ret = wifi->stop(wifi);
349    if (ret != HDF_SUCCESS) {
350        return HDF_FAILURE;
351    }
352
353    /* 销毁创建的WiFi实体 */
354    ret = WifiDestruct(&wifi);
355    if (ret != HDF_SUCCESS) {
356        return HDF_FAILURE;
357    }
358    return ret;
359}
360```
361### 使用说明(HDI接口)<a name="section19806524151819"></a>
362
363HDI接口使用步骤:
364
3651.  使用WlanInterfaceGetInstance获取WLAN服务对象。
3662.  使用Start创建HAL和驱动之间的通道。
3673.  通过GetSupportFeature获取该设备支持的WLAN特性。
3684.  调用Stop,销毁HAL和驱动之间的通道。
3695.  执行WlanInterfaceRelease销毁WLAN服务对象。
370
371代码示例:
372
373```
374#include "v1_1/iwlan_interface.h"
375#include "wlan_callback_impl.h"
376#include "wlan_impl.h"
377
378#define PROTOCOL_80211_IFTYPE_NUM 11
379#define HDF_SUCCESS 0
380#define HDF_FAILURE (-1)
381
382static int32_t hdi_main()
383{
384	int32_t rc;
385	const char *WLAN_SERVICE_NAME = "wlan_hal_c_service";
386	static struct IWlanInterface *g_wlanObj = NULL;
387	uint8_t supType[ PROTOCOL_80211_IFTYPE_NUM + 1 ] = {0};
388    uint32_t supTypeLen = PROTOCOL_80211_IFTYPE_NUM + 1;
389
390	/* 获取wlan服务对象。*/
391	g_wlanObj = WlanInterfaceGetInstance(WLAN_SERVICE_NAME);
392	if (g_wlanObj == NULL)
393	{
394		returnHDF_FAILURE;
395	}
396
397	/* 创建HAL和驱动之间的通道及获取驱动网卡信息。 */
398	rc = g_wlanObj->Start(g_wlanObj);
399	if (rc != HDF_SUCCESS)
400	{
401		return HDF_FAILURE;
402	}
403
404	/* 获取该设备支持的WLAN特性(不考虑当前的使用状态)。 */
405	rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLen);
406	if (rc != HDF_SUCCESS)
407	{
408		return HDF_FAILURE;
409	}
410
411	/* 销毁HAL和驱动之间的通道。 */
412	rc = g_wlanObj->Stop(g_wlanObj);
413	if (rc != HDF_SUCCESS)
414	{
415		return HDF_FAILURE;
416	}
417
418	/* 销毁wlan服务对象。 */
419	WlanInterfaceRelease(g_wlanObj);
420
421	return rc;
422}
423```
424
425## 相关仓<a name="section1371113476307"></a>
426
427[驱动子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E9%A9%B1%E5%8A%A8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
428
429[drivers\_hdf_core](https://gitee.com/openharmony/drivers_hdf_core)
430
431[driver\_interface](https://gitee.com/openharmony/drivers_interface)
432
433[**drivers\_peripheral**](https://gitee.com/openharmony/drivers_peripheral)
434
435