|
18 | 18 |
|
19 | 19 | #pragma once
|
20 | 20 |
|
21 |
| -#include <app/tests/suites/commands/interaction_model/InteractionModel.h> |
22 |
| - |
23 | 21 | #include "DataModelLogger.h"
|
24 | 22 | #include "ModelCommand.h"
|
| 23 | +#include <app/tests/suites/commands/interaction_model/InteractionModel.h> |
25 | 24 |
|
26 | 25 | class ClusterCommand : public InteractionModelCommands, public ModelCommand, public chip::app::CommandSender::Callback
|
27 | 26 | {
|
@@ -64,6 +63,17 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
|
64 | 63 | return CHIP_NO_ERROR;
|
65 | 64 | }
|
66 | 65 |
|
| 66 | + CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId, |
| 67 | + chip::CommandId commandId, |
| 68 | + const chip::app::Clusters::IcdManagement::Commands::RegisterClient::Type & value) |
| 69 | + { |
| 70 | + ReturnErrorOnFailure(InteractionModelCommands::SendCommand(device, endpointId, clusterId, commandId, value)); |
| 71 | + mScopedNodeId = chip::ScopedNodeId(value.checkInNodeID, device->GetSecureSession().Value()->GetFabricIndex()); |
| 72 | + mMonitoredSubject = value.monitoredSubject; |
| 73 | + memcpy(mICDSymmetricKey, value.key.data(), value.key.size()); |
| 74 | + return CHIP_NO_ERROR; |
| 75 | + } |
| 76 | + |
67 | 77 | CHIP_ERROR SendCommand(chip::DeviceProxy * device, chip::EndpointId endpointId, chip::ClusterId clusterId,
|
68 | 78 | chip::CommandId commandId,
|
69 | 79 | const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type & value)
|
@@ -117,11 +127,32 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
|
117 | 127 | mError = error;
|
118 | 128 | return;
|
119 | 129 | }
|
| 130 | + if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) && |
| 131 | + (path.mCommandId == chip::app::Clusters::IcdManagement::Commands::RegisterClient::Id)) |
| 132 | + { |
| 133 | + chip::TLV::TLVReader counterTlvReader; |
| 134 | + counterTlvReader.Init(*data); |
| 135 | + chip::app::Clusters::IcdManagement::Commands::RegisterClientResponse::DecodableType value; |
| 136 | + CHIP_ERROR err = chip::app::DataModel::Decode(counterTlvReader, value); |
| 137 | + if (CHIP_NO_ERROR != err) |
| 138 | + { |
| 139 | + ChipLogError(chipTool, "Failed to decode ICD counter: %" CHIP_ERROR_FORMAT, err.Format()); |
| 140 | + return; |
| 141 | + } |
| 142 | + |
| 143 | + chip::app::ICDClientInfo clientInfo; |
| 144 | + clientInfo.peer_node = mScopedNodeId; |
| 145 | + clientInfo.monitored_subject = mMonitoredSubject; |
| 146 | + clientInfo.start_icd_counter = value.ICDCounter; |
| 147 | + |
| 148 | + StoreICDEntryWithKey(clientInfo, chip::ByteSpan(mICDSymmetricKey)); |
| 149 | + } |
120 | 150 | }
|
| 151 | + |
121 | 152 | if ((path.mEndpointId == chip::kRootEndpointId) && (path.mClusterId == chip::app::Clusters::IcdManagement::Id) &&
|
122 | 153 | (path.mCommandId == chip::app::Clusters::IcdManagement::Commands::UnregisterClient::Id))
|
123 | 154 | {
|
124 |
| - ModelCommand::ClearICDEntry(mScopedNodeId); |
| 155 | + ClearICDEntry(mScopedNodeId); |
125 | 156 | }
|
126 | 157 | }
|
127 | 158 |
|
@@ -223,6 +254,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
|
223 | 254 | chip::ClusterId mClusterId;
|
224 | 255 | chip::CommandId mCommandId;
|
225 | 256 | chip::ScopedNodeId mScopedNodeId;
|
| 257 | + uint64_t mMonitoredSubject = static_cast<uint64_t>(0); |
| 258 | + uint8_t mICDSymmetricKey[chip::Crypto::kAES_CCM128_Key_Length]; |
226 | 259 | CHIP_ERROR mError = CHIP_NO_ERROR;
|
227 | 260 | CustomArgument mPayload;
|
228 | 261 | };
|
0 commit comments