Skip to content

Commit 24b692a

Browse files
Remove icd entry in icd client storage after unregisterClient is
triggered
1 parent 83d35a3 commit 24b692a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

examples/chip-tool/commands/clusters/ClusterCommand.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
5959
chip::CommandId commandId,
6060
const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type & value)
6161
{
62+
mPeerNodeId = device->GetDeviceId();
63+
mFabricIndex = device->GetSecureSession().Value()->GetFabricIndex();
6264
ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value));
6365

6466
if (value.transferFileDesignator.HasValue() &&
@@ -109,6 +111,15 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
109111
return;
110112
}
111113
}
114+
if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) && (path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id))
115+
{
116+
CHIP_ERROR deleteEntryError =
117+
CHIPCommand::sICDClientStorage.DeleteEntry(chip::ScopedNodeId(mPeerNodeId, mFabricIndex));
118+
if (deleteEntryError != CHIP_NO_ERROR)
119+
{
120+
ChipLogError(chipTool, "Failed to delete ICD entry: %s", chip::ErrorStr(deleteEntryError));
121+
}
122+
}
112123
}
113124

114125
virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override
@@ -208,7 +219,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
208219
private:
209220
chip::ClusterId mClusterId;
210221
chip::CommandId mCommandId;
211-
222+
chip::FabricIndex mFabricIndex = 0;
223+
chip::NodeId mPeerNodeId = 0;
212224
CHIP_ERROR mError = CHIP_NO_ERROR;
213225
CustomArgument mPayload;
214226
};

0 commit comments

Comments
 (0)