1 /* 2 * Copyright (c) 2021-2024 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 CLIENT_BUS_CENTER_MANAGER_H 17 #define CLIENT_BUS_CENTER_MANAGER_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "ble_range.h" 23 #include "data_level.h" 24 #include "data_level_inner.h" 25 #include "softbus_bus_center.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 typedef struct { 32 char peerIp[IP_STR_MAX_LEN]; 33 int32_t peerPort; 34 char targetNetworkId[NETWORK_ID_BUF_LEN]; 35 } TimeSyncSocketInfo; 36 37 typedef struct { 38 TimeSyncResult result; /**< Time synchronize result */ 39 TimeSyncFlag flag; /**< Time synchronize flag */ 40 TimeSyncSocketInfo targetSocketInfo; /**< Time synchronize target info */ 41 } TimeSyncResultWithSocket; 42 43 typedef struct { 44 void (*onTimeSyncResultWithSocket)(const TimeSyncResultWithSocket *info, int32_t retCode); 45 } ITimeSyncCbWithSocket; 46 47 int32_t BusCenterClientInit(void); 48 void BusCenterClientDeinit(void); 49 50 int32_t JoinLNNInner(const char *pkgName, ConnectionAddr *target, OnJoinLNNResult cb, bool isForceJoin); 51 int32_t LeaveLNNInner(const char *pkgName, const char *networkId, OnLeaveLNNResult cb); 52 int32_t RegNodeDeviceStateCbInner(const char *pkgName, INodeStateCb *callback); 53 int32_t UnregNodeDeviceStateCbInner(INodeStateCb *callback); 54 int32_t GetAllNodeDeviceInfoInner(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum); 55 int32_t GetLocalNodeDeviceInfoInner(const char *pkgName, NodeBasicInfo *info); 56 int32_t GetNodeKeyInfoInner(const char *pkgName, const char *networkId, 57 NodeDeviceInfoKey key, uint8_t *info, int32_t infoLen); 58 int32_t SetNodeDataChangeFlagInner(const char *pkgName, const char *networkId, uint16_t dataChangeFlag); 59 int32_t RegDataLevelChangeCbInner(const char *pkgName, IDataLevelCb *callback); 60 int32_t UnregDataLevelChangeCbInner(const char *pkgName); 61 int32_t SetDataLevelInner(const DataLevel *dataLevel); 62 void RestartRegDataLevelChange(void); 63 int32_t RegRangeCbForMsdpInner(const char *pkgName, IRangeCallback *callback); 64 int32_t UnregRangeCbForMsdpInner(const char *pkgName); 65 66 int32_t StartTimeSyncInner(const char *pkgName, const char *targetNetworkId, TimeSyncAccuracy accuracy, 67 TimeSyncPeriod period, ITimeSyncCb *cb); 68 int32_t StartTimeSyncWithSocketInner(const char *pkgName, const TimeSyncSocketInfo *socketInfo, 69 TimeSyncAccuracy accuracy, TimeSyncPeriod period, ITimeSyncCbWithSocket *cbWithSocket); 70 int32_t StopTimeSyncInner(const char *pkgName, const char *targetNetworkId); 71 int32_t StopTimeSyncWithSocketInner(const char *pkgName, const TimeSyncSocketInfo *socketInfo); 72 int32_t PublishLNNInner(const char *pkgName, const PublishInfo *info, const IPublishCb *cb); 73 int32_t StopPublishLNNInner(const char *pkgName, int32_t publishId); 74 int32_t RefreshLNNInner(const char *pkgName, const SubscribeInfo *info, const IRefreshCallback *cb); 75 int32_t StopRefreshLNNInner(const char *pkgName, int32_t refreshId); 76 int32_t ActiveMetaNodeInner(const char *pkgName, const MetaNodeConfigInfo *info, char *metaNodeId); 77 int32_t DeactiveMetaNodeInner(const char *pkgName, const char *metaNodeId); 78 int32_t GetAllMetaNodeInfoInner(const char *pkgName, MetaNodeInfo *infos, int32_t *infoNum); 79 int32_t ShiftLNNGearInner(const char *pkgName, const char *callerId, const char *targetNetworkId, 80 const GearMode *mode); 81 int32_t TriggerRangeForMsdpInner(const char *pkgName, const RangeConfig *config); 82 int32_t StopRangeForMsdpInner(const char *pkgName, const RangeConfig *config); 83 int32_t SyncTrustedRelationShipInner(const char *pkgName, const char *msg, uint32_t msgLen); 84 int32_t SetDisplayNameInner(const char *pkgName, const char *nameData, uint32_t len); 85 86 int32_t LnnOnJoinResult(void *addr, const char *networkId, int32_t retCode); 87 int32_t LnnOnLeaveResult(const char *networkId, int32_t retCode); 88 int32_t LnnOnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info); 89 int32_t LnnOnNodeBasicInfoChanged(const char *pkgName, void *info, int32_t type); 90 int32_t LnnOnNodeStatusChanged(const char *pkgName, void *info, int32_t type); 91 int32_t LnnOnLocalNetworkIdChanged(const char *pkgName); 92 int32_t LnnOnNodeDeviceTrustedChange(const char *pkgName, int32_t type, const char *msg, uint32_t msgLen); 93 int32_t LnnOnHichainProofException( 94 const char *pkgName, const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode); 95 int32_t LnnOnTimeSyncResult(const void *info, int32_t retCode); 96 void LnnOnPublishLNNResult(int32_t publishId, int32_t reason); 97 void LnnOnRefreshLNNResult(int32_t refreshId, int32_t reason); 98 void LnnOnRefreshDeviceFound(const void *device); 99 void LnnOnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo); 100 void LnnOnRangeResult(const RangeResultInnerInfo *rangeInfo); 101 102 int32_t DiscRecoveryPublish(void); 103 int32_t DiscRecoverySubscribe(void); 104 105 #ifdef __cplusplus 106 } 107 #endif 108 #endif 109