From 3d69583fb644577269ee468e6a28c0f4d6e40612 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Fri, 30 Aug 2024 10:12:08 -0700 Subject: [PATCH] Fix multiple check-in/peer nodeId handling in icd client side (#35304) --- .../commands/clusters/ClusterCommand.h | 27 ++++++++++++---- .../chip-tool/commands/icd/ICDCommand.cpp | 9 ++++-- .../commands/pairing/PairingCommand.cpp | 3 +- .../icd/client/DefaultICDClientStorage.cpp | 9 +++++- src/app/icd/client/DefaultICDClientStorage.h | 20 ++++++------ src/app/icd/client/ICDClientInfo.h | 2 ++ src/app/icd/client/RefreshKeySender.cpp | 2 +- .../java/AndroidCheckInDelegate.cpp | 31 +++++++++++-------- .../java/AndroidDeviceControllerWrapper.cpp | 8 +++-- src/controller/java/AndroidICDClient.cpp | 19 ++++++++---- .../ICDCheckInDelegateWrapper.java | 18 +++++++++-- .../chip/devicecontroller/ICDClientInfo.java | 12 ++++++- .../src/matter/controller/ICDClientInfo.kt | 3 +- ...Controller-ScriptDevicePairingDelegate.cpp | 3 +- 14 files changed, 119 insertions(+), 47 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index bf5c61fd02bd3f..ad77b5471251f5 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -60,7 +60,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub const chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Type & value) { ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value)); - mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex()); + mPeerNodeId = chip::ScopedNodeId(device->GetDeviceId(), device->GetSecureSession().Value()->GetFabricIndex()); return CHIP_NO_ERROR; } @@ -69,7 +69,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub const chip::app::Clusters::IcdManagement::Commands::RegisterClient::Type & value) { ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value)); - mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex()); + mPeerNodeId = chip::ScopedNodeId(device->GetDeviceId(), device->GetSecureSession().Value()->GetFabricIndex()); + mCheckInNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex()); mMonitoredSubject = value.monitoredSubject; mClientType = value.clientType; memcpy(mICDSymmetricKey, value.key.data(), value.key.size()); @@ -147,7 +148,9 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub return; } chip::app::ICDClientInfo clientInfo; - clientInfo.peer_node = mScopedNodeId; + + clientInfo.peer_node = mPeerNodeId; + clientInfo.check_in_node = mCheckInNodeId; clientInfo.monitored_subject = mMonitoredSubject; clientInfo.start_icd_counter = value.ICDCounter; clientInfo.client_type = mClientType; @@ -159,7 +162,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) && (path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id)) { - ClearICDEntry(mScopedNodeId); + ClearICDEntry(mPeerNodeId); } } @@ -260,9 +263,21 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub private: chip::ClusterId mClusterId; chip::CommandId mCommandId; - chip::ScopedNodeId mScopedNodeId; - uint64_t mMonitoredSubject = static_cast(0); + // The scoped node ID to which RegisterClient and UnregisterClient command will be sent. Not set for other commands. + chip::ScopedNodeId mPeerNodeId; + // The scoped node ID to which a Check-In message will be sent. Only set for the RegisterClient command. + chip::ScopedNodeId mCheckInNodeId; + + // Used to determine if a particular client has an active subscription for the given entry. + // The MonitoredSubject, when it is a NodeID, MAY be the same as the CheckInNodeID. + // The MonitoredSubject gives the registering client the flexibility of having a different + // CheckInNodeID from the MonitoredSubject. + uint64_t mMonitoredSubject = static_cast(0); + + // Client type of the client registering chip::app::Clusters::IcdManagement::ClientTypeEnum mClientType = chip::app::Clusters::IcdManagement::ClientTypeEnum::kPermanent; + + // Shared secret between the client and the ICD to encrypt the Check-In message. uint8_t mICDSymmetricKey[chip::Crypto::kAES_CCM128_Key_Length]; CHIP_ERROR mError = CHIP_NO_ERROR; diff --git a/examples/chip-tool/commands/icd/ICDCommand.cpp b/examples/chip-tool/commands/icd/ICDCommand.cpp index 3f7bfb328d5273..a66192e48bf128 100644 --- a/examples/chip-tool/commands/icd/ICDCommand.cpp +++ b/examples/chip-tool/commands/icd/ICDCommand.cpp @@ -40,14 +40,17 @@ CHIP_ERROR ICDListCommand::RunCommand() fprintf(stderr, " +------------------------------------------------------------------------------------------+\n"); fprintf(stderr, " | %-88s |\n", "Known ICDs:"); fprintf(stderr, " +------------------------------------------------------------------------------------------+\n"); - fprintf(stderr, " | %20s | %15s | %15s | %16s | %10s |\n", "Fabric Index:Node ID", "Start Counter", "Counter Offset", - "MonitoredSubject", "ClientType"); + fprintf(stderr, " | %20s | %20s | %15s | %15s | %16s | %10s |\n", "Fabric Index:Peer Node ID", "Fabric Index:CheckIn Node ID", + "Start Counter", "Counter Offset", "MonitoredSubject", "ClientType"); while (iter->Next(info)) { fprintf(stderr, " +------------------------------------------------------------------------------------------+\n"); - fprintf(stderr, " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 " | " ChipLogFormatX64 " | %10u |\n", + fprintf(stderr, + " | %3" PRIu32 ":" ChipLogFormatX64 " | %3" PRIu32 ":" ChipLogFormatX64 " | %15" PRIu32 " | %15" PRIu32 + " | " ChipLogFormatX64 " | %10u |\n", static_cast(info.peer_node.GetFabricIndex()), ChipLogValueX64(info.peer_node.GetNodeId()), + static_cast(info.check_in_node.GetFabricIndex()), ChipLogValueX64(info.check_in_node.GetNodeId()), info.start_icd_counter, info.offset, ChipLogValueX64(info.monitored_subject), static_cast(info.client_type)); diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 245c9ed57ff82c..b9034cc1285d49 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -469,7 +469,8 @@ void PairingCommand::OnICDRegistrationComplete(ScopedNodeId nodeId, uint32_t icd sizeof(icdSymmetricKeyHex), chip::Encoding::HexFlags::kNullTerminate); app::ICDClientInfo clientInfo; - clientInfo.peer_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex()); + clientInfo.check_in_node = chip::ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex()); + clientInfo.peer_node = nodeId; clientInfo.monitored_subject = mICDMonitoredSubject.Value(); clientInfo.start_icd_counter = icdCounter; diff --git a/src/app/icd/client/DefaultICDClientStorage.cpp b/src/app/icd/client/DefaultICDClientStorage.cpp index 7582e8fd580c40..2b6b3a1aff1657 100644 --- a/src/app/icd/client/DefaultICDClientStorage.cpp +++ b/src/app/icd/client/DefaultICDClientStorage.cpp @@ -235,16 +235,22 @@ CHIP_ERROR DefaultICDClientStorage::Load(FabricIndex fabricIndex, std::vector #include -#define PARSE_CLIENT_INFO(_clientInfo, _peerNodeId, _startCounter, _offset, _monitoredSubject, _jniICDAesKey, _jniICDHmacKey) \ +#define PARSE_CLIENT_INFO(_clientInfo, _peerNodeId, _checkInNodeId, _startCounter, _offset, _monitoredSubject, _jniICDAesKey, \ + _jniICDHmacKey) \ jlong _peerNodeId = static_cast(_clientInfo.peer_node.GetNodeId()); \ + jlong _checkInNodeId = static_cast(_clientInfo.check_in_node.GetNodeId()); \ jlong _startCounter = static_cast(_clientInfo.start_icd_counter); \ jlong _offset = static_cast(_clientInfo.offset); \ jlong _monitoredSubject = static_cast(_clientInfo.monitored_subject); \ @@ -53,24 +55,26 @@ CHIP_ERROR AndroidCheckInDelegate::SetDelegate(jobject checkInDelegateObj) void AndroidCheckInDelegate::OnCheckInComplete(const ICDClientInfo & clientInfo) { - ChipLogProgress( - ICD, "Check In Message processing complete: start_counter=%" PRIu32 " offset=%" PRIu32 " nodeid=" ChipLogFormatScopedNodeId, - clientInfo.start_icd_counter, clientInfo.offset, ChipLogValueScopedNodeId(clientInfo.peer_node)); + ChipLogProgress(ICD, + "Check In Message processing complete: start_counter=%" PRIu32 " offset=%" PRIu32 + " peernodeid=" ChipLogFormatScopedNodeId " checkinnodeid=" ChipLogFormatScopedNodeId, + clientInfo.start_icd_counter, clientInfo.offset, ChipLogValueScopedNodeId(clientInfo.peer_node), + ChipLogValueScopedNodeId(clientInfo.check_in_node)); VerifyOrReturn(mCheckInDelegate.HasValidObjectRef(), ChipLogProgress(ICD, "check-in delegate is not implemented!")); JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "JNIEnv is null!")); - PARSE_CLIENT_INFO(clientInfo, peerNodeId, startCounter, offset, monitoredSubject, jniICDAesKey, jniICDHmacKey) + PARSE_CLIENT_INFO(clientInfo, peerNodeId, checkInNodeId, startCounter, offset, monitoredSubject, jniICDAesKey, jniICDHmacKey) jmethodID onCheckInCompleteMethodID = nullptr; CHIP_ERROR err = chip::JniReferences::GetInstance().FindMethod(env, mCheckInDelegate.ObjectRef(), "onCheckInComplete", - "(JJJJ[B[B)V", &onCheckInCompleteMethodID); + "(JJJJJ[B[B)V", &onCheckInCompleteMethodID); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogProgress(ICD, "onCheckInComplete - FindMethod is failed! : %" CHIP_ERROR_FORMAT, err.Format())); - env->CallVoidMethod(mCheckInDelegate.ObjectRef(), onCheckInCompleteMethodID, peerNodeId, startCounter, offset, monitoredSubject, - jniICDAesKey.jniValue(), jniICDHmacKey.jniValue()); + env->CallVoidMethod(mCheckInDelegate.ObjectRef(), onCheckInCompleteMethodID, peerNodeId, checkInNodeId, startCounter, offset, + monitoredSubject, jniICDAesKey.jniValue(), jniICDHmacKey.jniValue()); } RefreshKeySender * AndroidCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) @@ -84,17 +88,18 @@ RefreshKeySender * AndroidCheckInDelegate::OnKeyRefreshNeeded(ICDClientInfo & cl JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnValue(env != nullptr, nullptr, ChipLogError(Controller, "JNIEnv is null!")); - PARSE_CLIENT_INFO(clientInfo, peerNodeId, startCounter, offset, monitoredSubject, jniICDAesKey, jniICDHmacKey) + PARSE_CLIENT_INFO(clientInfo, peerNodeId, checkInNodeId, startCounter, offset, monitoredSubject, jniICDAesKey, + jniICDHmacKey) jmethodID onKeyRefreshNeededMethodID = nullptr; - err = chip::JniReferences::GetInstance().FindMethod(env, mCheckInDelegate.ObjectRef(), "onKeyRefreshNeeded", "(JJJJ[B[B)V", + err = chip::JniReferences::GetInstance().FindMethod(env, mCheckInDelegate.ObjectRef(), "onKeyRefreshNeeded", "(JJJJJ[B[B)V", &onKeyRefreshNeededMethodID); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(ICD, "onKeyRefreshNeeded - FindMethod is failed! : %" CHIP_ERROR_FORMAT, err.Format())); - jbyteArray key = static_cast(env->CallObjectMethod(mCheckInDelegate.ObjectRef(), onKeyRefreshNeededMethodID, - peerNodeId, startCounter, offset, monitoredSubject, - jniICDAesKey.jniValue(), jniICDHmacKey.jniValue())); + jbyteArray key = static_cast( + env->CallObjectMethod(mCheckInDelegate.ObjectRef(), onKeyRefreshNeededMethodID, peerNodeId, checkInNodeId, startCounter, + offset, monitoredSubject, jniICDAesKey.jniValue(), jniICDHmacKey.jniValue())); if (key != nullptr) { diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index af5d220295a983..f634f8a26fbc6b 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -1015,6 +1015,8 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::ScopedNodeI CHIP_ERROR err = CHIP_NO_ERROR; chip::app::ICDClientInfo clientInfo; clientInfo.peer_node = icdNodeId; + clientInfo.check_in_node = chip::ScopedNodeId(mAutoCommissioner.GetCommissioningParameters().GetICDCheckInNodeId().Value(), + icdNodeId.GetFabricIndex()); clientInfo.monitored_subject = mAutoCommissioner.GetCommissioningParameters().GetICDMonitoredSubject().Value(); clientInfo.start_icd_counter = icdCounter; @@ -1056,7 +1058,7 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::ScopedNodeI methodErr = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ICDDeviceInfo", icdDeviceInfoClass); VerifyOrReturn(methodErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find class ICDDeviceInfo")); - icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "", "([BILjava/lang/String;JJIJJJJI)V"); + icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "", "([BILjava/lang/String;JJIJJJJJI)V"); VerifyOrReturn(icdDeviceInfoStructCtor != nullptr, ChipLogError(Controller, "Could not find ICDDeviceInfo constructor")); methodErr = @@ -1069,7 +1071,9 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::ScopedNodeI icdDeviceInfoObj = env->NewObject( icdDeviceInfoClass, icdDeviceInfoStructCtor, jSymmetricKey, static_cast(mUserActiveModeTriggerHint.Raw()), jUserActiveModeTriggerInstruction, static_cast(mIdleModeDuration), static_cast(mActiveModeDuration), - static_cast(mActiveModeThreshold), static_cast(icdNodeId.GetNodeId()), static_cast(icdCounter), + static_cast(mActiveModeThreshold), static_cast(icdNodeId.GetNodeId()), + static_cast(mAutoCommissioner.GetCommissioningParameters().GetICDCheckInNodeId().Value()), + static_cast(icdCounter), static_cast(mAutoCommissioner.GetCommissioningParameters().GetICDMonitoredSubject().Value()), static_cast(Controller()->GetFabricId()), static_cast(Controller()->GetFabricIndex())); diff --git a/src/controller/java/AndroidICDClient.cpp b/src/controller/java/AndroidICDClient.cpp index 036d92bcf107b7..867a55da350a1f 100644 --- a/src/controller/java/AndroidICDClient.cpp +++ b/src/controller/java/AndroidICDClient.cpp @@ -58,7 +58,7 @@ jobject getICDClientInfo(JNIEnv * env, const char * icdClientInfoSign, jint jFab ChipLogError(Controller, "Find ICDClientInfo class: %" CHIP_ERROR_FORMAT, err.Format())); env->ExceptionClear(); - constructor = env->GetMethodID(infoClass, "", "(JJJJ[B[B)V"); + constructor = env->GetMethodID(infoClass, "", "(JJJJJ[B[B)V"); VerifyOrReturnValue(constructor != nullptr, nullptr, ChipLogError(Controller, "Find GetMethodID error!")); while (iter->Next(info)) @@ -84,9 +84,10 @@ jobject getICDClientInfo(JNIEnv * env, const char * icdClientInfoSign, jint jFab VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogError(Controller, "ICD HMAC KEY N2J_ByteArray error!: %" CHIP_ERROR_FORMAT, err.Format())); - jICDClientInfo = (jobject) env->NewObject(infoClass, constructor, static_cast(info.peer_node.GetNodeId()), - static_cast(info.start_icd_counter), static_cast(info.offset), - static_cast(info.monitored_subject), jIcdAesKey, jIcdHmacKey); + jICDClientInfo = static_cast( + env->NewObject(infoClass, constructor, static_cast(info.peer_node.GetNodeId()), + static_cast(info.check_in_node.GetNodeId()), static_cast(info.start_icd_counter), + static_cast(info.offset), static_cast(info.monitored_subject), jIcdAesKey, jIcdHmacKey)); err = chip::JniReferences::GetInstance().AddToList(jInfo, jICDClientInfo); VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, @@ -154,6 +155,7 @@ CHIP_ERROR ParseICDClientInfo(JNIEnv * env, jint jFabricIndex, jobject jIcdClien VerifyOrReturnError(jIcdClientInfo != nullptr, CHIP_ERROR_INVALID_ARGUMENT); jmethodID getPeerNodeIdMethod = nullptr; + jmethodID getCheckInNodeIdMethod = nullptr; jmethodID getStartCounterMethod = nullptr; jmethodID getOffsetMethod = nullptr; jmethodID getMonitoredSubjectMethod = nullptr; @@ -162,6 +164,8 @@ CHIP_ERROR ParseICDClientInfo(JNIEnv * env, jint jFabricIndex, jobject jIcdClien ReturnErrorOnFailure( chip::JniReferences::GetInstance().FindMethod(env, jIcdClientInfo, "getPeerNodeId", "()J", &getPeerNodeIdMethod)); + ReturnErrorOnFailure( + chip::JniReferences::GetInstance().FindMethod(env, jIcdClientInfo, "getCheckInNodeId", "()J", &getCheckInNodeIdMethod)); ReturnErrorOnFailure( chip::JniReferences::GetInstance().FindMethod(env, jIcdClientInfo, "getStartCounter", "()J", &getStartCounterMethod)); ReturnErrorOnFailure(chip::JniReferences::GetInstance().FindMethod(env, jIcdClientInfo, "getOffset", "()J", &getOffsetMethod)); @@ -173,17 +177,20 @@ CHIP_ERROR ParseICDClientInfo(JNIEnv * env, jint jFabricIndex, jobject jIcdClien chip::JniReferences::GetInstance().FindMethod(env, jIcdClientInfo, "getIcdHmacKey", "()[B", &getIcdHmacKeyMethod)); jlong jPeerNodeId = env->CallLongMethod(jIcdClientInfo, getPeerNodeIdMethod); + jlong jCheckInNodeId = env->CallLongMethod(jIcdClientInfo, getCheckInNodeIdMethod); jlong jStartCounter = env->CallLongMethod(jIcdClientInfo, getStartCounterMethod); jlong jOffset = env->CallLongMethod(jIcdClientInfo, getOffsetMethod); jlong jMonitoredSubject = env->CallLongMethod(jIcdClientInfo, getMonitoredSubjectMethod); jbyteArray jIcdAesKey = static_cast(env->CallObjectMethod(jIcdClientInfo, getIcdAesKeyMethod)); jbyteArray jIcdHmacKey = static_cast(env->CallObjectMethod(jIcdClientInfo, getIcdHmacKeyMethod)); - chip::ScopedNodeId scopedNodeId(static_cast(jPeerNodeId), static_cast(jFabricIndex)); + chip::ScopedNodeId peerNodeId(static_cast(jPeerNodeId), static_cast(jFabricIndex)); + chip::ScopedNodeId checkInNodeId(static_cast(jCheckInNodeId), static_cast(jFabricIndex)); chip::JniByteArray jniIcdAesKey(env, jIcdAesKey); chip::JniByteArray jniIcdHmacKey(env, jIcdHmacKey); - icdClientInfo.peer_node = scopedNodeId; + icdClientInfo.peer_node = peerNodeId; + icdClientInfo.check_in_node = checkInNodeId; icdClientInfo.start_icd_counter = static_cast(jStartCounter); icdClientInfo.offset = static_cast(jOffset); icdClientInfo.monitored_subject = static_cast(jMonitoredSubject); diff --git a/src/controller/java/src/chip/devicecontroller/ICDCheckInDelegateWrapper.java b/src/controller/java/src/chip/devicecontroller/ICDCheckInDelegateWrapper.java index 39ca5df1b9e766..3b338045a248e2 100644 --- a/src/controller/java/src/chip/devicecontroller/ICDCheckInDelegateWrapper.java +++ b/src/controller/java/src/chip/devicecontroller/ICDCheckInDelegateWrapper.java @@ -29,6 +29,7 @@ class ICDCheckInDelegateWrapper { @SuppressWarnings("unused") private void onCheckInComplete( long peerNodeId, + long checkInNodeId, long startCounter, long offset, long monitoredSubject, @@ -36,12 +37,19 @@ private void onCheckInComplete( byte[] icdHmacKey) { delegate.onCheckInComplete( new ICDClientInfo( - peerNodeId, startCounter, offset, monitoredSubject, icdAesKey, icdHmacKey)); + peerNodeId, + checkInNodeId, + startCounter, + offset, + monitoredSubject, + icdAesKey, + icdHmacKey)); } @SuppressWarnings("unused") private byte[] onKeyRefreshNeeded( long peerNodeId, + long checkInNodeId, long startCounter, long offset, long monitoredSubject, @@ -49,7 +57,13 @@ private byte[] onKeyRefreshNeeded( byte[] icdHmacKey) { return delegate.onKeyRefreshNeeded( new ICDClientInfo( - peerNodeId, startCounter, offset, monitoredSubject, icdAesKey, icdHmacKey)); + peerNodeId, + checkInNodeId, + startCounter, + offset, + monitoredSubject, + icdAesKey, + icdHmacKey)); } @SuppressWarnings("unused") diff --git a/src/controller/java/src/chip/devicecontroller/ICDClientInfo.java b/src/controller/java/src/chip/devicecontroller/ICDClientInfo.java index 77df9179e115ee..ff028ae487ce23 100644 --- a/src/controller/java/src/chip/devicecontroller/ICDClientInfo.java +++ b/src/controller/java/src/chip/devicecontroller/ICDClientInfo.java @@ -20,6 +20,7 @@ /** Class for holding ICD Client information. */ public class ICDClientInfo { private final long peerNodeId; + private final long checkInNodeId; private final long startCounter; private final long offset; private final long monitoredSubject; @@ -28,12 +29,14 @@ public class ICDClientInfo { public ICDClientInfo( long peerNodeId, + long checkInNodeId, long startCounter, long offset, long monitoredSubject, byte[] icdAesKey, byte[] icdHmacKey) { this.peerNodeId = peerNodeId; + this.checkInNodeId = checkInNodeId; this.startCounter = startCounter; this.offset = offset; this.monitoredSubject = monitoredSubject; @@ -41,11 +44,16 @@ public ICDClientInfo( this.icdHmacKey = icdHmacKey; } - /** Returns the check in peer node ID. */ + /** Returns the peer node ID. */ public long getPeerNodeId() { return peerNodeId; } + /** Returns the check in node ID. */ + public long getCheckInNodeId() { + return checkInNodeId; + } + /** Returns the Start Counter. */ public long getStartCounter() { return startCounter; @@ -76,6 +84,8 @@ public String toString() { return "ICDClientInfo{" + "\n\tpeerNodeId=" + peerNodeId + + "\n\tcheckInNodeId=" + + checkInNodeId + "\n\t, startCounter=" + startCounter + "\n\t, offset=" diff --git a/src/controller/java/src/matter/controller/ICDClientInfo.kt b/src/controller/java/src/matter/controller/ICDClientInfo.kt index 3f0f30255a7dbc..a1c543a044bacc 100644 --- a/src/controller/java/src/matter/controller/ICDClientInfo.kt +++ b/src/controller/java/src/matter/controller/ICDClientInfo.kt @@ -21,11 +21,12 @@ package matter.controller /** Class for holding ICD Client information. */ data class ICDClientInfo( val peerNodeId: Long, + val checkInNodeId: Long, val startCounter: Long, val offset: Long, val monitoredSubject: Long, val icdAesKey: ByteArray, val icdHmacKey: ByteArray ) { - override fun toString(): String = "$peerNodeId/$startCounter/$offset/$monitoredSubject" + override fun toString(): String = "$peerNodeId/$checkInNodeId/$startCounter/$offset/$monitoredSubject" } diff --git a/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp b/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp index c04481a45a11ea..11dc4bc70720a4 100644 --- a/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp +++ b/src/controller/python/ChipDeviceController-ScriptDevicePairingDelegate.cpp @@ -188,7 +188,8 @@ ScriptDevicePairingDelegate::GetOpenWindowCallback(Controller::CommissioningWind void ScriptDevicePairingDelegate::OnICDRegistrationComplete(ScopedNodeId nodeId, uint32_t icdCounter) { app::ICDClientInfo clientInfo; - clientInfo.peer_node = nodeId; + clientInfo.peer_node = nodeId; + clientInfo.check_in_node = chip::ScopedNodeId(sCommissioningParameters.GetICDCheckInNodeId().Value(), nodeId.GetFabricIndex()); clientInfo.monitored_subject = sCommissioningParameters.GetICDMonitoredSubject().Value(); clientInfo.start_icd_counter = icdCounter; clientInfo.client_type = sCommissioningParameters.GetICDClientType().Value();