Skip to content

Commit 452cad3

Browse files
[chip-tool][ICD]Remove icd entry in icd client storage after unregisterClient in ICDManagemenet is triggered (#33671)
* Remove icd entry in icd client storage after unregisterClient is triggered * Restyled by clang-format * address comments * Update ModelCommand.cpp * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 17c5a00 commit 452cad3

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
5555
return InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value);
5656
}
5757

58+
CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId,
59+
chip::CommandId commandId,
60+
const chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Type & value)
61+
{
62+
ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value));
63+
mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex());
64+
return CHIP_NO_ERROR;
65+
}
66+
5867
CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId,
5968
chip::CommandId commandId,
6069
const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type & value)
@@ -109,6 +118,11 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
109118
return;
110119
}
111120
}
121+
if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) &&
122+
(path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id))
123+
{
124+
ModelCommand::ClearICDEntry(mScopedNodeId);
125+
}
112126
}
113127

114128
virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override
@@ -208,7 +222,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
208222
private:
209223
chip::ClusterId mClusterId;
210224
chip::CommandId mCommandId;
211-
225+
chip::ScopedNodeId mScopedNodeId;
212226
CHIP_ERROR mError = CHIP_NO_ERROR;
213227
CustomArgument mPayload;
214228
};

examples/chip-tool/commands/clusters/ModelCommand.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ void ModelCommand::Shutdown()
7676
CHIPCommand::Shutdown();
7777
}
7878

79+
void ModelCommand::ClearICDEntry(const chip::ScopedNodeId & nodeId)
80+
{
81+
CHIP_ERROR deleteEntryError = CHIPCommand::sICDClientStorage.DeleteEntry(nodeId);
82+
if (deleteEntryError != CHIP_NO_ERROR)
83+
{
84+
ChipLogError(chipTool, "Failed to delete ICD entry: %" CHIP_ERROR_FORMAT, deleteEntryError.Format());
85+
}
86+
}
87+
7988
void ModelCommand::CheckPeerICDType()
8089
{
8190
if (mIsPeerLIT.HasValue())

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

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class ModelCommand : public CHIPCommand
6767

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

70+
virtual void ClearICDEntry(const chip::ScopedNodeId & nodeId);
71+
7072
void Shutdown() override;
7173

7274
protected:

examples/tv-casting-app/tv-casting-common/commands/clusters/ModelCommand.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ void ModelCommand::Shutdown()
8282
mOnDeviceConnectionFailureCallback.Cancel();
8383
}
8484

85+
void ModelCommand::ClearICDEntry(const chip::ScopedNodeId & nodeId)
86+
{
87+
ChipLogError(chipTool, "ClearICDEntry is not implemented in tv-casting-app");
88+
}
89+
8590
bool ModelCommand::IsPeerLIT()
8691
{
8792
// Does not support tv-casting-app

0 commit comments

Comments
 (0)