1060ff233Sopenharmony_ci/* 2060ff233Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License. 5060ff233Sopenharmony_ci * You may obtain a copy of the License at 6060ff233Sopenharmony_ci * 7060ff233Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8060ff233Sopenharmony_ci * 9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and 13060ff233Sopenharmony_ci * limitations under the License. 14060ff233Sopenharmony_ci */ 15060ff233Sopenharmony_ci 16060ff233Sopenharmony_ci/** 17060ff233Sopenharmony_ci * @addtogroup SoftBus 18060ff233Sopenharmony_ci * @{ 19060ff233Sopenharmony_ci * 20060ff233Sopenharmony_ci * @brief Provides data level of distributed database transport by DSoftBus ble heratbeat. 21060ff233Sopenharmony_ci * 22060ff233Sopenharmony_ci * This module implements unified distributed communication management of nearby devices and provides link-independent 23060ff233Sopenharmony_ci * device discovery and transmission interfaces to support service publishing and data transmission. 24060ff233Sopenharmony_ci * @since 1.0 25060ff233Sopenharmony_ci * @version 1.0 26060ff233Sopenharmony_ci */ 27060ff233Sopenharmony_ci/** @} */ 28060ff233Sopenharmony_ci 29060ff233Sopenharmony_ci#ifndef DATA_LEVEL_H 30060ff233Sopenharmony_ci#define DATA_LEVEL_H 31060ff233Sopenharmony_ci 32060ff233Sopenharmony_ci#include <stdint.h> 33060ff233Sopenharmony_ci 34060ff233Sopenharmony_ci#ifdef __cplusplus 35060ff233Sopenharmony_ciextern "C" { 36060ff233Sopenharmony_ci#endif 37060ff233Sopenharmony_ci 38060ff233Sopenharmony_ci/** 39060ff233Sopenharmony_ci * @brief Defines a callback that is invoked when receive the data level from remote device. 40060ff233Sopenharmony_ci * For details, see {@link RegDataLevelChangeCb}. 41060ff233Sopenharmony_ci * 42060ff233Sopenharmony_ci * @since 1.0 43060ff233Sopenharmony_ci * @version 1.0 44060ff233Sopenharmony_ci */ 45060ff233Sopenharmony_citypedef struct { 46060ff233Sopenharmony_ci uint16_t dynamicLevel; /**< dynamic data level, 16bit */ 47060ff233Sopenharmony_ci uint16_t staticLevel; /**< static data level, 16bit */ 48060ff233Sopenharmony_ci uint32_t switchLevel; /**< switch data level, alterable length, 16bit, 24bit or 32bit */ 49060ff233Sopenharmony_ci uint16_t switchLength; /**< switch data length, max 24 switchs */ 50060ff233Sopenharmony_ci} DataLevel; 51060ff233Sopenharmony_ci 52060ff233Sopenharmony_citypedef struct { 53060ff233Sopenharmony_ci /** 54060ff233Sopenharmony_ci * @brief Called when the Data level of a device received. 55060ff233Sopenharmony_ci * 56060ff233Sopenharmony_ci * @param networkId Indicates the network id of the device. 57060ff233Sopenharmony_ci * @param dataLevel Indicates the received data level. 58060ff233Sopenharmony_ci * 59060ff233Sopenharmony_ci * @since 1.0 60060ff233Sopenharmony_ci * @version 1.0 61060ff233Sopenharmony_ci */ 62060ff233Sopenharmony_ci void (*onDataLevelChanged)(const char *networkId, const DataLevel dataLevel); 63060ff233Sopenharmony_ci} IDataLevelCb; 64060ff233Sopenharmony_ci 65060ff233Sopenharmony_ci/** 66060ff233Sopenharmony_ci * @brief Registers a callback for data level received. 67060ff233Sopenharmony_ci * 68060ff233Sopenharmony_ci * @param pkgName Indicates the package name of the caller. 69060ff233Sopenharmony_ci * @param callback Indicates the function callback to be registered. For details, see {@link IDataLevelCb}. 70060ff233Sopenharmony_ci * @return Returns <b>0</b> if the registeration is successful; returns any other value otherwise. 71060ff233Sopenharmony_ci * 72060ff233Sopenharmony_ci * @since 1.0 73060ff233Sopenharmony_ci * @version 1.0 74060ff233Sopenharmony_ci */ 75060ff233Sopenharmony_ciint32_t RegDataLevelChangeCb(const char *pkgName, IDataLevelCb *callback); 76060ff233Sopenharmony_ci 77060ff233Sopenharmony_ci/** 78060ff233Sopenharmony_ci * @brief Unregisters a callback for data level received. 79060ff233Sopenharmony_ci * 80060ff233Sopenharmony_ci * @param pkgName Indicates the package name of the caller. 81060ff233Sopenharmony_ci * @return Returns <b>0</b> if the registeration is successful; returns any other value otherwise. 82060ff233Sopenharmony_ci * 83060ff233Sopenharmony_ci * @since 1.0 84060ff233Sopenharmony_ci * @version 1.0 85060ff233Sopenharmony_ci */ 86060ff233Sopenharmony_ciint32_t UnregDataLevelChangeCb(const char *pkgName); 87060ff233Sopenharmony_ci 88060ff233Sopenharmony_ci/** 89060ff233Sopenharmony_ci * @brief Set the DistributedDataBase Data Level. This interface CAN ONLY invoked by DistributedDataBase. 90060ff233Sopenharmony_ci * 91060ff233Sopenharmony_ci * @param dataLevel Indicates the data level. 92060ff233Sopenharmony_ci * @return Returns <b>0</b> if the registeration is successful; returns any other value otherwise. 93060ff233Sopenharmony_ci * 94060ff233Sopenharmony_ci * @since 1.0 95060ff233Sopenharmony_ci * @version 1.0 96060ff233Sopenharmony_ci */ 97060ff233Sopenharmony_ciint32_t SetDataLevel(const DataLevel *dataLevel); 98060ff233Sopenharmony_ci 99060ff233Sopenharmony_ci#ifdef __cplusplus 100060ff233Sopenharmony_ci} 101060ff233Sopenharmony_ci#endif 102060ff233Sopenharmony_ci#endif