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 LNN_HEARTBEAT_STRATEGY_H
17 #define LNN_HEARTBEAT_STRATEGY_H
18 
19 #include "lnn_heartbeat_fsm.h"
20 #include "softbus_bus_center.h"
21 #include "softbus_common.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct {
28     LnnHeartbeatType supportType;
29     int32_t (*onProcess)(LnnHeartbeatFsm *hbFsm, void *obj);
30 } LnnHeartbeatStrategyManager;
31 
32 int32_t LnnSetGearModeBySpecificType(const char *callerId, const GearMode *mode, LnnHeartbeatType type);
33 int32_t LnnGetGearModeBySpecificType(GearMode *mode, char *callerId, LnnHeartbeatType type);
34 int32_t LnnSetMediumParamBySpecificType(const LnnHeartbeatMediumParam *param);
35 int32_t LnnGetMediumParamBySpecificType(LnnHeartbeatMediumParam *param, LnnHeartbeatType type);
36 
37 int32_t LnnSetHbAsMasterNodeState(bool isMasterNode);
38 int32_t LnnGetHbStrategyManager(
39     LnnHeartbeatStrategyManager *mgr, LnnHeartbeatType hbType, LnnHeartbeatStrategyType strategyType);
40 
41 int32_t LnnStartNewHbStrategyFsm(void);
42 int32_t LnnStartHbByTypeAndStrategy(LnnHeartbeatType hbType, LnnHeartbeatStrategyType strategyType, bool isRelay);
43 int32_t LnnStartHeartbeat(uint64_t delayMillis);
44 int32_t LnnStopHeartbeatByType(LnnHeartbeatType type);
45 int32_t LnnStopV0HeartbeatAndNotTransState();
46 int32_t LnnStartOfflineTimingStrategy(const char *networkId, ConnectionAddrType addrType);
47 int32_t LnnStopOfflineTimingStrategy(const char *networkId, ConnectionAddrType addrType);
48 int32_t LnnStartScreenChangeOfflineTiming(const char *networkId, ConnectionAddrType addrType);
49 int32_t LnnStopScreenChangeOfflineTiming(const char *networkId, ConnectionAddrType addrType);
50 int32_t LnnStopHeartBeatAdvByTypeNow(LnnHeartbeatType registedHbType);
51 int32_t LnnUpdateSendInfoStrategy(LnnHeartbeatUpdateInfoType type);
52 LnnHeartbeatStrategyType GetStrategyTypeByPolicy(int32_t policy);
53 
54 bool LnnIsHeartbeatEnable(LnnHeartbeatType type);
55 int32_t LnnEnableHeartbeatByType(LnnHeartbeatType type, bool isEnable);
56 
57 int32_t LnnRegistParamMgrByType(LnnHeartbeatType type);
58 void LnnUnRegistParamMgrByType(LnnHeartbeatType type);
59 
60 int32_t LnnHbStrategyInit(void);
61 void LnnHbStrategyDeinit(void);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif /* LNN_HEARTBEAT_STRATEGY_H */
67