From 53ecde4df1e713dee4069ee2d889c310af15229a Mon Sep 17 00:00:00 2001 From: Thivya Ashokkumar Date: Sun, 3 Dec 2023 12:57:07 -0800 Subject: [PATCH] ICDHandler initialization --- src/app/icd/client/ICDHandler.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/icd/client/ICDHandler.cpp b/src/app/icd/client/ICDHandler.cpp index a908847299ee20..720d141eed43ac 100644 --- a/src/app/icd/client/ICDHandler.cpp +++ b/src/app/icd/client/ICDHandler.cpp @@ -33,11 +33,12 @@ #include -#define PWRTWO(exp) (1UL << (exp)) - namespace chip { namespace app { +inline constexpr uint32_t kCheckInCounterMax = UINT32_MAX; +inline constexpr uint32_t kCheckInRolloverConstant = (1U << 31); + static Global sCheckInMessageHandler; CheckInMessageHandler * CheckInMessageHandler::GetInstance() { @@ -88,12 +89,12 @@ CHIP_ERROR CheckInMessageHandler::OnMessageReceived(Messaging::ExchangeContext * err = mICDClientStorage->ProcessCheckInPayload(payloadByteSpan, clientInfo, &counter); if (err == CHIP_NO_ERROR) { - auto checkInCounter = (counter - clientInfo.start_icd_counter) % (PWRTWO(32)); + auto checkInCounter = (counter - clientInfo.start_icd_counter) % kCheckInCounterMax; // TAk - If this condition fails, do we notify the application through callback with an error? if (checkInCounter > clientInfo.offset) { clientInfo.offset = counter - clientInfo.start_icd_counter; - if (checkInCounter > (uint32_t) PWRTWO(31)) + if (checkInCounter > kCheckInRolloverConstant) { // TODO - refresh key }