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_WIFI_HAL_P2P_INTERFACE_H
17 #define OHOS_WIFI_HAL_P2P_INTERFACE_H
18 
19 #include "wifi_hal_define.h"
20 #include "wifi_hal_struct.h"
21 #include "wifi_hal_p2p_struct.h"
22 
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26 
27 #include <dirent.h>
28 #include <stdio.h>
29 #include <sys/types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**
36  * @Description Enable P2P
37  *
38  * @return WifiErrorNo
39  */
40 WifiErrorNo P2pStart(void);
41 
42 /**
43  * @Description  Disabling P2P
44  *
45  * @return WifiErrorNo
46  */
47 WifiErrorNo P2pStop(void);
48 
49 /**
50  * @Description Forcibly Close P2p
51  *
52  * @return WifiErrorNo
53  */
54 WifiErrorNo P2pForceStop(void);
55 
56 /**
57  * @Description Setting Random MAC Address
58  *
59  * @param enable
60  * @return WifiErrorNo
61  */
62 WifiErrorNo P2pSetRandomMac(int enable);
63 
64 /**
65  * @Description  Sets the WPS device name.
66  *
67  * @param name - DeviceName
68  * @return WifiErrorNo
69  */
70 WifiErrorNo P2pSetDeviceName(const char *name);
71 
72 /**
73  * @Description Sets the P2P SSID suffix.
74  *
75  * @param postfixName
76  * @return WifiErrorNo
77  */
78 WifiErrorNo P2pSetSsidPostfixName(const char *postfixName);
79 
80 /**
81  * @Description Setting the WPS Primary Device Type
82  *
83  * @param type - Primary Device Type
84  * @return WifiErrorNo
85  */
86 WifiErrorNo P2pSetWpsDeviceType(const char *type);
87 
88 /**
89  * @Description Setting the WPS Secondary Device Type
90  *
91  * @param type - Secondary Device Type
92  * @return WifiErrorNo
93  */
94 WifiErrorNo P2pSetWpsSecondaryDeviceType(const char *type);
95 
96 /**
97  * @Description Setting WPS config methods
98  *
99  * @param config - config methods
100  * @return WifiErrorNo
101  */
102 WifiErrorNo P2pSetWpsConfigMethods(const char *config);
103 
104 /**
105  * @Description Obtains the MAC address of the working device.
106  *
107  * @param deviceAddress - request address buffer
108  * @param size - request address buffer size
109  * @return WifiErrorNo
110  */
111 WifiErrorNo P2pGetDeviceAddress(char *deviceAddress, int size);
112 
113 /**
114  * @Description flush P2P table and status
115  *
116  * @return WifiErrorNo
117  */
118 WifiErrorNo P2pFlush();
119 
120 /**
121  * @Description Flush all services on the current device.
122  *
123  * @return WifiErrorNo
124  */
125 WifiErrorNo P2pFlushService();
126 
127 /**
128  * @Description Save Config.
129  *
130  * @return WifiErrorNo
131  */
132 WifiErrorNo P2pSaveConfig();
133 
134 /**
135  * @Description Enable WPS PBC
136  *
137  * @param groupIfc
138  * @param address
139  * @return WifiErrorNo
140  */
141 WifiErrorNo P2pSetupWpsPbc(const char *groupIfc, const char *address);
142 
143 /**
144  * @Description Enable Wps Pin mode
145  *
146  * @param groupIfc - p2p group
147  * @param address
148  * @param pin - pin code
149  * @param result - when pin is empty, represent use pin display mode, this return pin code
150  * @param resultLen - request result buffer size
151  * @return WifiErrorNo
152  */
153 WifiErrorNo P2pSetupWpsPin(const char *groupIfc, const char *address, const char *pin, char *result, int resultLen);
154 
155 /**
156  * @Description Remove P2p Network.
157  *
158  * @param networkId
159  * @return WifiErrorNo
160  */
161 WifiErrorNo P2pRemoveNetwork(int networkId);
162 
163 /**
164  * @Description Get P2p Network List.
165  *
166  * @return WifiErrorNo
167  */
168 WifiErrorNo P2pListNetworks(P2pNetworkList *infoList);
169 
170 /**
171  * @Description Set the maximum idle time of a group.
172  *
173  * @param groupIfc
174  * @param time
175  * @return WifiErrorNo
176  */
177 WifiErrorNo P2pSetGroupMaxIdle(const char *groupIfc, int time);
178 
179 /**
180  * @Description Setting the Power Saving Mode
181  *
182  * @param groupIfc
183  * @param enable
184  * @return WifiErrorNo
185  */
186 WifiErrorNo P2pSetPowerSave(const char *groupIfc, int enable);
187 
188 /**
189  * @Description Enable or disable Wi-Fi display.
190  *
191  * @param enable
192  * @return WifiErrorNo
193  */
194 WifiErrorNo P2pSetWfdEnable(int enable);
195 
196 /**
197  * @Description Sets Wi-Fi display device information.
198  *
199  * @param config
200  * @return WifiErrorNo
201  */
202 WifiErrorNo P2pSetWfdDeviceConfig(const char *config);
203 
204 /**
205  * @Description Start P2P service discovery.
206  *
207  * @param timeout
208  * @return WifiErrorNo
209  */
210 WifiErrorNo P2pStartFind(int timeout);
211 
212 /**
213  * @Description Disabling P2P Service Discovery
214  *
215  * @return WifiErrorNo
216  */
217 WifiErrorNo P2pStopFind();
218 
219 /**
220  * @Description Setting listen channel
221  *
222  * @param enable
223  * @param period
224  * @param interval
225  * @return WifiErrorNo
226  */
227 WifiErrorNo P2pSetExtListen(int enable, int period, int interval);
228 
229 /**
230  * @Description Setting listen channel
231  *
232  * @param channel
233  * @param regClass
234  * @return WifiErrorNo
235  */
236 WifiErrorNo P2pSetListenChannel(int channel, int regClass);
237 
238 /**
239  * @Description Connect
240  *
241  * @param info
242  * @return WifiErrorNo
243  */
244 WifiErrorNo P2pConnect(P2pConnectInfo *info);
245 
246 /**
247  * @Description Cancel the ongoing P2P group and join the group.
248  *
249  * @return WifiErrorNo
250  */
251 WifiErrorNo P2pCancelConnect();
252 
253 /**
254  * @Description Provision Discovery
255  *
256  * @param peerBssid
257  * @param mode
258  * @return WifiErrorNo
259  */
260 WifiErrorNo P2pProvisionDiscovery(const char *peerBssid, int mode);
261 
262 /**
263  * @Description Add a P2P Group.
264  *
265  * @param isPersistent
266  * @param networkId
267  * @param freq - 2/5.  0 - acs
268  * @return WifiErrorNo
269  */
270 WifiErrorNo P2pAddGroup(int isPersistent, int networkId, int freq);
271 
272 /**
273  * @Description Terminate a group.
274  *
275  * @param interface
276  * @return WifiErrorNo
277  */
278 WifiErrorNo P2pRemoveGroup(const char *interface);
279 
280 /**
281  * @Description Terminate a group.
282  *
283  * @param deviceMac
284  * @return WifiErrorNo
285  */
286 WifiErrorNo P2pRemoveGroupClient(const char *deviceMac);
287 
288 /**
289  * @Description Inviting a Device to Join a Persistent Group.
290  *
291  * @param persistent
292  * @param peerBssid
293  * @param goBssid
294  * @param ifname
295  * @return WifiErrorNo
296  */
297 WifiErrorNo P2pInvite(int persistent, const char *peerBssid, const char *goBssid, const char *ifname);
298 
299 /**
300  * @Description persistent group Reinvoke peer
301  *
302  * @param networkId
303  * @param bssid
304  * @return WifiErrorNo
305  */
306 WifiErrorNo P2pReinvoke(int networkId, const char *bssid);
307 
308 /**
309  * @Description Obtains the capability of the group to which the deviceAddress belongs.
310  *
311  * @param bssid
312  * @param cap
313  * @return WifiErrorNo
314  */
315 WifiErrorNo P2pGetGroupCapability(const char *bssid, int *cap);
316 
317 /**
318  * @Description Add an UPNP/Bonjour service.
319  *
320  * @param info
321  * @return WifiErrorNo
322  */
323 WifiErrorNo P2pAddService(const P2pServiceInfo *info);
324 
325 /**
326  * @Description Deleting an UPNP/Bonjour Service
327  *
328  * @param info
329  * @return WifiErrorNo
330  */
331 WifiErrorNo P2pRemoveService(const P2pServiceInfo *info);
332 
333 /**
334  * @Description Initiate a ServiceDiscovery request.
335  *
336  * @param bssid
337  * @param msg
338  * @return WifiErrorNo
339  */
340 WifiErrorNo P2pReqServiceDiscovery(const char *bssid, const char *msg, char *disc, int size);
341 
342 /**
343  * @Description Canceling a ServiceDiscovery Request
344  *
345  * @param id
346  * @return WifiErrorNo
347  */
348 WifiErrorNo P2pCancelServiceDiscovery(const char *id);
349 
350 /**
351  * @Description Set the Miracast mode to the driver.
352  *
353  * @param type
354  * @return WifiErrorNo
355  */
356 WifiErrorNo P2pSetMiracastType(int type);
357 
358 /**
359  * @Description P2p response server discovery
360  *
361  * @param info
362  * @return WifiErrorNo
363  */
364 WifiErrorNo P2pRespServerDiscovery(P2pServDiscReqInfo *info);
365 
366 /**
367  * @Description P2p Set Service Discovery External
368  *
369  * @param mode
370  * @return WifiErrorNo
371  */
372 WifiErrorNo P2pSetServDiscExternal(int mode);
373 
374 /**
375  * @Description P2p Set Persistent Reconnect mode.
376  *
377  * @param mode
378  * @return WifiErrorNo
379  */
380 WifiErrorNo P2pSetPersistentReconnect(int mode);
381 
382 /**
383      * @Description Show information about known P2P peer
384      *
385      * @param deviceAddress
386      * @param device
387      * @return WifiErrorNo
388      */
389 WifiErrorNo P2pGetPeer(const char *bssid, P2pDeviceInfo *peerInfo);
390 
391 /**
392  * @Description Get chba0 frequency.
393  *
394  * @param chba0Freq
395  * @return WifiErrorNo
396  */
397 WifiErrorNo P2pGetChba0Freq(int *chba0Freq);
398 
399 /**
400  * @Description Obtains the frequencies supported by a specified frequency band.
401  *
402  * @param band - Band type.
403  * @param frequencies - Numeric group pointer of the int type.
404  * @param size - Size of the memory to which the frequencies point and the
405  *               number of obtained data.
406  * @return WifiErrorNo
407  */
408 WifiErrorNo P2pGetFrequencies(int band, int *frequencies, int *size);
409 
410 /**
411  * @Description Setting the P2P group config.
412  *
413  * @param networkId
414  * @param config
415  * @param size
416  * @return WifiErrorNo
417  */
418 WifiErrorNo P2pSetGroupConfig(int networkId, P2pGroupConfig *pConfig, int size);
419 
420 /**
421  * @Description Getting the P2P group config.
422  *
423  * @param networkId
424  * @param config
425  * @param size
426  * @return WifiErrorNo
427  */
428 WifiErrorNo P2pGetGroupConfig(int networkId, P2pGroupConfig *pConfig, int size);
429 
430 /**
431  * @Description Add Network interface.
432  *
433  * @param networkId
434  * @return WifiErrorNo
435  */
436 WifiErrorNo P2pAddNetwork(int *networkId);
437 
438 /**
439  * @Description Connect
440  *
441  * @param info - connection information
442  * @return WifiErrorNo
443  */
444 WifiErrorNo P2pHid2dConnect(Hid2dConnectInfo *info);
445 
446 #ifdef __cplusplus
447 }
448 #endif
449 
450 #endif  // OHOS_WIFI_HAL_P2P_INTERFACE_H
451