• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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  */
15 
16 /**
17  * @addtogroup WLAN
18  * @{
19  *
20  * @brief Provides cross-OS migration, component adaptation, and modular assembly and compilation.
21  *
22  * Based on the unified APIs provided by the WLAN module, developers of the Hardware Driver Interface
23  * (HDI) are capable of creating, disabling, scanning for, and connecting to WLAN hotspots, managing WLAN chips,
24  * network devices, and power, and applying for, releasing, and moving network data buffers.
25  *
26  * @since 1.0
27  * @version 1.0
28  */
29 
30 /**
31  * @file wifi_hal.h
32  *
33  * @brief Declares APIs for basic WLAN features.
34  *
35  * @since 1.0
36  * @version 1.0
37  */
38 
39 #ifndef WIFI_HAL_H
40 #define WIFI_HAL_H
41 
42 #include "wifi_hal_ap_feature.h"
43 #include "wifi_hal_sta_feature.h"
44 
45 #ifdef __cplusplus
46 #if __cplusplus
47 extern "C" {
48 #endif
49 #endif
50 
51 /**
52  * @brief Defines a callback to listen for <b>IWiFi</b> asynchronous events.
53  *
54  * @param event Indicates the event type passed to the callback.
55  * @param data Indicates the pointer to the data passed to the callback.
56  * @param ifName The interface name.
57  *
58  * @return Returns <b>0</b> if the <b>IWiFi</b> callback is defined; returns a negative value otherwise.
59  *
60  * @since 1.0
61  * @version 1.0
62  */
63 typedef int32_t (*CallbackFunc)(uint32_t event, void *data, const char *ifName);
64 
65 /**
66  * @brief Defines the basic WLAN features provided by the hardware abstraction layer (HAL).
67  *
68  * The basic features include creating and stopping a channel between the HAL and the WLAN driver,
69  * and creating, obtaining, and destroying WLAN features.
70  *
71  * @since 1.0
72  * @version 1.0
73  */
74 struct IWiFi {
75     /**
76      * @brief Creates a channel between the HAL and the WLAN driver and obtains the driver NIC information.
77      *
78      * @param iwifi Indicates the pointer to the {@link IWiFi} object.
79      *
80      * @return Returns <b>0</b> if the channel is created and the driver NIC information is obtained;
81      * returns a negative value otherwise.
82      *
83      * @since 1.0
84      * @version 1.0
85      */
86     int32_t (*start)(struct IWiFi *iwifi);
87 
88     /**
89      * @brief Stops the channel between the HAL and the WLAN driver.
90      *
91      * @param iwifi Indicates the pointer to the {@link IWiFi} object.
92      *
93      * @return Returns <b>0</b> if the channel is stopped; returns a negative value otherwise.
94      *
95      * @since 1.0
96      * @version 1.0
97      */
98     int32_t (*stop)(struct IWiFi *iwifi);
99 
100     /**
101      * @brief Obtains the WLAN features available for the device no matter whether it works as an AP,
102      * STA, or P2P server/client.
103      *
104      * @param supType Indicates the pointer to the WLAN features available for the device.
105      * @param size Indicates the length of the <b>supType</b> array.
106      *
107      * @return Returns <b>0</b> if the WLAN features are obtained; returns a negative value otherwise.
108      *
109      * @since 1.0
110      * @version 1.0
111      */
112     int32_t (*getSupportFeature)(uint8_t *supType, uint32_t size);
113 
114     /**
115      * @brief Obtains the WLAN features available for the device that plays different roles simultaneously
116      * (any combination of AP, STA, and P2P server/client).
117      *
118      * @param combo Indicates the pointer to WLAN features available for the device.
119      * @param size Indicates the length of the <b>combo</b> array.
120      *
121      * @return Returns <b>0</b> if the WLAN features are obtained; returns a negative value otherwise.
122      *
123      * @since 1.0
124      * @version 1.0
125      */
126     int32_t (*getSupportCombo)(uint64_t *combo, uint32_t size);
127 
128     /**
129      * @brief Creates an {@link IWiFiBaseFeature} object of a specified type.
130      *
131      * @param type Indicates the feature type.
132      * @param ifeature Indicates the double pointer to the {@link IWiFiBaseFeature} object.
133      *
134      * @return Returns <b>0</b> if the {@link IWiFiBaseFeature} object is created; returns a negative value otherwise.
135      *
136      * @since 1.0
137      * @version 1.0
138      */
139     int32_t (*createFeature)(int32_t type, struct IWiFiBaseFeature **ifeature);
140 
141     /**
142      * @brief Obtains an {@link IWiFiBaseFeature} object based on a specified network interface name.
143      *
144      * @param ifName Indicates the pointer to the network interface name.
145      * @param ifeature Indicates the double pointer to the {@link IWiFiBaseFeature} object.
146      *
147      * @return Returns <b>0</b> if the {@link IWiFiBaseFeature} object is obtained; returns a negative value otherwise.
148      *
149      * @since 1.0
150      * @version 1.0
151      */
152     int32_t (*getFeatureByIfName)(const char *ifName, struct IWiFiBaseFeature **ifeature);
153 
154     /**
155      * @brief Registers a callback to listen for <b>IWiFi</b> asynchronous events.
156      *
157      * @param cbFunc Indicates the callback to register.
158      * @param ifName Indicates the pointer to the network interface name.
159      *
160      * @return Returns <b>0</b> if the callback is registered; returns a negative value otherwise.
161      *
162      * @since 1.0
163      * @version 1.0
164      */
165     int32_t (*registerEventCallback)(CallbackFunc cbFunc, const char *ifName);
166 
167     /**
168      * @brief Deregisters an <b>IWiFi</b> callback.
169 
170      * @param cbFunc Indicates the callback to register.
171      * @param ifName Indicates the pointer to the network interface name.
172      *
173      * @return Returns <b>0</b> if the <b>IWiFi</b> callback is deregistered; returns a negative value otherwise.
174      *
175      * @since 1.0
176      * @version 1.0
177      */
178     int32_t (*unregisterEventCallback)(CallbackFunc cbFunc, const char *ifName);
179 
180     /**
181      * @brief Destroys a specified {@link IWiFiBaseFeature} object.
182      *
183      * @param ifeature Indicates the pointer to the {@link IWiFiBaseFeature} object to destroy.
184      *
185      * @return Returns <b>0</b> if the {@link IWiFiBaseFeature} object is destroyed; returns a negative value otherwise.
186      *
187      * @since 1.0
188      * @version 1.0
189      */
190     int32_t (*destroyFeature)(struct IWiFiBaseFeature *ifeature);
191 
192     /**
193      * @brief Resets the WLAN driver with a specified chip ID.
194      *
195      * @param chipId Indicates the chip ID.
196      *
197      * @return Returns <b>0</b> if the WLAN driver is reset; returns a negative value otherwise.
198      *
199      * @since 1.0
200      * @version 1.0
201      */
202     int32_t (*resetDriver)(const uint8_t chipId, const char *ifName);
203 
204     /**
205      * @brief get net device infos.
206      *
207      * @param netDeviceInfoResult get net device infos.
208      *
209      * @return Returns <b>0</b> if get infos successful; returns a negative value otherwise.
210      *
211      * @since 1.0
212      * @version 1.0
213      */
214     int32_t (*getNetDevInfo)(struct NetDeviceInfoResult *netDeviceInfoResult);
215 };
216 
217 /**
218  * @brief Creates an {@link IWiFi} structure.
219  *
220  * @param wifiInstance Indicates the double pointer to the {@link IWiFi} structure.
221  *
222  * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
223  *
224  * @since 1.0
225  * @version 1.0
226  */
227 int32_t WifiConstruct(struct IWiFi **wifiInstance);
228 
229 /**
230  * @brief Destroys a specified {@link IWiFi} structure.
231  *
232  * @param wifiInstance Indicates the double pointer to the {@link IWiFi} structure.
233  *
234  * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
235  *
236  * @since 1.0
237  * @version 1.0
238  */
239 int32_t WifiDestruct(struct IWiFi **wifiInstance);
240 
241 #ifdef __cplusplus
242 #if __cplusplus
243 }
244 #endif
245 #endif
246 
247 #endif
248 /** @} */
249