• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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_C_P2P_H
17 #define OHOS_C_P2P_H
18 
19 #include "wifi_error_code.h"
20 #include "wifi_p2p_config.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef void (*P2pStateChangedCallback)(P2pState state);
27 typedef void (*P2pPersistentGroupsChangedCallback)(void);
28 typedef void (*P2pConnectionChangedCallback)(const WifiP2pLinkedInfo info);
29 typedef void (*P2pPeersChangedCallback)(WifiP2pDevice* devices, int len);
30 
31 /**
32  * @Description Enabling the P2P Mode.
33  *
34  * @return WifiErrorCode - operate result
35  */
36 WifiErrorCode EnableP2p();
37 
38 /**
39  * @Description Disable the P2P mode.
40  *
41  * @return WifiErrorCode - operate result
42  */
43 WifiErrorCode DisableP2p();
44 
45 /**
46  * @Description Get p2p enable status
47  *
48  * @param state - enable status
49  * @return WifiErrorCode - operate result
50  */
51 WifiErrorCode GetP2pEnableStatus(P2pState* state);
52 
53 /**
54  * @Description Start Wi-Fi P2P device search.
55  *
56  * @return WifiErrorCode - operate result
57  */
58 WifiErrorCode DiscoverDevices();
59 
60 /**
61  * @Description Stop Wi-Fi P2P device search.
62  *
63  * @return WifiErrorCode - operate result
64  */
65 WifiErrorCode StopDiscoverDevices();
66 
67 /**
68  * @Description Start the search for the Wi-Fi P2P service.
69  *
70  * @return WifiErrorCode - operate result
71  */
72 WifiErrorCode DiscoverServices();
73 
74 /**
75  * @Description Stop the search for the Wi-Fi P2P service.
76  *
77  * @return WifiErrorCode - operate result
78  */
79 WifiErrorCode StopDiscoverServices();
80 
81 /**
82  * @Description Enable Wi-Fi P2P listening.
83  *
84  * @param period - period
85  * @param interval - interval
86  * @return WifiErrorCode - operate result
87  */
88 WifiErrorCode StartP2pListen(int period, int interval);
89 
90 /**
91  * @Description Disable Wi-Fi P2P listening.
92  *
93  * @return ErrCode - operate result
94  */
95 WifiErrorCode StopP2pListen();
96 
97 /**
98  * @Description Creating a P2P Group.
99  *
100  * @param config - WifiP2pConfig object
101  * @return WifiErrorCode - operate result
102  */
103 WifiErrorCode CreateGroup(const WifiP2pConfig* config);
104 
105 /**
106  * @Description Remove a P2P Group.
107  *
108  * @param config - WifiP2pConfig object
109  * @return WifiErrorCode - operate result
110  */
111 WifiErrorCode RemoveGroup();
112 
113 /**
114  * @Description Delete a p2p Group.
115  *
116  * @param group - WifiP2pGroupInfo object
117  * @return ErrCode - operate result
118  */
119 WifiErrorCode DeleteGroup(const WifiP2pGroupInfo* group);
120 
121 /**
122  * @Description P2P connection.
123  *
124  * @param config - WifiP2pConfig object
125  * @return WifiErrorCode - operate result
126  */
127 WifiErrorCode P2pConnect(const WifiP2pConfig* config);
128 
129 /**
130  * @Description P2P disconnection.
131  *
132  * @return WifiErrorCode - operate result
133  */
134 WifiErrorCode P2pDisConnect();
135 
136 /**
137  * @Description Get the Current Group object.
138  *
139  * @param groupInfo - the WifiP2pGroupInfo object
140  * @return WifiErrorCode - operate result
141  */
142 WifiErrorCode GetCurrentGroup(WifiP2pGroupInfo* groupInfo);
143 
144 /**
145  * @Description Obtains the P2P connection status.
146  *
147  * @param status - the P2P connection status
148  * @return WifiErrorCode - operate result
149  */
150 WifiErrorCode GetP2pConnectedStatus(int* status);
151 
152 /**
153  * @Description Query the information about the found devices.
154  *
155  * @param clientDevices - pre-allocate memory for client devices
156  * @param size - the allocate size for clientDevices
157  * @param retSize - the queryed size of the client devices, used for return.
158  * @return WifiErrorCode - operate result
159  */
160 WifiErrorCode QueryP2pDevices(WifiP2pDevice* clientDevices, int size, int* retSize);
161 
162 /**
163  * @Description Query the information about the found groups.
164  *
165  * @param groupInfo - pre-allocate memory for group size
166  * @param size - the allocate size for groupInfo
167  * @return ErrCode - operate result
168  */
169 WifiErrorCode QueryP2pGroups(WifiP2pGroupInfo* groupInfo, int size);
170 
171 /**
172  * @Description register p2p state changed event
173  *
174  * @param callback - callback function
175  * @return ErrCode - operate result
176  */
177 WifiErrorCode RegisterP2pStateChangedCallback(const P2pStateChangedCallback callback);
178 
179 /**
180  * @Description register p2p persistent group change event
181  *
182  * @param callback - callback function
183  * @return ErrCode - operate result
184  */
185 WifiErrorCode RegisterP2pPersistentGroupsChangedCallback(const P2pPersistentGroupsChangedCallback callback);
186 
187 /**
188  * @Description register p2p connection change event
189  *
190  * @param callback - callback function
191  * @return ErrCode - operate result
192  */
193 WifiErrorCode RegisterP2pConnectionChangedCallback(const P2pConnectionChangedCallback callback);
194 
195 /**
196  * @Description register p2p peers change event
197  *
198  * @param callback - callback function
199  * @return ErrCode - operate result
200  */
201 WifiErrorCode RegisterP2pPeersChangedCallback(const P2pPeersChangedCallback callback);
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif
208