• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 DISC_MANAGER_INTERFACE_H
17 #define DISC_MANAGER_INTERFACE_H
18 
19 #include "discovery_service.h"
20 #include "stdint.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 /**
29  * @ingroup softbus_disc_manager
30  * Inner Module.
31  *
32  */
33 typedef enum {
34     MODULE_MIN = 1,
35     MODULE_LNN = MODULE_MIN,
36     MODULE_CONN = 2,
37     MODULE_MAX = MODULE_CONN
38 } DiscModule;
39 
40 typedef enum {
41     LINK_STATUS_UP = 0,
42     LINK_STATUS_DOWN,
43 } LinkStatus;
44 
45 typedef enum {
46     TYPE_LOCAL_DEVICE_NAME,
47     TYPE_ACCOUNT,
48 } InfoTypeChanged;
49 
50 /**
51  * @ingroup softbus_disc_manager
52  * Inner Callback.
53  *
54  */
55 typedef struct {
56     void (*OnDeviceFound)(const DeviceInfo *device, const InnerDeviceInfoAddtions *addtions);
57 } DiscInnerCallback;
58 
59 /**
60  * @ingroup softbus_disc_manager
61  * @brief Initialization of discovery management. Set the necessary environment for the discovery side.
62  * This interface is only called once when the softbus service is created.
63  * @see {@link DiscMgrDeinit}
64  * @return <b>SOFTBUS_ERR</b> Create Softbus list failed.
65  * @return <b>SOFTBUS_OK</b> Manager is Successfully inited
66  */
67 int32_t DiscMgrInit(void);
68 
69 /**
70  * @ingroup softbus_disc_manager
71  * @brief Discovery managed deinitialization. Clear the corresponding configuration of the discovery terminal.
72  * This interface is only called once when the softbus service is destroyed.
73  * @see {@link DiscMgrInit}
74  */
75 void DiscMgrDeinit(void);
76 
77 /**
78  * @ingroup softbus_disc_manager
79  * @brief Found management module information destroy callback function.
80  * Destroy the configuration related to the discovery release and clear it.
81  * @param[in] pkgName Indicates the pointer to package name, which can contain a maximum of 64 bytes.
82  */
83 void DiscMgrDeathCallback(const char *pkgName);
84 
85 /**
86  * @ingroup softbus_disc_manager
87  * @brief Set the discovery callback and set the discovery client environment.
88  * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}.
89  * @param[in] callback Indicates a pointer to the discovery internal callback.
90  * For details, see {@link DiscInnerCallback}.
91  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
92  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized.
93  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> if mouble id is null or invalid.
94  * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed.
95  * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed.
96  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info.
97  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed.
98  * @return <b>SOFTBUS_OK</b> if the set discovery callback is successful.
99  */
100 int32_t DiscSetDiscoverCallback(DiscModule moduleId, const DiscInnerCallback *callback);
101 
102 /**
103  * @ingroup softbus_disc_manager
104  * @brief Publish capabilities and create the necessary environment for their own capabilities information.
105  * @see {@link DiscUnpublish}.
106  * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}.
107  * @param[in] info Indicates the pointer to the service publishing information.
108  * For details, see {@link PublishInfo}.
109  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
110  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized.
111  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> if mouble id is null or invalid.
112  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> if the creation of the information node fails.
113  * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed.
114  * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed.
115  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info.
116  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed.
117  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed.
118  * @return <b>SOFTBUS_OK</b> if the active release is successful.
119  */
120 int32_t DiscPublish(DiscModule moduleId, const PublishInfo *info);
121 
122 /**
123  * @ingroup softbus_disc_manager
124  * @brief Start the scan and set the corresponding environment according to the scan information.
125  * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}.
126  * @param[in] info Indicates the pointer to the service publishing information.
127  * For details, see {@link PublishInfo}.
128  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
129  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized.
130  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> if mouble id is null or invalid.
131  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> if the creation of the information node fails.
132  * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed.
133  * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed.
134  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info.
135  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed.
136  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed.
137  * @return <b>SOFTBUS_OK</b> if the passive publish is successful.
138  */
139 int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info);
140 
141 /**
142  * @ingroup softbus_disc_manager
143  * @brief Cancel the ability to publish, and clear the configuration environment where it publishes information.
144  * @see {@link DiscPublish}.
145  * @param[in] moduleId module ID. For details, see {@link DiscModule}.
146  * @param[in] publishId the publish ID which will be stopped.
147  * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
148  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized.
149  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> if mouble id is null or invalid.
150  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> if info node delete failed.
151  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed.
152  * @return <b>SOFTBUS_OK</b> if the stop publish is successful.
153  */
154 int32_t DiscUnpublish(DiscModule moduleId, int32_t publishId);
155 
156 /**
157  * @ingroup softbus_disc_manager
158  * @brief Start the broadcast and create the necessary environment for its own broadcast information.
159  * @see {@link DiscStopAdvertise}.
160  * @param[in] moduleId module ID. For details, see {@link DiscModule}.
161  * @param[in] info Indicates the pointer to the service subscribe information.
162  * For details, see {@link SubscribeInfo}.
163  * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter.
164  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised.
165  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> Module to string failed.
166  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> InfoNode create failed.
167  * @return <b>SOFTBUS_MEM_ERR</b> Memcpy failed.
168  * @return <b>SOFTBUS_LOCK_ERR</b> Mutex lock failed.
169  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> Duplicate info.
170  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> ItemNode create failed.
171  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed.
172  * @return <b>SOFTBUS_OK</b> Active discover successfully.
173  */
174 int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info);
175 
176 /**
177  * @ingroup softbus_disc_manager
178  * @brief Subscription capability, configure the environment required for its own subscription information.
179  * @param[in] moduleId module ID. For details, see {@link DiscModule}.
180  * @param[in] info Indicates the pointer to the service subscribe information.
181  * For details, see {@link SubscribeInfo}.
182  * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter.
183  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised.
184  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> Module to string failed.
185  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> InfoNode create failed.
186  * @return <b>SOFTBUS_MEM_ERR</b> Memcpy failed.
187  * @return <b>SOFTBUS_LOCK_ERR</b> Mutex lock failed.
188  * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> Duplicate info.
189  * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> ItemNode create failed.
190  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed.
191  * @return <b>SOFTBUS_OK</b> Passive discover successfully.
192  */
193 int32_t DiscSubscribe(DiscModule moduleId, const SubscribeInfo *info);
194 
195 /**
196  * @ingroup softbus_disc_manager
197  * @brief Stop the broadcast and clear the environment configured by the start broadcast.
198  * @see {@link DiscStartAdvertise}.
199  * @param[in] moduleId module ID. For details, see {@link DiscModule}.
200  * @param[in] subscribeId the subscribe ID which will be stop broadcast.
201  * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter.
202  * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised.
203  * @return <b>SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE</b> Module to string failed.
204  * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> InfoNode delete failed.
205  * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed.
206  * @return <b>SOFTBUS_OK</b> Stop discover successfully.
207  */
208 int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId);
209 
210 /**
211  * @brief Modify the connection state.
212  * @param[in] status Used to indicate a certain connection state discovered. For details, see {@link LinkStatus}.
213  * @param[in] medium A medium for sending information that can be used in a connection route.
214  * For details, see {@link ExchangeMedium}.
215  */
216 void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium);
217 
218 /**
219  * @brief Set the networking status and modify the networking connection status.
220  * @param[in] flag Network connection flag.
221  */
222 void SetCallLnnStatus(bool flag);
223 
224 /**
225  * @brief Get the networking connection status.
226  */
227 bool GetCallLnnStatus(void);
228 
229 /**
230  * @ingroup softbus_disc_manager
231  * @brief Update broadcast packets when the local device information changes.
232  * @param[in] type Information that changes
233  */
234 void DiscDeviceInfoChanged(InfoTypeChanged type);
235 
236 #ifdef __cplusplus
237 #if __cplusplus
238 }
239 #endif /* __cplusplus */
240 #endif /* __cplusplus */
241 
242 #endif /* DISC_MANAGER_INTERFACE_H */