Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EncodableToTLV in im_responder #33693

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/app/tests/integration/chip_im_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@
namespace chip {
namespace app {

namespace {

class TestTLVDataEncoder : public chip::app::DataModel::EncodableToTLV
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
{
public:
CHIP_ERROR EncodeTo(TLV::TLVWriter & writer, TLV::Tag tag) const override
{
TLV::TLVType outerType;
ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outerType));

ReturnErrorOnFailure(writer.Put(chip::TLV::ContextTag(kTestFieldId1), kTestFieldValue1));
ReturnErrorOnFailure(writer.Put(chip::TLV::ContextTag(kTestFieldId2), kTestFieldValue2));

return writer.EndContainer(outerType);
}
};

} // namespace

Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath)
{
// The Mock cluster catalog -- only have one command on one cluster on one endpoint.
Expand Down Expand Up @@ -104,17 +123,8 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aRequestCommandPat
{
printf("responder constructing command data in command");

chip::TLV::TLVWriter * writer;

const CommandHandler::InvokeResponseParameters prepareParams(aRequestCommandPath);
ReturnOnFailure(apCommandObj->PrepareInvokeResponseCommand(path, prepareParams));

writer = apCommandObj->GetCommandDataIBTLVWriter();
ReturnOnFailure(writer->Put(chip::TLV::ContextTag(kTestFieldId1), kTestFieldValue1));

ReturnOnFailure(writer->Put(chip::TLV::ContextTag(kTestFieldId2), kTestFieldValue2));

ReturnOnFailure(apCommandObj->FinishCommand());
TestTLVDataEncoder testData;
apCommandObj->AddResponse(path, kTestCommandId, testData);
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
}
statusCodeFlipper = !statusCodeFlipper;
}
Expand Down
Loading