diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index 792588a886dffb..171c664481c9dd 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -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) @@ -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 @@ -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; }; diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index 94b2b36c5538a3..2a549e62d4668b 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -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()) diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index d4e8eac613f468..79c31cf865930d 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -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: diff --git a/examples/tv-casting-app/tv-casting-common/commands/clusters/ModelCommand.cpp b/examples/tv-casting-app/tv-casting-common/commands/clusters/ModelCommand.cpp index 1210af574603f4..dafa11f2381fed 100644 --- a/examples/tv-casting-app/tv-casting-common/commands/clusters/ModelCommand.cpp +++ b/examples/tv-casting-app/tv-casting-common/commands/clusters/ModelCommand.cpp @@ -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