Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Jan 30, 2024
1 parent e4827b7 commit 1227872
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
11 changes: 8 additions & 3 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,27 @@ 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;
}

app::ICDClientInfo info;
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;
}
}
Expand Down
11 changes: 7 additions & 4 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -69,12 +70,14 @@ class ModelCommand : public CHIPCommand
void Shutdown() override;

protected:
bool IsPeerLIT() { return mIsPeerLIT.ValueOr(false); }

chip::Optional<uint16_t> mTimeout;
chip::Optional<int> mIsPeerLITCLI;

private:
chip::NodeId mDestinationId;
std::vector<chip::EndpointId> mEndPointId;
chip::Optional<bool> mIsPeerLIT;

void CheckPeerICDType();

Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class SubscribeAttribute : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0));
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeAttribute(device, endpointIds, mClusterIds, mAttributeIds);
}

Expand Down Expand Up @@ -408,7 +408,7 @@ class SubscribeEvent : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0));
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeEvent(device, endpointIds, mClusterIds, mEventIds);
}

Expand Down Expand Up @@ -540,7 +540,7 @@ class SubscribeAll : public SubscribeCommand

CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override
{
SubscribeCommand::SetPeerLIT(mIsPeerLITCLI.ValueOr(0));
SubscribeCommand::SetPeerLIT(IsPeerLIT());
return SubscribeCommand::SubscribeAll(device, endpointIds, mClusterIds, mAttributeIds, mEventIds);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadClient>(InteractionModelEngine::GetInstance(), device->GetExchangeManager(),
Expand Down Expand Up @@ -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<ReadClient>(InteractionModelEngine::GetInstance(), device->GetExchangeManager(),
Expand Down Expand Up @@ -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<ReadClient>(InteractionModelEngine::GetInstance(), device->GetExchangeManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ class InteractionModelReports
}

InteractionModelReports & SetPeerLIT(bool isPeerLIT)
{
mIsPeerLIT.SetValue(isPeerLIT);
return *this;
}

InteractionModelReports & SetPeerLIT(const chip::Optional<bool> & isPeerLIT)
{
mIsPeerLIT = isPeerLIT;
return *this;
Expand All @@ -225,7 +219,7 @@ class InteractionModelReports
mFabricFiltered = chip::Optional<bool>(true);
mKeepSubscriptions = chip::NullOptional;
mAutoResubscribe = chip::NullOptional;
mIsPeerLIT = chip::NullOptional;
mIsPeerLIT = false;
mMinInterval = 0;
mMaxInterval = 0;
}
Expand All @@ -236,7 +230,7 @@ class InteractionModelReports
chip::Optional<bool> mFabricFiltered;
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<bool> mAutoResubscribe;
chip::Optional<bool> mIsPeerLIT;
bool mIsPeerLIT;
uint16_t mMinInterval;
uint16_t mMaxInterval;
};
Expand Down

0 comments on commit 1227872

Please sign in to comment.