Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Feb 26, 2025
1 parent 3d53d30 commit 37f08b6
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 104 deletions.
12 changes: 6 additions & 6 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ void ModelCommand::StoreICDEntryWithKey(app::ICDClientInfo & clientInfo, ByteSpa

void ModelCommand::CheckPeerICDType()
{
if (mIsPeerLIT.HasValue())
if (mIsPeerICD.HasValue())
{
ChipLogProgress(chipTool, "Peer ICD type is set to %s", mIsPeerLIT.Value() == 1 ? "LIT-ICD" : "non LIT-ICD");
ChipLogProgress(chipTool, "Peer device can send ICD checkin message: %s", mIsPeerICD.Value() == 1 ? "Yes" : "no");
return;
}

Expand All @@ -125,17 +125,17 @@ void ModelCommand::CheckPeerICDType()
{
if (ScopedNodeId(info.peer_node.GetNodeId(), info.peer_node.GetFabricIndex()) == destinationPeerId)
{
ChipLogProgress(chipTool, "Peer is a registered LIT ICD.");
mIsPeerLIT.SetValue(true);
ChipLogProgress(chipTool, "Peer is a registered ICD with checkin capability.");
mIsPeerICD.SetValue(true);
return;
}
}
}

bool ModelCommand::IsPeerLIT()
bool ModelCommand::IsPeerICD()
{
CheckPeerICDType();
return mIsPeerLIT.ValueOr(false);
return mIsPeerICD.ValueOr(false);
}

bool ModelCommand::AllowLargePayload()
Expand Down
15 changes: 7 additions & 8 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class ModelCommand : public CHIPCommand
public:
ModelCommand(const char * commandName, CredentialIssuerCommands * credsIssuerConfig, bool supportsMultipleEndpoints = false,
const char * helpText = nullptr) :
CHIPCommand(commandName, credsIssuerConfig, helpText),
mOnDeviceConnectedCallback(OnDeviceConnectedFn, this),
CHIPCommand(commandName, credsIssuerConfig, helpText), mOnDeviceConnectedCallback(OnDeviceConnectedFn, this),
mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureFn, this), mSupportsMultipleEndpoints(supportsMultipleEndpoints)
{}

Expand All @@ -54,10 +53,10 @@ class ModelCommand : public CHIPCommand
"Endpoint the command is targeted at.");
}
}
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("icd-peer", 0, 1, &mIsPeerICD,
"Whether to treat the peer as ICD with check-in capability. false: Always no, true: Always yes, (not set): Yes "
"if the peer is registered "
"to this controller.");
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
AddArgument("allow-large-payload", 0, 1, &mAllowLargePayload,
"If true, indicates that the session should allow large application payloads (which requires a TCP connection)."
Expand All @@ -77,7 +76,7 @@ class ModelCommand : public CHIPCommand
void Shutdown() override;

protected:
bool IsPeerLIT();
bool IsPeerICD();

chip::NodeId GetDestinationId() const { return mDestinationId; }

Expand All @@ -86,7 +85,7 @@ class ModelCommand : public CHIPCommand
private:
chip::NodeId mDestinationId;
std::vector<chip::EndpointId> mEndPointId;
chip::Optional<bool> mIsPeerLIT;
chip::Optional<bool> mIsPeerICD;
chip::Optional<bool> mAllowLargePayload;

void CheckPeerICDType();
Expand Down
18 changes: 7 additions & 11 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ class ReadAttribute : public ReadCommand

ReadAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId,
CredentialIssuerCommands * credsIssuerConfig) :
ReadCommand("read", credsIssuerConfig),
mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
ReadCommand("read", credsIssuerConfig), mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
{
AddArgument("attr-name", attributeName);
AddCommonArguments();
Expand Down Expand Up @@ -272,8 +271,7 @@ class SubscribeAttribute : public SubscribeCommand

SubscribeAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId,
CredentialIssuerCommands * credsIssuerConfig) :
SubscribeCommand("subscribe", credsIssuerConfig),
mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
SubscribeCommand("subscribe", credsIssuerConfig), mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
{
AddArgument("attr-name", attributeName);
AddCommonArguments();
Expand All @@ -284,7 +282,7 @@ class SubscribeAttribute : public SubscribeCommand

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

Expand Down Expand Up @@ -341,8 +339,7 @@ class ReadEvent : public ReadCommand

ReadEvent(chip::ClusterId clusterId, const char * eventName, chip::EventId eventId,
CredentialIssuerCommands * credsIssuerConfig) :
ReadCommand("read-event", credsIssuerConfig),
mClusterIds(1, clusterId), mEventIds(1, eventId)
ReadCommand("read-event", credsIssuerConfig), mClusterIds(1, clusterId), mEventIds(1, eventId)
{
AddArgument("event-name", eventName);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
Expand Down Expand Up @@ -387,8 +384,7 @@ class SubscribeEvent : public SubscribeCommand

SubscribeEvent(chip::ClusterId clusterId, const char * eventName, chip::EventId eventId,
CredentialIssuerCommands * credsIssuerConfig) :
SubscribeCommand("subscribe-event", credsIssuerConfig),
mClusterIds(1, clusterId), mEventIds(1, eventId)
SubscribeCommand("subscribe-event", credsIssuerConfig), mClusterIds(1, clusterId), mEventIds(1, eventId)
{
AddArgument("event-name", eventName, "Event name.");
AddCommonArguments();
Expand Down Expand Up @@ -421,7 +417,7 @@ class SubscribeEvent : public SubscribeCommand

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/icd/ICDCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ CHIP_ERROR ICDListCommand::RunCommand()

CHIP_ERROR ICDWaitForDeviceCommand::RunCommand()
{
if (!IsPeerLIT())
if (!IsPeerICD())
{
ChipLogError(chipTool, "The device is not a registered LIT-ICD device.");
ChipLogError(chipTool, "The device is not a registered ICD device with check-in capability.");
return CHIP_ERROR_NOT_FOUND;
}
mInterestedNode = ScopedNodeId(GetDestinationId(), CurrentCommissioner().GetFabricIndex());
Expand Down
8 changes: 4 additions & 4 deletions examples/fabric-admin/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ void ModelCommand::Shutdown()

void ModelCommand::CheckPeerICDType()
{
if (mIsPeerLIT.HasValue())
if (mIsPeerICD.HasValue())
{
ChipLogProgress(NotSpecified, "Peer ICD type is set to %s", mIsPeerLIT.Value() == 1 ? "LIT-ICD" : "non LIT-ICD");
ChipLogProgress(NotSpecified, "Peer device is ICD with check-in capability: %s", mIsPeerICD.Value() == 1 ? "Yes" : "No");
return;
}

Expand All @@ -97,8 +97,8 @@ void ModelCommand::CheckPeerICDType()
{
if (ScopedNodeId(info.peer_node.GetNodeId(), info.peer_node.GetFabricIndex()) == destinationPeerId)
{
ChipLogProgress(NotSpecified, "Peer is a registered LIT ICD.");
mIsPeerLIT.SetValue(true);
ChipLogProgress(NotSpecified, "Peer is a registered ICD with checkin capability.");
mIsPeerICD.SetValue(true);
return;
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/fabric-admin/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class ModelCommand : public CHIPCommand
"Endpoint the command is targeted at.");
}
}
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("icd-peer", 0, 1, &mIsPeerICD,
"Whether to treat the peer as ICD with checkin capability, 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 @@ -70,14 +70,14 @@ class ModelCommand : public CHIPCommand
void Shutdown() override;

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

chip::Optional<uint16_t> mTimeout;

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

void CheckPeerICDType();

Expand Down
18 changes: 7 additions & 11 deletions examples/fabric-admin/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ class ReadAttribute : public ReadCommand

ReadAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId,
CredentialIssuerCommands * credsIssuerConfig) :
ReadCommand("read", credsIssuerConfig),
mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
ReadCommand("read", credsIssuerConfig), mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
{
AddArgument("attr-name", attributeName);
AddCommonArguments();
Expand Down Expand Up @@ -206,8 +205,7 @@ class SubscribeAttribute : public SubscribeCommand

SubscribeAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId,
CredentialIssuerCommands * credsIssuerConfig) :
SubscribeCommand("subscribe", credsIssuerConfig),
mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
SubscribeCommand("subscribe", credsIssuerConfig), mClusterIds(1, clusterId), mAttributeIds(1, attributeId)
{
AddArgument("attr-name", attributeName);
AddCommonArguments();
Expand All @@ -218,7 +216,7 @@ class SubscribeAttribute : public SubscribeCommand

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

Expand Down Expand Up @@ -273,8 +271,7 @@ class ReadEvent : public ReadCommand

ReadEvent(chip::ClusterId clusterId, const char * eventName, chip::EventId eventId,
CredentialIssuerCommands * credsIssuerConfig) :
ReadCommand("read-event", credsIssuerConfig),
mClusterIds(1, clusterId), mEventIds(1, eventId)
ReadCommand("read-event", credsIssuerConfig), mClusterIds(1, clusterId), mEventIds(1, eventId)
{
AddArgument("event-name", eventName);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
Expand Down Expand Up @@ -315,8 +312,7 @@ class SubscribeEvent : public SubscribeCommand

SubscribeEvent(chip::ClusterId clusterId, const char * eventName, chip::EventId eventId,
CredentialIssuerCommands * credsIssuerConfig) :
SubscribeCommand("subscribe-event", credsIssuerConfig),
mClusterIds(1, clusterId), mEventIds(1, eventId)
SubscribeCommand("subscribe-event", credsIssuerConfig), mClusterIds(1, clusterId), mEventIds(1, eventId)
{
AddArgument("event-name", eventName, "Event name.");
AddCommonArguments();
Expand Down Expand Up @@ -349,7 +345,7 @@ class SubscribeEvent : public SubscribeCommand

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void ModelCommand::StoreICDEntryWithKey(app::ICDClientInfo & clientinfo, ByteSpa
ChipLogError(chipTool, "StoreICDEntryWithKey is not implemented in tv-casting-app");
}

bool ModelCommand::IsPeerLIT()
bool ModelCommand::isPeerICD()
{
// Does not support tv-casting-app
return false;
Expand Down
Loading

0 comments on commit 37f08b6

Please sign in to comment.