• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_P2P_HAL_INTERFACE_H
17 #define OHOS_WIFI_P2P_HAL_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 
23 #include "wifi_base_hal_interface.h"
24 #include "wifi_idl_struct.h"
25 #include "wifi_p2p_event_callback.h"
26 
27 namespace OHOS {
28 namespace Wifi {
29 class WifiP2PHalInterface : public WifiBaseHalInterface {
30 public:
31     static WifiP2PHalInterface &GetInstance(void);
32 
33     /**
34      * @Description Open P2p
35      *
36      * @return WifiErrorNo
37      */
38     WifiErrorNo StartP2p(void) const;
39 
40     /**
41      * @Description Close p2p
42      *
43      * @return WifiErrorNo
44      */
45     WifiErrorNo StopP2p(void) const;
46 
47     /**
48      * @Description P2P hal-layer registration event
49      *
50      * @param callbacks - register callback functions
51      * @return WifiErrorNo
52      */
53     WifiErrorNo RegisterP2pCallback(const P2pHalCallback &callbacks);
54 
55     /**
56      * @Description Enable WPS PBC
57      *
58      * @param groupInterface
59      * @param bssid
60      * @return WifiErrorNo
61      */
62     WifiErrorNo StartWpsPbc(const std::string &groupInterface, const std::string &bssid) const;
63 
64     /**
65      * @Description Enable Wps Pin mode
66      *
67      * @param groupInterface - p2p group
68      * @param address
69      * @param pin - pin code
70      * @param result - when pin is empty, represent use pin display mode, this return pin code
71      * @return WifiErrorNo
72      */
73     WifiErrorNo StartWpsPin(const std::string &groupInterface, const std::string &address, const std::string &pin,
74         std::string &result) const;
75 
76     /**
77      * @Description Remove Network
78      *
79      * @param networkId
80      * @return WifiErrorNo
81      */
82     WifiErrorNo RemoveNetwork(int networkId) const;
83 
84     /**
85      * @Description Get p2p Network list.
86      *
87      * @param mapGroups
88      * @return WifiErrorNo
89      */
90     WifiErrorNo ListNetworks(std::map<int, WifiP2pGroupInfo> &mapGroups) const;
91 
92     /**
93      * @Description Requesting P2P Setting Device Name
94      *
95      * @param name
96      * @return WifiErrorNo
97      */
98     WifiErrorNo SetP2pDeviceName(const std::string &name) const;
99 
100     /**
101      * @Description Send a request for setting the WPS primary device type in P2P mode
102      *
103      * @param type
104      * @return WifiErrorNo
105      */
106     WifiErrorNo SetP2pDeviceType(const std::string &type) const;
107 
108     /**
109      * @Description Send a request for setting the WPS secondary device type in P2P mode
110      *
111      * @param type
112      * @return WifiErrorNo
113      */
114     WifiErrorNo SetP2pSecondaryDeviceType(const std::string &type);
115 
116     /**
117      * @Description Sends a request for setting the WPS configuration method to
118      * the P2P.
119      *
120      * @param methods
121      * @return WifiErrorNo
122      */
123     WifiErrorNo SetP2pConfigMethods(const std::string &methods) const;
124 
125     /**
126      * @Description Send a P2P request for setting the SSID suffix
127      *
128      * @param postfixName
129      * @return WifiErrorNo
130      */
131     WifiErrorNo SetP2pSsidPostfix(const std::string &postfixName) const;
132 
133     /**
134      * @Description Sends a request for set group max idle to the P2P
135      *
136      * @param groupInterface - p2p group
137      * @param time
138      * @return WifiErrorNo
139      */
140     WifiErrorNo SetP2pGroupIdle(const std::string &groupInterface, size_t time) const;
141 
142     /**
143      * @Description Sends a request for set power save to the P2P
144      *
145      * @param groupInterface - p2p group
146      * @param enable
147      * @return WifiErrorNo
148      */
149     WifiErrorNo SetP2pPowerSave(const std::string &groupInterface, bool enable) const;
150 
151     /**
152      * @Description enable/disable Wi-Fi Display
153      *
154      * @param enable
155      * @return WifiErrorNo
156      */
157     WifiErrorNo SetWfdEnable(bool enable) const;
158 
159     /**
160      * @Description Sends a request for set Wi-Fi Display config
161      *
162      * @param config
163      * @return WifiErrorNo
164      */
165     WifiErrorNo SetWfdDeviceConfig(const std::string &config) const;
166 
167     /**
168      * @Description Sends a request for start p2p find to the P2P
169      *
170      * @param timeout
171      * @return WifiErrorNo
172      */
173     WifiErrorNo P2pFind(size_t timeout) const;
174 
175     /**
176      * @Description Sends a request for stop p2p find to the P2P
177      *
178      * @return WifiErrorNo
179      */
180     WifiErrorNo P2pStopFind() const;
181 
182     /**
183      * @Description Sends a request for set ext listen to the P2P
184      *
185      * @param enable
186      * @param period
187      * @param interval
188      * @return WifiErrorNo
189      */
190     WifiErrorNo P2pConfigureListen(bool enable, size_t period, size_t interval) const;
191 
192     /**
193      * @Description Sends a request for set listen channel to the P2P
194      *
195      * @param channel
196      * @param regClass
197      * @return WifiErrorNo
198      */
199     WifiErrorNo SetListenChannel(size_t channel, unsigned char regClass) const;
200 
201     /**
202      * @Description Sends a request for flush to the P2P.
203      *
204      * @return WifiErrorNo
205      */
206     WifiErrorNo P2pFlush() const;
207 
208     /**
209      * @Description Sends a request for connect to the P2P
210      *
211      * @param config
212      * @param isJoinExistingGroup
213      * @param pin - if using pin mode, return pin code
214      * @return WifiErrorNo
215      */
216     WifiErrorNo Connect(const WifiP2pConfigInternal &config, bool isJoinExistingGroup, std::string &pin) const;
217 
218     /**
219      * @Description Sends a request for cancel connect to the P2P
220      *
221      * @return WifiErrorNo
222      */
223     WifiErrorNo CancelConnect() const;
224 
225     /**
226      * @Description Provision Discovery
227      *
228      * @param config
229      * @return WifiErrorNo
230      */
231     WifiErrorNo ProvisionDiscovery(const WifiP2pConfigInternal &config) const;
232 
233     /**
234      * @Description Add Group
235      *
236      * @param isPersistent
237      * @param networkId - if networkid > 0, update it's freq; else create a new group
238      * @param freq
239      * @return WifiErrorNo
240      */
241     WifiErrorNo GroupAdd(bool isPersistent, int networkId, int freq) const;
242 
243     /**
244      * @Description Sends a request for remove group to the P2P
245      *
246      * @param groupInterface - p2p group
247      * @return WifiErrorNo
248      */
249     WifiErrorNo GroupRemove(const std::string &groupInterface) const;
250 
251     /**
252      * @Description Sends a request for invite to the P2P
253      *
254      * @param group - p2p group info
255      * @param deviceAddr - invite device address
256      * @return WifiErrorNo
257      */
258     WifiErrorNo Invite(const WifiP2pGroupInfo &group, const std::string &deviceAddr) const;
259 
260     /**
261      * @Description Sends a request for reinvoke to the P2P
262      *
263      * @param networkId
264      * @param deviceAddr
265      * @return WifiErrorNo
266      */
267     WifiErrorNo Reinvoke(int networkId, const std::string &deviceAddr) const;
268 
269     /**
270      * @Description Sends a request for get device address to the P2P.
271      *
272      * @param deviceAddress
273      * @return WifiErrorNo
274      */
275     WifiErrorNo GetDeviceAddress(std::string &deviceAddress) const;
276 
277     /**
278      * @Description Sends a request for add service to the P2P
279      *
280      * @param info
281      * @return WifiErrorNo
282      */
283     WifiErrorNo P2pServiceAdd(const WifiP2pServiceInfo &info) const;
284 
285     /**
286      * @Description Sends a request for remove service to the P2P
287      *
288      * @param info
289      * @return WifiErrorNo
290      */
291     WifiErrorNo P2pServiceRemove(const WifiP2pServiceInfo &info) const;
292 
293     /**
294      * @Description Sends a request for get group capability to the P2P
295      *
296      * @param deviceAddress
297      * @param cap
298      * @return WifiErrorNo
299      */
300     WifiErrorNo GetGroupCapability(const std::string &deviceAddress, uint32_t &cap) const;
301 
302     /**
303      * @Description Sends a request for flush service to the P2P
304      *
305      * @return WifiErrorNo
306      */
307     WifiErrorNo FlushService() const;
308 
309     /**
310      * @Description Sends a request for save config to the P2P
311      *
312      * @return WifiErrorNo
313      */
314     WifiErrorNo SaveConfig() const;
315 
316     /**
317      * @Description Sends a request for request service discovery to the P2P
318      *
319      * @param macAddr
320      * @param queryMsg
321      * @return WifiErrorNo
322      */
323     WifiErrorNo ReqServiceDiscovery(
324         const std::string &deviceAddress, const std::vector<unsigned char> &tlvs, std::string &reqID) const;
325 
326     /**
327      * @Description Sends a request for cancel request service discovery to the
328      * P2P
329      *
330      * @param id
331      * @return WifiErrorNo
332      */
333     WifiErrorNo CancelReqServiceDiscovery(const std::string &id) const;
334 
335     /**
336      * @Description set enable/disable using random mac address
337      *
338      * @param enable
339      * @return WifiErrorNo
340      */
341     WifiErrorNo SetRandomMacAddr(bool enable) const;
342 
343     /**
344      * @Description Set the Miracast Type
345      *
346      * @param type
347      * @return WifiErrorNo
348      */
349     WifiErrorNo SetMiracastMode(int type) const;
350 
351     /**
352      * @Description Set the Persistent Reconnect mode.
353      *
354      * @param mode
355      * @return WifiErrorNo
356      */
357     WifiErrorNo SetPersistentReconnect(int mode) const;
358 
359     /**
360      * @Description
361      *
362      * @param deviceAddress
363      * @param frequency
364      * @param dialogToken
365      * @param tlvs
366      * @param tlvsLength
367      * @return WifiErrorNo
368      */
369     WifiErrorNo RespServiceDiscovery(
370         const WifiP2pDevice &device, int frequency, int dialogToken, const std::vector<unsigned char> &tlvs) const;
371 
372     /**
373      * @Description Set the Service Discovery External.
374      *
375      * @param isExternalProcess
376      * @return WifiErrorNo
377      */
378     WifiErrorNo SetServiceDiscoveryExternal(bool isExternalProcess) const;
379 
380     /**
381      * @Description Show information about known P2P peer
382      *
383      * @param deviceAddress
384      * @param device
385      * @return WifiErrorNo
386      */
387     WifiErrorNo GetP2pPeer(const std::string &deviceAddress, WifiP2pDevice &device) const;
388 
389     /**
390      * @Description Obtains the P2P frequency supported by a specified frequency band.
391      *
392      * @param band - Frequency band.
393      * @param frequencies - Frequency list.
394      * @return WifiErrorNo
395      */
396     WifiErrorNo P2pGetSupportFrequenciesByBand(int band, std::vector<int> &frequencies) const;
397 
398     /**
399      * @Description Setting the P2P group config.
400      *
401      * @param networkId
402      * @param config
403      * @return WifiErrorNo
404      */
405     WifiErrorNo P2pSetGroupConfig(int networkId, const IdlP2pGroupConfig &config) const;
406 
407     /**
408      * @Description Getting the P2P group config.
409      *
410      * @param networkId
411      * @param config
412      * @return WifiErrorNo
413      */
414     WifiErrorNo P2pGetGroupConfig(int networkId, IdlP2pGroupConfig &config) const;
415 
416     /**
417      * @Description Request to obtain the next network ID.
418      *
419      * @param networkId
420      * @return WifiErrorNo
421      */
422     WifiErrorNo P2pAddNetwork(int &networkId) const;
423 
424     /**
425      * @Description Get register callback objects
426      *
427      * @return const P2pHalCallback& - register p2p callback objects
428      */
429     const P2pHalCallback &GetP2pCallbackInst(void) const;
430 
431     /**
432      * @Description Sends a request for hid2d connect to the P2P
433      *
434      * @param config hid2d config
435      * @return WifiErrorNo
436      */
437     WifiErrorNo Hid2dConnect(const Hid2dConnectConfig &config) const;
438 
439 private:
440     P2pHalCallback mP2pCallback;
441 };
442 }  // namespace Wifi
443 }  // namespace OHOS
444 #endif