diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index 31fd2e14a15a1f..fc7d34eb404331 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -35,6 +35,7 @@ CHIP_ERROR ModelCommand::RunCommand() } ChipLogProgress(chipTool, "Sending command to node 0x%" PRIx64, mDestinationId); + CheckPeerICDType(); CommissioneeDeviceProxy * commissioneeDeviceProxy = nullptr; if (CHIP_NO_ERROR == CurrentCommissioner().GetDeviceBeingCommissioned(mDestinationId, &commissioneeDeviceProxy)) @@ -73,3 +74,26 @@ void ModelCommand::Shutdown() CHIPCommand::Shutdown(); } + +void ModelCommand::CheckPeerICDType() +{ + if (mIsPeerLITCLI.HasValue()) + { + ChipLogProgress(chipTool, "Peer is ICD type set to %s", mIsPeerLITCLI.Value() == 1 ? "LIT-ICD" : "non LIT-ICD"); + return; + } + + app::ICDClientInfo info; + auto destinationPeerId = chip::ScopedNodeId(mDestinationId, CurrentCommissioner().GetFabricIndex()); + auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo(); + + while (iter->Next(info)) + { + if (ScopedNodeId(info.peer_node.GetNodeId(), info.peer_node.GetFabricIndex()) == destinationPeerId) + { + ChipLogProgress(chipTool, "Peer is a registered LIT ICD."); + mIsPeerLITCLI.SetValue(true); + return; + } + } +} diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 0b6339ab60f5ed..354389fb85af37 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -52,6 +52,9 @@ class ModelCommand : public CHIPCommand "Endpoint the command is targeted at."); } } + AddArgument("lit-icd-peer", 0, 1, &mIsPeerLITCLI, + "Whether to treat the peer as a LIT ICD. 0: Always no, 1: Always yes, (not set): Yes if the peer is registered " + "to this controller."); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } @@ -67,11 +70,14 @@ class ModelCommand : public CHIPCommand protected: chip::Optional mTimeout; + chip::Optional mIsPeerLITCLI; private: chip::NodeId mDestinationId; std::vector mEndPointId; + void CheckPeerICDType(); + static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle); static void OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error); diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index eefd938c2d0717..186b0cff57fa32 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -277,6 +277,7 @@ class SubscribeAttribute : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); return SubscribeCommand::SubscribeAttribute(device, endpointIds, mClusterIds, mAttributeIds); } @@ -407,6 +408,7 @@ class SubscribeEvent : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); return SubscribeCommand::SubscribeEvent(device, endpointIds, mClusterIds, mEventIds); } @@ -538,6 +540,7 @@ class SubscribeAll : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { + SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); return SubscribeCommand::SubscribeAll(device, endpointIds, mClusterIds, mAttributeIds, mEventIds); } diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index a2c418435990e4..bb0ee7c9e52d3f 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -350,6 +350,7 @@ CHIP_ERROR InteractionModelReports::ReportAttribute(DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -479,6 +480,7 @@ CHIP_ERROR InteractionModelReports::ReportEvent(DeviceProxy * device, std::vecto { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -652,6 +654,7 @@ CHIP_ERROR InteractionModelReports::ReportAll(chip::DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } + params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index da3c3378a45d90..7ca595014cd6a1 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -205,6 +205,18 @@ class InteractionModelReports return *this; } + InteractionModelReports & SetPeerLIT(bool isPeerLIT) + { + mIsPeerLIT.SetValue(isPeerLIT); + return *this; + } + + InteractionModelReports & SetPeerLIT(const chip::Optional & isPeerLIT) + { + mIsPeerLIT = isPeerLIT; + return *this; + } + void ResetOptions() { mDataVersions = chip::NullOptional; @@ -213,6 +225,7 @@ class InteractionModelReports mFabricFiltered = chip::Optional(true); mKeepSubscriptions = chip::NullOptional; mAutoResubscribe = chip::NullOptional; + mIsPeerLIT = chip::NullOptional; mMinInterval = 0; mMaxInterval = 0; } @@ -223,6 +236,7 @@ class InteractionModelReports chip::Optional mFabricFiltered; chip::Optional mKeepSubscriptions; chip::Optional mAutoResubscribe; + chip::Optional mIsPeerLIT; uint16_t mMinInterval; uint16_t mMaxInterval; };