Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chip-tool][ICD]Remove icd entry in icd client storage after unregisterClient in ICDManagemenet is triggered #33671

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
return InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value);
}

CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId,
chip::CommandId commandId,
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());
return CHIP_NO_ERROR;
}

CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId,
chip::CommandId commandId,
const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type & value)
Expand Down Expand Up @@ -109,6 +118,11 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
return;
}
}
if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) &&
(path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id))
{
ModelCommand::ClearICDEntry(mScopedNodeId);
}
}

virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override
Expand Down Expand Up @@ -208,7 +222,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
private:
chip::ClusterId mClusterId;
chip::CommandId mCommandId;

chip::ScopedNodeId mScopedNodeId;
CHIP_ERROR mError = CHIP_NO_ERROR;
CustomArgument mPayload;
};
9 changes: 9 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ void ModelCommand::Shutdown()
CHIPCommand::Shutdown();
}

void ModelCommand::ClearICDEntry(const chip::ScopedNodeId & nodeId)
{
CHIP_ERROR deleteEntryError = CHIPCommand::sICDClientStorage.DeleteEntry(nodeId);
if (deleteEntryError != CHIP_NO_ERROR)
{
ChipLogError(chipTool, "Failed to delete ICD entry: %" CHIP_ERROR_FORMAT, deleteEntryError.Format());
}
}

void ModelCommand::CheckPeerICDType()
{
if (mIsPeerLIT.HasValue())
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class ModelCommand : public CHIPCommand

virtual CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) { return CHIP_ERROR_BAD_REQUEST; };

virtual void ClearICDEntry(const chip::ScopedNodeId & nodeId);

void Shutdown() override;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ void ModelCommand::Shutdown()
mOnDeviceConnectionFailureCallback.Cancel();
}

void ModelCommand::ClearICDEntry(const chip::ScopedNodeId & nodeId)
{
ChipLogError(chipTool, "ClearICDEntry is not implemented in tv-casting-app");
}

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