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 "disc_interface_struct.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 * @brief Initialization of discovery management. Set the necessary environment for the discovery side. 31 * This interface is only called once when the softbus service is created. 32 * @see {@link DiscMgrDeinit} 33 * @return <b>SOFTBUS_DISCOVER_MANAGER_INIT_FAIL</b> Create Softbus list failed. 34 * @return <b>SOFTBUS_OK</b> Manager is Successfully inited 35 */ 36 int32_t DiscMgrInit(void); 37 38 /** 39 * @ingroup softbus_disc_manager 40 * @brief Discovery managed deinitialization. Clear the corresponding configuration of the discovery terminal. 41 * This interface is only called once when the softbus service is destroyed. 42 * @see {@link DiscMgrInit} 43 */ 44 void DiscMgrDeinit(void); 45 46 /** 47 * @ingroup softbus_disc_manager 48 * @brief Found management module information destroy callback function. 49 * Destroy the configuration related to the discovery release and clear it. 50 * @param[in] pkgName Indicates the pointer to package name, which can contain a maximum of 64 bytes. 51 * @param[in] pid Indicates pid of the invoking process. 52 */ 53 void DiscMgrDeathCallback(const char *pkgName, int32_t pid); 54 55 /** 56 * @ingroup softbus_disc_manager 57 * @brief Set the discovery callback and set the discovery client environment. 58 * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}. 59 * @param[in] callback Indicates a pointer to the discovery internal callback. 60 * For details, see {@link DiscInnerCallback}. 61 * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 62 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized. 63 * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed. 64 * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed. 65 * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info. 66 * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed. 67 * @return <b>SOFTBUS_OK</b> if the set discovery callback is successful. 68 */ 69 int32_t DiscSetDiscoverCallback(DiscModule moduleId, const DiscInnerCallback *callback); 70 71 /** 72 * @ingroup softbus_disc_manager 73 * @brief Publish capabilities and create the necessary environment for their own capabilities information. 74 * @see {@link DiscUnpublish}. 75 * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}. 76 * @param[in] info Indicates the pointer to the service publishing information. 77 * For details, see {@link PublishInfo}. 78 * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 79 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized. 80 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> if the creation of the information node fails. 81 * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed. 82 * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed. 83 * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info. 84 * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed. 85 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed. 86 * @return <b>SOFTBUS_OK</b> if the active release is successful. 87 */ 88 int32_t DiscPublish(DiscModule moduleId, const PublishInfo *info); 89 90 /** 91 * @ingroup softbus_disc_manager 92 * @brief Start the scan and set the corresponding environment according to the scan information. 93 * @param[in] moduleId Mouble Id. For details, see {@link DiscModule}. 94 * @param[in] info Indicates the pointer to the service publishing information. 95 * For details, see {@link PublishInfo}. 96 * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 97 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized. 98 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> if the creation of the information node fails. 99 * @return <b>SOFTBUS_MEM_ERR</b> if Memcpy failed. 100 * @return <b>SOFTBUS_LOCK_ERR</b> if Mutex lock failed. 101 * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> if duplicate info. 102 * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> if item node create failed. 103 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed. 104 * @return <b>SOFTBUS_OK</b> if the passive publish is successful. 105 */ 106 int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info, int32_t callingPid); 107 108 /** 109 * @ingroup softbus_disc_manager 110 * @brief Cancel the ability to publish, and clear the configuration environment where it publishes information. 111 * @see {@link DiscPublish}. 112 * @param[in] moduleId module ID. For details, see {@link DiscModule}. 113 * @param[in] publishId the publish ID which will be stopped. 114 * @return <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 115 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> if the Intelligent Soft Bus server fails to be initialized. 116 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> if info node delete failed. 117 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> if InnerFunction failed. 118 * @return <b>SOFTBUS_OK</b> if the stop publish is successful. 119 */ 120 int32_t DiscUnpublish(DiscModule moduleId, int32_t publishId, int32_t callingPid); 121 122 /** 123 * @ingroup softbus_disc_manager 124 * @brief Start the broadcast and create the necessary environment for its own broadcast information. 125 * @see {@link DiscStopAdvertise}. 126 * @param[in] moduleId module ID. For details, see {@link DiscModule}. 127 * @param[in] info Indicates the pointer to the service subscribe information. 128 * For details, see {@link SubscribeInfo}. 129 * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter. 130 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised. 131 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> InfoNode create failed. 132 * @return <b>SOFTBUS_MEM_ERR</b> Memcpy failed. 133 * @return <b>SOFTBUS_LOCK_ERR</b> Mutex lock failed. 134 * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> Duplicate info. 135 * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> ItemNode create failed. 136 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed. 137 * @return <b>SOFTBUS_OK</b> Active discover successfully. 138 */ 139 int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info, int32_t callingPid); 140 141 /** 142 * @ingroup softbus_disc_manager 143 * @brief Subscription capability, configure the environment required for its own subscription information. 144 * @param[in] moduleId module ID. For details, see {@link DiscModule}. 145 * @param[in] info Indicates the pointer to the service subscribe information. 146 * For details, see {@link SubscribeInfo}. 147 * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter. 148 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised. 149 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_CREATE</b> InfoNode create failed. 150 * @return <b>SOFTBUS_MEM_ERR</b> Memcpy failed. 151 * @return <b>SOFTBUS_LOCK_ERR</b> Mutex lock failed. 152 * @return <b>SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM</b> Duplicate info. 153 * @return <b>SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE</b> ItemNode create failed. 154 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed. 155 * @return <b>SOFTBUS_OK</b> Passive discover successfully. 156 */ 157 int32_t DiscSubscribe(DiscModule moduleId, const SubscribeInfo *info); 158 159 /** 160 * @ingroup softbus_disc_manager 161 * @brief Stop the broadcast and clear the environment configured by the start broadcast. 162 * @see {@link DiscStartAdvertise}. 163 * @param[in] moduleId module ID. For details, see {@link DiscModule}. 164 * @param[in] subscribeId the subscribe ID which will be stop broadcast. 165 * @return <b>SOFTBUS_INVALID_PARAM</b> Invalid moduleId or info parameter. 166 * @return <b>SOFTBUS_DISCOVER_MANAGER_NOT_INIT</b> Discovery manager is not initialised. 167 * @return <b>SOFTBUS_DISCOVER_MANAGER_INFO_NOT_DELETE</b> InfoNode delete failed. 168 * @return <b>SOFTBUS_DISCOVER_MANAGER_INNERFUNCTION_FAIL</b> InnerFunction failed. 169 * @return <b>SOFTBUS_OK</b> Stop discover successfully. 170 */ 171 int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId, int32_t callingPid); 172 173 /** 174 * @brief Modify the connection state. 175 * @param[in] status Used to indicate a certain connection state discovered. For details, see {@link LinkStatus}. 176 * @param[in] medium A medium for sending information that can be used in a connection route. 177 * @param[in] ifnameIdx Index of ifname for coap discovery. 178 * For details, see {@link ExchangeMedium}. 179 */ 180 void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium, int32_t ifnameIdx); 181 182 /** 183 * @ingroup softbus_disc_manager 184 * @brief Update broadcast packets when the local device information changes. 185 * @param[in] type Information that changes 186 */ 187 void DiscDeviceInfoChanged(InfoTypeChanged type); 188 189 int32_t OnRaiseHandDeviceFound(RaiseHandDeviceInfo *deviceInfo); 190 191 #ifdef __cplusplus 192 #if __cplusplus 193 } 194 #endif /* __cplusplus */ 195 #endif /* __cplusplus */ 196 197 #endif /* DISC_MANAGER_INTERFACE_H */