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 /** 46 * @ingroup softbus_disc_manager 47 * Inner Callback. 48 * 49 */ 50 typedef struct { 51 void (*OnDeviceFound)(const DeviceInfo *device); 52 } DiscInnerCallback; 53 54 /** 55 * @ingroup softbus_disc_manager 56 * @brief softbus discovery manager init 57 * 58 * @retval #SOFTBUS_ERR Create Softbus list failed. 59 * @retval #SOFTBUS_OK Manager is Successfully inited 60 * 61 */ 62 int32_t DiscMgrInit(void); 63 64 /** 65 * @ingroup softbus_disc_manager 66 * @brief softbus discovery manager deinit 67 * 68 */ 69 void DiscMgrDeinit(void); 70 71 /** 72 * @ingroup softbus_disc_manager 73 * @brief softbus discovery manager death callback 74 * 75 */ 76 void DiscMgrDeathCallback(const char *pkgName); 77 78 /** 79 * @ingroup softbus_disc_manager 80 * @brief Subscribe inner callback update. 81 * 82 * @param moduleId [IN] Type #DiscModule module ID. 83 * @param initParam [IN] Type #DiscInnerCallback * update the callback of the module. 84 * 85 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or cb. 86 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 87 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 88 * @retval #SOFTBUS_LOCK_ERR Mutex lock failed. 89 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_PARAM Module not found. 90 * @retval #SOFTBUS_OK Subscribe inner callback update successfully. 91 * 92 */ 93 int32_t DiscSetDiscoverCallback(DiscModule moduleId, const DiscInnerCallback *cb); 94 95 /** 96 * @ingroup softbus_disc_manager 97 * @brief Active publish. 98 * 99 * @param moduleId [IN] Type #DiscModule module ID. 100 * @param info [IN] Type #PublishInfo * publish information. 101 * 102 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 103 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 104 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 105 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE InfoNode create failed. 106 * @retval #SOFTBUS_MEM_ERR Memcpy failed. 107 * @retval #SOFTBUS_LOCK_ERR Mutex lock failed. 108 * @retval #SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM Duplicate info. 109 * @retval #SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE ItemNode create failed. 110 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 111 * @retval #SOFTBUS_OK Active publish successfully. 112 * 113 */ 114 int32_t DiscPublish(DiscModule moduleId, const PublishInfo *info); 115 116 /** 117 * @ingroup softbus_disc_manager 118 * @brief Passive publish. 119 * 120 * @param moduleId [IN] Type #DiscModule module ID. 121 * @param info [IN] Type #PublishInfo * publish information. 122 * 123 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 124 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 125 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 126 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE InfoNode create failed. 127 * @retval #SOFTBUS_MEM_ERR Memcpy failed. 128 * @retval #SOFTBUS_LOCK_ERR Mutex lock failed. 129 * @retval #SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM Duplicate info. 130 * @retval #SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE ItemNode create failed. 131 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 132 * @retval #SOFTBUS_OK Passive publish successfully. 133 * 134 */ 135 int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info); 136 137 /** 138 * @ingroup softbus_disc_manager 139 * @brief Stop publish. 140 * 141 * @param moduleId [IN] Type #DiscModule module ID. 142 * @param publishId [IN] Type #int32_t the publish ID which will be stopped. 143 * 144 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 145 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 146 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 147 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE InfoNode delete failed. 148 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 149 * @retval #SOFTBUS_OK Stop publish successfully. 150 * 151 */ 152 int32_t DiscUnpublish(DiscModule moduleId, int32_t publishId); 153 154 /** 155 * @ingroup softbus_disc_manager 156 * @brief Active discover. 157 * 158 * @param moduleId [IN] Type #DiscModule module ID. 159 * @param info [IN] Type #SubscribeInfo * discover information. 160 * 161 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 162 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 163 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 164 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE InfoNode create failed. 165 * @retval #SOFTBUS_MEM_ERR Memcpy failed. 166 * @retval #SOFTBUS_LOCK_ERR Mutex lock failed. 167 * @retval #SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM Duplicate info. 168 * @retval #SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE ItemNode create failed. 169 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 170 * @retval #SOFTBUS_OK Active discover successfully. 171 * 172 */ 173 int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info); 174 175 /** 176 * @ingroup softbus_disc_manager 177 * @brief Passive discover. 178 * 179 * @param moduleId [IN] Type #DiscModule module ID. 180 * @param info [IN] Type #SubscribeInfo * discover information. 181 * 182 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 183 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 184 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 185 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE InfoNode create failed. 186 * @retval #SOFTBUS_MEM_ERR Memcpy failed. 187 * @retval #SOFTBUS_LOCK_ERR Mutex lock failed. 188 * @retval #SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM Duplicate info. 189 * @retval #SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE ItemNode create failed. 190 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 191 * @retval #SOFTBUS_OK Passive discover successfully. 192 * 193 */ 194 int32_t DiscSubscribe(DiscModule moduleId, const SubscribeInfo *info); 195 196 /** 197 * @ingroup softbus_disc_manager 198 * @brief Stop discover. 199 * 200 * @param moduleId [IN] Type #DiscModule module ID. 201 * @param subscribeId [IN] Type #int32_t the discover ID which will be stopped. 202 * 203 * @retval #SOFTBUS_INVALID_PARAM Invalid moduleId or info parameter. 204 * @retval #SOFTBUS_DISCOVER_MANAGER_NOT_INIT Discovery manager is not initialised. 205 * @retval #SOFTBUS_DISCOVER_MANAGER_INVALID_MODULE Module to string failed. 206 * @retval #SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE InfoNode delete failed. 207 * @retval #SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL InnerFunction failed. 208 * @retval #SOFTBUS_OK Stop discover successfully. 209 * 210 */ 211 int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId); 212 213 void DiscLinkStatusChanged(LinkStatus status, ExchanageMedium medium); 214 215 void SetCallLnnStatus(bool flag); 216 bool GetCallLnnStatus(void); 217 218 #ifdef __cplusplus 219 #if __cplusplus 220 } 221 #endif /* __cplusplus */ 222 #endif /* __cplusplus */ 223 224 #endif /* DISC_MANAGER_INTERFACE_H */