Skip to content

Commit

Permalink
ICDHandler initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
thivya-amazon committed Dec 3, 2023
1 parent 2102751 commit 53ecde4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/icd/client/ICDHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@

#include <protocols/secure_channel/Constants.h>

#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<CheckInMessageHandler> sCheckInMessageHandler;
CheckInMessageHandler * CheckInMessageHandler::GetInstance()
{
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 53ecde4

Please sign in to comment.