Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2024 Project CHIP Authors
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #pragma once
19 :
20 : #include <app/icd/server/ICDCheckInBackOffStrategy.h>
21 : #include <lib/core/ClusterEnums.h>
22 :
23 : namespace chip {
24 : namespace app {
25 :
26 : /**
27 : * @brief Default ICD Check-In BackOff Strategy.
28 : * The default strategy is based on the two types of controllers
29 : * - kPermanent : Always send a Check-In message
30 : * - kEphemeral : Never send a Check-In message
31 : *
32 : * This implementation represents a no back off strategy.
33 : */
34 : class DefaultICDCheckInBackOffStrategy : public ICDCheckInBackOffStrategy
35 : {
36 : public:
37 10 : DefaultICDCheckInBackOffStrategy() = default;
38 12 : ~DefaultICDCheckInBackOffStrategy() = default;
39 :
40 : /**
41 : * @brief Function checks if the entry is a permanent or ephemeral client.
42 : * If the client is permanent, we should send a Check-In message.
43 : * If the client is ephemeral, we should not send a Check-In message.
44 : *
45 : * @param entry Entry for which we are deciding whether we need to send a Check-In message or not.
46 : * @return true If the client is permanent, return true.
47 : * @return false If the client is not permanent, ephemeral or invalid, return false.
48 : */
49 2 : bool ShouldSendCheckInMessage(const ICDMonitoringEntry & entry) override
50 : {
51 2 : return (entry.clientType == Clusters::IcdManagement::ClientTypeEnum::kPermanent);
52 : }
53 :
54 : /**
55 : * @brief The default Check-In BackOff fundamentally implements a no back off strategy.
56 : * As such, we don't need to execute anything to force the maximum Check-In BackOff.
57 : *
58 : */
59 0 : CHIP_ERROR ForceMaximumCheckInBackoff() override { return CHIP_NO_ERROR; }
60 : };
61 :
62 : } // namespace app
63 : } // namespace chip
|