forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICD] Implement the support of the ICD Check-In BackOff (project-chip…
…#34482) * Add MaximunCheckInBackOff attribute to ICDM cluster * Add injectable ICD Check-In BackOff strategy * Fix gn dependency * Fix non CIP builds * Fix switch case and add test * Update zcl with extensions * Fix zap generation * Refactor ICDManager init to leverage a builder pattern * Fix non LIT test builds * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]> --------- Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
Showing
21 changed files
with
408 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/icd/server/ICDCheckInBackOffStrategy.h> | ||
#include <lib/core/ClusterEnums.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
|
||
/** | ||
* @brief Default ICD Check-In BackOff Strategy. | ||
* The default strategy is based on the two types of controllers | ||
* - kPermanent : Always send a Check-In message | ||
* - kEphemeral : Never send a Check-In message | ||
* | ||
* This implementation represents a no back off strategy. | ||
*/ | ||
class DefaultICDCheckInBackOffStrategy : public ICDCheckInBackOffStrategy | ||
{ | ||
public: | ||
DefaultICDCheckInBackOffStrategy() = default; | ||
~DefaultICDCheckInBackOffStrategy() = default; | ||
|
||
/** | ||
* @brief Function checks if the entry is a permanent or ephemeral client. | ||
* If the client is permanent, we should send a Check-In message. | ||
* If the client is ephemeral, we should not send a Check-In message. | ||
* | ||
* @param entry Entry for which we are deciding whether we need to send a Check-In message or not. | ||
* @return true If the client is permanent, return true. | ||
* @return false If the client is not permanent, ephemeral or invalid, return false. | ||
*/ | ||
bool ShouldSendCheckInMessage(const ICDMonitoringEntry & entry) override | ||
{ | ||
return (entry.clientType == Clusters::IcdManagement::ClientTypeEnum::kPermanent); | ||
} | ||
|
||
/** | ||
* @brief The default Check-In BackOff fundamentally implements a no back off strategy. | ||
* As such, we don't need to execute anything to force the maximum Check-In BackOff. | ||
* | ||
*/ | ||
CHIP_ERROR ForceMaximumCheckInBackoff() override { return CHIP_NO_ERROR; } | ||
}; | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
#include <app/icd/server/ICDMonitoringTable.h> | ||
#include <lib/core/CHIPError.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
|
||
/** | ||
* @brief This class defines the necessary interface a ICD Check-In BackOff strategy needs to implment to be consummed by the | ||
* ICDManager class. The strategy is injected with the init server params when initializing the device Server class. | ||
*/ | ||
class ICDCheckInBackOffStrategy | ||
{ | ||
public: | ||
virtual ~ICDCheckInBackOffStrategy() = default; | ||
|
||
/** | ||
* @brief Function is used by the ICDManager to determine if a Check-In message should be sent to the given entry based on the | ||
* Check-In BackOff strategy. | ||
* | ||
* There are no requirements on how the Check-In BackOff strategy should behave. | ||
* The only specified requirement is the maximum time between to Check-In message, MaximumCheckInBackOff. | ||
* All strategies must respect this requirement. | ||
* | ||
* @param entry ICDMonitoringEntry for which we are about to send a Check-In message to. | ||
* | ||
* @return true ICDCheckInBackOffStrategy determines that we SHOULD send a Check-In message to the given entry | ||
* @return false ICDCheckInBackOffStrategy determines that we SHOULD NOT send a Check-In message to the given entry | ||
*/ | ||
virtual bool ShouldSendCheckInMessage(const ICDMonitoringEntry & entry) = 0; | ||
|
||
/** | ||
* @brief Function is used within the test event trigger to force the maximum BackOff state of the ICD Check-In BackOff | ||
* strategy. This enables to validate the strategy and to certify it respects the MaximumCheckInBackOff interval during | ||
* certification. | ||
* | ||
* Function sets the maxmimum BackOff state for all clients registered with the ICD | ||
* | ||
* @return CHIP_ERROR Any error returned during the forcing of the maximum BackOff state | ||
*/ | ||
virtual CHIP_ERROR ForceMaximumCheckInBackoff() = 0; | ||
}; | ||
|
||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.