Skip to content

Commit 4d10d22

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

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

+16-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#include "DataModelLogger.h"
2424
#include "ModelCommand.h"
25+
#include <app-common/zap-generated/cluster-objects.h>
26+
#include <app-common/zap-generated/ids/Attributes.h>
27+
#include <app-common/zap-generated/ids/Clusters.h>
2528

2629
class ClusterCommand : public InteractionModelCommands, public ModelCommand, public chip::app::CommandSender::Callback
2730
{
@@ -59,6 +62,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
5962
chip::CommandId commandId,
6063
const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type & value)
6164
{
65+
mPeerNodeId = device->GetDeviceId();
66+
mFabricIndex = device->GetSecureSession().Value()->GetFabricIndex();
6267
ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value));
6368

6469
if (value.transferFileDesignator.HasValue() &&
@@ -109,6 +114,15 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
109114
return;
110115
}
111116
}
117+
if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) && (path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id))
118+
{
119+
CHIP_ERROR deleteEntryError =
120+
CHIPCommand::sICDClientStorage.DeleteEntry(chip::ScopedNodeId(mPeerNodeId, mFabricIndex));
121+
if (deleteEntryError != CHIP_NO_ERROR)
122+
{
123+
ChipLogError(chipTool, "Failed to delete ICD entry: %s", chip::ErrorStr(deleteEntryError));
124+
}
125+
}
112126
}
113127

114128
virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override
@@ -208,7 +222,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
208222
private:
209223
chip::ClusterId mClusterId;
210224
chip::CommandId mCommandId;
211-
225+
chip::FabricIndex mFabricIndex = 0;
226+
chip::NodeId mPeerNodeId = 0;
212227
CHIP_ERROR mError = CHIP_NO_ERROR;
213228
CustomArgument mPayload;
214229
};

0 commit comments

Comments
 (0)