1 /*
2  * Copyright (C) 2021-2022 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 #ifndef OHOS_IDL_IWIFI_STA_IFACE_H
17 #define OHOS_IDL_IWIFI_STA_IFACE_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "wifi_error_no.h"
22 #include "i_wifi_event_callback.h"
23 #include "i_wifi_struct.h"
24 #include "wifi_error_no.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /**
31  * @Description Sets the Wi-Fi event callback function.
32  *
33  * @param callback
34  */
35 void SetWifiEventCallback(IWifiEventCallback callback);
36 
37 /**
38  * @Description Obtains the Wi-Fi event callback structure.
39  *
40  * @return IWifiEventCallback*
41  */
42 IWifiEventCallback *GetWifiEventCallback(void);
43 
44 /**
45  * @Description Obtaining the STA Support Capability.
46  *
47  * @param capabilities
48  * @return WifiErrorNo
49  */
50 WifiErrorNo GetStaCapabilities(int32_t *capabilities);
51 
52 /**
53  * @Description Obtaining the MAC Address of a STA.
54  *
55  * @param mac - Mac address.
56  * @param lenMac - Size of the memory to which the MAC address points.
57  * @return WifiErrorNo
58  */
59 WifiErrorNo GetDeviceMacAddress(unsigned char *mac, int *lenMac);
60 
61 /**
62  * @Description Obtains the frequencies supported by a specified frequency band.
63  *
64  * @param band - Band type.
65  * @param frequencies - Numeric group pointer of the int type.
66  * @param size - Size of the memory to which the frequencies point and the
67  *               number of obtained data.
68  * @return WifiErrorNo
69  */
70 WifiErrorNo GetFrequencies(int32_t band, int *frequencies, int32_t *size);
71 
72 /**
73  * @Description Sets the MAC address of the Wi-Fi connection.
74  *
75  * @param mac - Mac address.
76  * @param lenMac - Mac string length.
77  * @param portType - Port Type
78  * @return WifiErrorNo
79  */
80 WifiErrorNo SetAssocMacAddr(unsigned char *mac, int lenMac, const int portType);
81 
82 /**
83  * @Description Sets the MAC address for Wi-Fi scanning.
84  *
85  * @param mac - Mac address.
86  * @param lenMac - Mac string length.
87  * @return WifiErrorNo
88  */
89 WifiErrorNo SetScanningMacAddress(unsigned char *mac, int lenMac);
90 
91 /**
92  * @Description Disconnect the BSSID of the last roaming subscriber.
93  *
94  * @param mac - Mac address.
95  * @param lenMac - Mac string length.
96  * @return WifiErrorNo
97  */
98 WifiErrorNo DeauthLastRoamingBssid(unsigned char *mac, int lenMac);
99 
100 /**
101  * @Description Get total supported feature.
102  *
103  * @param feature
104  * @return WifiErrorNo
105  */
106 WifiErrorNo GetSupportFeature(long *feature);
107 
108 /**
109  * @Description Send instructions to the Wi-Fi driver or chip.
110  *
111  * @param ifname
112  * @param cmdId
113  * @param buf
114  * @param bufSize
115  * @return WifiErrorNo
116  */
117 WifiErrorNo RunCmd(const char *ifname, int32_t cmdId, unsigned char *buf, int32_t bufSize);
118 
119 /**
120  * @Description Set the Wi-Fi transmit power.
121  *
122  * @param power
123  * @return WifiErrorNo
124  */
125 WifiErrorNo SetWifiTxPower(int32_t power);
126 
127 /**
128  * @Description Deleting a Network.
129  *
130  * @param networkId
131  * @return WifiErrorNo
132  */
133 WifiErrorNo RemoveNetwork(int networkId);
134 
135 /**
136  * @Description Add a network. If the network is successfully added, the
137  *              HAL returns the network ID.
138  *
139  * @param networkId
140  * @return WifiErrorNo
141  */
142 WifiErrorNo AddNetwork(int *networkId);
143 
144 /**
145  * @Description Enable a network.
146  *
147  * @param networkId
148  * @return WifiErrorNo
149  */
150 WifiErrorNo EnableNetwork(int networkId);
151 
152 /**
153  * @Description Disable a network.
154  *
155  * @param networkId
156  * @return WifiErrorNo
157  */
158 WifiErrorNo DisableNetwork(int networkId);
159 
160 /**
161  * @Description Set the Network object
162  *
163  * @param networkId
164  * @param confs
165  * @param size
166  * @return WifiErrorNo
167  */
168 WifiErrorNo SetNetwork(int networkId, SetNetworkConfig *confs, int size);
169 
170 /**
171  * @Description WpaGetNetwork Info.
172  *
173  * @param confs
174  * @return WifiErrorNo
175  */
176 WifiErrorNo WpaGetNetwork(GetNetworkConfig *confs);
177 
178 /**
179  * @Description Save the network.
180  *
181  * @return WifiErrorNo
182  */
183 WifiErrorNo SaveNetworkConfig(void);
184 
185 /**
186  * @Description Start Scanning.
187  *
188  * @param settings
189  * @return WifiErrorNo
190  */
191 WifiErrorNo StartScan(const ScanSettings *settings);
192 
193 /**
194  * @Description Obtain the scanning result, the caller needs to release the return
195  *              pointer if it is not NULL
196  *
197  * @param results
198  * @param size
199  * @return ScanResult pointer
200  */
201 ScanInfo* GetScanInfos(int *size);
202 
203 /**
204  * @Description Initiate PNO scanning.
205  *
206  * @param settings
207  * @return WifiErrorNo
208  */
209 WifiErrorNo StartPnoScan(const PnoScanSettings *settings);
210 
211 /**
212  * @Description Stop PNO Scanning.
213  *
214  * @return WifiErrorNo
215  */
216 WifiErrorNo StopPnoScan(void);
217 
218 /**
219  * @Description Registering the Sta Event Callback.
220  *
221  * @param callback
222  * @return WifiErrorNo
223  */
224 WifiErrorNo RegisterStaEventCallback(IWifiEventCallback callback);
225 
226 /**
227  * @Description Enabling WPS in PBC Mode.
228  *
229  * @param param
230  * @return WifiErrorNo
231  */
232 WifiErrorNo StartWpsPbcMode(WifiWpsParam *param);
233 
234 /**
235  * @Description Enable PIN mode WPS.
236  *
237  * @param param
238  * @param pinCode
239  * @return WifiErrorNo
240  */
241 WifiErrorNo StartWpsPinMode(WifiWpsParam *param, int *pinCode);
242 
243 /**
244  * @Description Close wps.
245  *
246  * @return WifiErrorNo
247  */
248 WifiErrorNo StopWps(void);
249 
250 /**
251  * @Description Obtains the roaming support capability.
252  *
253  * @param capability
254  * @return WifiErrorNo
255  */
256 WifiErrorNo GetRoamingCapabilities(WifiRoamCapability *capability);
257 
258 /**
259  * @Description Setting Roaming Configurations.
260  *
261  * @param blocklist
262  * @param blocksize
263  * @param trustlist
264  * @param trustsize
265  * @return WifiErrorNo
266  */
267 WifiErrorNo SetRoamConfig(char **blocklist, int blocksize, char **trustlist, int trustsize);
268 
269 /**
270  * @Description Wpa_s disable/enable(0/1) automatic reconnection.
271  *
272  * @param enable
273  * @return WifiErrorNo
274  */
275 WifiErrorNo WpaAutoConnect(int enable);
276 
277 /**
278  * @Description Clearing the wpa Blocklist.
279  *
280  * @return WifiErrorNo
281  */
282 WifiErrorNo WpaBlocklistClear(void);
283 
284 /**
285  * @Description Obtaining the Network List.
286  *
287  * @param networkList
288  * @param size
289  * @return WifiErrorNo
290  */
291 WifiErrorNo GetNetworkList(WifiNetworkInfo *infos, int *size);
292 
293 /**
294  * @Description Get current connect signal info, rssi, linkspeed, noise ...
295  *
296  * @param endBssid - peer end bssid, i.e. linked ap's bssid
297  * @param info - signal info
298  * @return WifiErrorNo
299  */
300 WifiErrorNo GetConnectSignalInfo(const char *endBssid, WpaSignalInfo *info);
301 
302 /**
303  * @Description send suspend mode for wpa.
304  *
305  * @param mode: true for suspend, false for resume.
306  * @return WifiErrorNo
307  */
308 WifiErrorNo SetSuspendMode(bool mode);
309 
310 /**
311  * @Description send power mode for wpa.
312  *
313  * @param mode: true for power, false for resume.
314  * @return WifiErrorNo
315  */
316 WifiErrorNo SetPowerMode(bool mode);
317 
318 #ifdef __cplusplus
319 }
320 #endif
321 #endif
322