diff --git a/src/app/icd/BUILD.gn b/src/app/icd/BUILD.gn index fcb396b3bcd41b..b19384c2e41047 100644 --- a/src/app/icd/BUILD.gn +++ b/src/app/icd/BUILD.gn @@ -81,6 +81,7 @@ source_set("sender") { ] public_deps = [ + ":configuration-data", ":monitoring-table", ":notifier", "${chip_root}/src/credentials:credentials", diff --git a/src/app/icd/ICDCheckInSender.cpp b/src/app/icd/ICDCheckInSender.cpp index ea827c2c7ac6c1..026f3f2d5e51ff 100644 --- a/src/app/icd/ICDCheckInSender.cpp +++ b/src/app/icd/ICDCheckInSender.cpp @@ -15,15 +15,12 @@ * limitations under the License. */ -#include "ICDCheckInSender.h" - -#include "ICDNotifier.h" - -#include - -#include - +#include +#include +#include #include +#include +#include namespace chip { namespace app { @@ -61,7 +58,13 @@ CHIP_ERROR ICDCheckInSender::SendCheckInMsg(const Transport::PeerAddress & addr) VerifyOrReturnError(!buffer.IsNull(), CHIP_ERROR_NO_MEMORY); MutableByteSpan output{ buffer->Start(), buffer->MaxDataLength() }; - ReturnErrorOnFailure(CheckinMessage::GenerateCheckinMessagePayload(mAesKeyHandle, mICDCounter, ByteSpan(), output)); + // Encoded ActiveModeThreshold in littleEndian for Check-In message application data + uint8_t activeModeThresholdBuffer[2] = {}; + ByteSpan activeModeThresholdByteSpan(activeModeThresholdBuffer); + Encoding::LittleEndian::Put16((uint8_t *) activeModeThresholdByteSpan.data(), ICDConfigurationData::GetInstance().GetActiveModeThresholdMs()); + + ReturnErrorOnFailure(CheckinMessage::GenerateCheckinMessagePayload(mAes128KeyHandle, mHmac128KeyHandle, mICDCounter, + activeModeThresholdByteSpan, output)); buffer->SetDataLength(static_cast(output.size())); VerifyOrReturnError(mExchangeManager->GetSessionManager() != nullptr, CHIP_ERROR_INTERNAL); @@ -89,9 +92,12 @@ CHIP_ERROR ICDCheckInSender::RequestResolve(ICDMonitoringEntry & entry, FabricTa AddressResolve::NodeLookupRequest request(peerId); - memcpy(mAesKeyHandle.AsMutable(), + memcpy(mAes128KeyHandle.AsMutable(), entry.aesKeyHandle.As(), sizeof(Crypto::Symmetric128BitsKeyByteArray)); + memcpy(mHmac128KeyHandle.AsMutable(), + entry.hmacKeyHandle.As(), sizeof(Crypto::Symmetric128BitsKeyByteArray)); + CHIP_ERROR err = AddressResolve::Resolver::Instance().LookupNode(request, mAddressLookupHandle); if (err == CHIP_NO_ERROR) diff --git a/src/app/icd/ICDCheckInSender.h b/src/app/icd/ICDCheckInSender.h index b6e2dfa2212f92..3156b3655a56f3 100644 --- a/src/app/icd/ICDCheckInSender.h +++ b/src/app/icd/ICDCheckInSender.h @@ -50,7 +50,8 @@ class ICDCheckInSender : public AddressResolve::NodeListener Messaging::ExchangeManager * mExchangeManager = nullptr; - Crypto::Aes128KeyHandle mAesKeyHandle = Crypto::Aes128KeyHandle(); + Crypto::Aes128KeyHandle mAes128KeyHandle = Crypto::Aes128KeyHandle(); + Crypto::Hmac128KeyHandle mHmac128KeyHandle = Crypto::Hmac128KeyHandle(); uint32_t mICDCounter = 0; }; diff --git a/src/app/icd/ICDConfigurationData.cpp b/src/app/icd/ICDConfigurationData.cpp index 6abb9784fde1ce..4df2ca75f217b9 100644 --- a/src/app/icd/ICDConfigurationData.cpp +++ b/src/app/icd/ICDConfigurationData.cpp @@ -28,9 +28,9 @@ System::Clock::Milliseconds32 ICDConfigurationData::GetSlowPollingInterval() // When in SIT mode, the slow poll interval SHOULDN'T be greater than the SIT mode polling threshold, per spec. // This is important for ICD device configured for LIT operation but currently operating as a SIT // due to a lack of client registration - if (mICDMode == ICDMode::SIT && GetSlowPollingInterval() > GetSITPollingThreshold()) + if (mICDMode == ICDMode::SIT && mSlowPollingInterval > kSITPollingThreshold) { - return GetSITPollingThreshold(); + return kSITPollingThreshold; } #endif return mSlowPollingInterval; diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index daf312058ee693..09190ae9dfb8e1 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -275,15 +275,6 @@ void ICDManager::UpdateOperationState(OperationalState state) System::Clock::Milliseconds32 slowPollInterval = ICDConfigurationData::GetInstance().GetSlowPollingInterval(); -#if ICD_ENFORCE_SIT_SLOW_POLL_LIMIT - // When in SIT mode, the slow poll interval SHOULDN'T be greater than the SIT mode polling threshold, per spec. - if (ICDConfigurationData::GetInstance().GetICDMode() == ICDConfigurationData::ICDMode::SIT && - GetSlowPollingInterval() > GetSITPollingThreshold()) - { - slowPollInterval = GetSITPollingThreshold(); - } -#endif - // Going back to Idle, all Check-In messages are sent mICDSenderPool.ReleaseAll();