From 1227872dc7f21ba52ce2ea87ac3c82b98e80c3fa Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 23 Jan 2024 07:13:13 +0000 Subject: [PATCH] Update --- examples/chip-tool/commands/clusters/ModelCommand.cpp | 11 ++++++++--- examples/chip-tool/commands/clusters/ModelCommand.h | 11 +++++++---- examples/chip-tool/commands/clusters/ReportCommand.h | 6 +++--- .../commands/interaction_model/InteractionModel.cpp | 6 +++--- .../commands/interaction_model/InteractionModel.h | 10 ++-------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index fc7d34eb404331..c2b09b133923bd 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -77,9 +77,9 @@ void ModelCommand::Shutdown() void ModelCommand::CheckPeerICDType() { - if (mIsPeerLITCLI.HasValue()) + if (mIsPeerLIT.HasValue()) { - ChipLogProgress(chipTool, "Peer is ICD type set to %s", mIsPeerLITCLI.Value() == 1 ? "LIT-ICD" : "non LIT-ICD"); + ChipLogProgress(chipTool, "Peer ICD type is set to %s", mIsPeerLIT.Value() == 1 ? "LIT-ICD" : "non LIT-ICD"); return; } @@ -87,12 +87,17 @@ void ModelCommand::CheckPeerICDType() auto destinationPeerId = chip::ScopedNodeId(mDestinationId, CurrentCommissioner().GetFabricIndex()); auto iter = CHIPCommand::sICDClientStorage.IterateICDClientInfo(); + if (iter == nullptr) + { + return; + } + 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); + mIsPeerLIT.SetValue(true); return; } } diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 354389fb85af37..9561932c9b74e0 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -52,9 +52,10 @@ 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( + "lit-icd-peer", 0, 1, &mIsPeerLIT, + "Whether to treat the peer as a LIT ICD. false: Always no, true: Always yes, (not set): Yes if the peer is registered " + "to this controller."); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } @@ -69,12 +70,14 @@ class ModelCommand : public CHIPCommand void Shutdown() override; protected: + bool IsPeerLIT() { return mIsPeerLIT.ValueOr(false); } + chip::Optional mTimeout; - chip::Optional mIsPeerLITCLI; private: chip::NodeId mDestinationId; std::vector mEndPointId; + chip::Optional mIsPeerLIT; void CheckPeerICDType(); diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index 186b0cff57fa32..e2c0f1db785900 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -277,7 +277,7 @@ class SubscribeAttribute : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { - SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); + SubscribeCommand::SetPeerLIT(IsPeerLIT()); return SubscribeCommand::SubscribeAttribute(device, endpointIds, mClusterIds, mAttributeIds); } @@ -408,7 +408,7 @@ class SubscribeEvent : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { - SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); + SubscribeCommand::SetPeerLIT(IsPeerLIT()); return SubscribeCommand::SubscribeEvent(device, endpointIds, mClusterIds, mEventIds); } @@ -540,7 +540,7 @@ class SubscribeAll : public SubscribeCommand CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override { - SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0)); + SubscribeCommand::SetPeerLIT(IsPeerLIT()); 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 bb0ee7c9e52d3f..04e658f18cc188 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -350,7 +350,7 @@ CHIP_ERROR InteractionModelReports::ReportAttribute(DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } - params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); + params.mIsPeerLIT = mIsPeerLIT; } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -480,7 +480,7 @@ CHIP_ERROR InteractionModelReports::ReportEvent(DeviceProxy * device, std::vecto { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } - params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); + params.mIsPeerLIT = mIsPeerLIT; } auto client = std::make_unique(InteractionModelEngine::GetInstance(), device->GetExchangeManager(), @@ -654,7 +654,7 @@ CHIP_ERROR InteractionModelReports::ReportAll(chip::DeviceProxy * device, std::v { params.mKeepSubscriptions = mKeepSubscriptions.Value(); } - params.mIsPeerLIT = mIsPeerLIT.ValueOr(false); + params.mIsPeerLIT = mIsPeerLIT; } 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 7ca595014cd6a1..dbbf4246680c5f 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -206,12 +206,6 @@ class InteractionModelReports } InteractionModelReports & SetPeerLIT(bool isPeerLIT) - { - mIsPeerLIT.SetValue(isPeerLIT); - return *this; - } - - InteractionModelReports & SetPeerLIT(const chip::Optional & isPeerLIT) { mIsPeerLIT = isPeerLIT; return *this; @@ -225,7 +219,7 @@ class InteractionModelReports mFabricFiltered = chip::Optional(true); mKeepSubscriptions = chip::NullOptional; mAutoResubscribe = chip::NullOptional; - mIsPeerLIT = chip::NullOptional; + mIsPeerLIT = false; mMinInterval = 0; mMaxInterval = 0; } @@ -236,7 +230,7 @@ class InteractionModelReports chip::Optional mFabricFiltered; chip::Optional mKeepSubscriptions; chip::Optional mAutoResubscribe; - chip::Optional mIsPeerLIT; + bool mIsPeerLIT; uint16_t mMinInterval; uint16_t mMaxInterval; };