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