@@ -87,6 +87,19 @@ constexpr CommandId kTestCommandIdFillResponseMessage = 7;
87
87
constexpr CommandId kTestNonExistCommandId = 0 ;
88
88
89
89
const app::CommandSender::TestOnlyMarker kCommandSenderTestOnlyMarker ;
90
+
91
+ class SimpleTLVPayload : public app ::DataModel::EncodableToTLV
92
+ {
93
+ public:
94
+ CHIP_ERROR EncodeTo (TLV::TLVWriter & writer, TLV::Tag tag) const override
95
+ {
96
+ TLV::TLVType outerType;
97
+ ReturnErrorOnFailure (writer.StartContainer (tag, TLV::kTLVType_Structure , outerType));
98
+ ReturnErrorOnFailure (writer.PutBoolean (chip::TLV::ContextTag (1 ), true ));
99
+ return writer.EndContainer (outerType);
100
+ }
101
+ };
102
+
90
103
} // namespace
91
104
92
105
namespace app {
@@ -199,12 +212,8 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aRequestCommandPat
199
212
}
200
213
else
201
214
{
202
- const CommandHandler::InvokeResponseParameters prepareParams (aRequestCommandPath);
203
- const ConcreteCommandPath responseCommandPath = aRequestCommandPath;
204
- apCommandObj->PrepareInvokeResponseCommand (responseCommandPath, prepareParams);
205
- chip::TLV::TLVWriter * writer = apCommandObj->GetCommandDataIBTLVWriter ();
206
- writer->PutBoolean (chip::TLV::ContextTag (1 ), true );
207
- apCommandObj->FinishCommand ();
215
+ SimpleTLVPayload payloadWriter;
216
+ apCommandObj->AddResponse (aRequestCommandPath, aRequestCommandPath.mCommandId , payloadWriter);
208
217
}
209
218
}
210
219
@@ -597,8 +606,6 @@ void TestCommandInteraction::AddInvalidInvokeRequestData(nlTestSuite * apSuite,
597
606
void TestCommandInteraction::AddInvokeResponseData (nlTestSuite * apSuite, void * apContext, CommandHandler * apCommandHandler,
598
607
bool aNeedStatusCode, CommandId aResponseCommandId, CommandId aRequestCommandId)
599
608
{
600
- CHIP_ERROR err = CHIP_NO_ERROR;
601
-
602
609
constexpr EndpointId kTestEndpointId = 1 ;
603
610
constexpr ClusterId kTestClusterId = 3 ;
604
611
ConcreteCommandPath requestCommandPath = { kTestEndpointId , kTestClusterId , aRequestCommandId };
@@ -608,17 +615,8 @@ void TestCommandInteraction::AddInvokeResponseData(nlTestSuite * apSuite, void *
608
615
}
609
616
else
610
617
{
611
- const CommandHandler::InvokeResponseParameters prepareParams (requestCommandPath);
612
- ConcreteCommandPath responseCommandPath = { kTestEndpointId , kTestClusterId , aResponseCommandId };
613
- err = apCommandHandler->PrepareInvokeResponseCommand (responseCommandPath, prepareParams);
614
- NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
615
-
616
- chip::TLV::TLVWriter * writer = apCommandHandler->GetCommandDataIBTLVWriter ();
617
-
618
- err = writer->PutBoolean (chip::TLV::ContextTag (1 ), true );
619
- NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
620
-
621
- err = apCommandHandler->FinishCommand ();
618
+ SimpleTLVPayload payloadWriter;
619
+ CHIP_ERROR err = apCommandHandler->AddResponseData (requestCommandPath, aResponseCommandId, payloadWriter);
622
620
NL_TEST_ASSERT (apSuite, err == CHIP_NO_ERROR);
623
621
}
624
622
}
0 commit comments