1 /* 2 * Copyright (c) 2023 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 LNN_HEARTBETA_MEDIUM_MGR_STRUCT_H 17 #define LNN_HEARTBETA_MEDIUM_MGR_STRUCT_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 22 #include "lnn_heartbeat_utils_struct.h" 23 #include "softbus_common.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 typedef struct { 30 /** Heartbeat media type. For details, see {@link LnnHeartbeatType}. */ 31 LnnHeartbeatType type; 32 union { 33 /** Defines parameters of ble heartbeat. */ 34 struct BleParam { 35 /** minimum time between the start of two consecutive advertising events. */ 36 uint16_t advMinInterval; 37 /** maximum time between the start of two consecutive advertising events. */ 38 uint16_t advMaxInterval; 39 /** Interval between the start of two consecutive scan windows. */ 40 uint16_t scanInterval; 41 /** The duration in which the link layer scans on one channel. */ 42 uint16_t scanWindow; 43 } ble; 44 } info; 45 } LnnHeartbeatMediumParam; 46 47 typedef struct { 48 int32_t weight; 49 int32_t localMasterWeight; 50 } LnnHeartbeatWeight; 51 52 typedef struct { 53 void (*onRelay)(const char *udidHash, ConnectionAddrType type, LnnHeartbeatType hbType); 54 int32_t (*onReceive)(DeviceInfo *device, const LnnHeartbeatWeight *mediumWeight, LnnHeartbeatType hbType, 55 bool isOnlineDirectly, HbRespData *hbResp); 56 int32_t (*onRecvHigherWeight)(const char *udidHash, int32_t weight, ConnectionAddrType type, bool isReElect, 57 bool isPeerScreenOn); 58 void (*onRecvLpInfo)(const char *networkId, uint64_t nowTime); 59 void (*onRecvSleInfo)(const char *networkId, SleDeviceInfo *info); 60 } LnnHeartbeatMediumMgrCb; 61 62 typedef struct { 63 LnnHeartbeatType hbType; 64 bool wakeupFlag; 65 bool isRelay; 66 bool isSyncData; 67 bool isFirstBegin; 68 bool isNeedRestart; 69 bool hasScanRsp; 70 bool isFast; 71 bool isDirectBoardcast; 72 bool isMsdpRange; 73 char networkId[NETWORK_ID_BUF_LEN]; 74 } LnnHeartbeatSendBeginData; 75 76 typedef struct { 77 LnnHeartbeatType hbType; 78 bool wakeupFlag; 79 bool isRelay; 80 bool isLastEnd; 81 bool isMsdpRange; 82 } LnnHeartbeatSendEndData; 83 84 typedef struct { 85 LnnHeartbeatType supportType; 86 int32_t (*init)(const LnnHeartbeatMediumMgrCb *callback); 87 int32_t (*onSendOneHbBegin)(const LnnHeartbeatSendBeginData *custData); 88 int32_t (*onSendOneHbEnd)(const LnnHeartbeatSendEndData *custData); 89 int32_t (*onSetMediumParam)(const LnnHeartbeatMediumParam *param); 90 int32_t (*onUpdateSendInfo)(LnnHeartbeatUpdateInfoType type); 91 int32_t (*onStopHbByType)(void); 92 void (*deinit)(void); 93 } LnnHeartbeatMediumMgr; 94 95 #ifdef __cplusplus 96 } 97 #endif 98 #endif /*LNN_HEARTBETA_MEDIUM_MGR_STRUCT_H */