|
50 | 50 | namespace chip {
|
51 | 51 | namespace app {
|
52 | 52 |
|
| 53 | +namespace { |
| 54 | + |
| 55 | +class TestTLVDataEncoder : public DataModel::EncodableToTLV |
| 56 | +{ |
| 57 | +public: |
| 58 | + CHIP_ERROR EncodeTo(TLV::TLVWriter & writer, TLV::Tag tag) const override |
| 59 | + { |
| 60 | + TLV::TLVType outerType; |
| 61 | + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outerType)); |
| 62 | + |
| 63 | + ReturnErrorOnFailure(writer.Put(chip::TLV::ContextTag(kTestFieldId1), kTestFieldValue1)); |
| 64 | + ReturnErrorOnFailure(writer.Put(chip::TLV::ContextTag(kTestFieldId2), kTestFieldValue2)); |
| 65 | + |
| 66 | + return writer.EndContainer(outerType); |
| 67 | + } |
| 68 | +}; |
| 69 | + |
| 70 | +} // namespace |
| 71 | + |
53 | 72 | Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
|
54 | 73 | {
|
55 | 74 | // The Mock cluster catalog -- only have one command on one cluster on one endpoint.
|
@@ -104,17 +123,8 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aRequestCommandPat
|
104 | 123 | {
|
105 | 124 | printf("responder constructing command data in command");
|
106 | 125 |
|
107 |
| - chip::TLV::TLVWriter * writer; |
108 |
| - |
109 |
| - const CommandHandler::InvokeResponseParameters prepareParams(aRequestCommandPath); |
110 |
| - ReturnOnFailure(apCommandObj->PrepareInvokeResponseCommand(path, prepareParams)); |
111 |
| - |
112 |
| - writer = apCommandObj->GetCommandDataIBTLVWriter(); |
113 |
| - ReturnOnFailure(writer->Put(chip::TLV::ContextTag(kTestFieldId1), kTestFieldValue1)); |
114 |
| - |
115 |
| - ReturnOnFailure(writer->Put(chip::TLV::ContextTag(kTestFieldId2), kTestFieldValue2)); |
116 |
| - |
117 |
| - ReturnOnFailure(apCommandObj->FinishCommand()); |
| 126 | + TestTLVDataEncoder testData; |
| 127 | + apCommandObj->AddResponse(path, kTestCommandId, testData); |
118 | 128 | }
|
119 | 129 | statusCodeFlipper = !statusCodeFlipper;
|
120 | 130 | }
|
|
0 commit comments