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

Changes to InvokeResponseMessage to reflect 1.3 spec #30639

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions src/app/MessageDef/InvokeResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ CHIP_ERROR InvokeResponseMessage::Parser::PrettyPrint() const
ReturnErrorOnFailure(invokeResponses.PrettyPrint());
PRETTY_PRINT_DECDEPTH();
}
break;
case to_underlying(Tag::kMoreChunkedMessages):
#if CHIP_DETAIL_LOGGING
{
bool moreChunkedMessages;
ReturnErrorOnFailure(reader.Get(moreChunkedMessages));
PRETTY_PRINT("\tmoreChunkedMessages = %s, ", moreChunkedMessages ? "true" : "false");
}
#endif // CHIP_DETAIL_LOGGING
break;
case kInteractionModelRevisionTag:
ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader));
Expand Down Expand Up @@ -98,6 +107,11 @@ CHIP_ERROR InvokeResponseMessage::Parser::GetInvokeResponses(InvokeResponseIBs::
return apStatus->Init(reader);
}

CHIP_ERROR InvokeResponseMessage::Parser::GetMoreChunkedMessages(bool * const apMoreChunkedMessages) const
{
return GetSimpleValue(to_underlying(Tag::kMoreChunkedMessages), TLV::kTLVType_Boolean, apMoreChunkedMessages);
}

InvokeResponseMessage::Builder & InvokeResponseMessage::Builder::SuppressResponse(const bool aSuppressResponse)
{
if (mError == CHIP_NO_ERROR)
Expand All @@ -116,6 +130,16 @@ InvokeResponseIBs::Builder & InvokeResponseMessage::Builder::CreateInvokeRespons
return mInvokeResponses;
}

InvokeResponseMessage::Builder & InvokeResponseMessage::Builder::MoreChunkedMessages(const bool aMoreChunkedMessages)
{
// skip if error has already been set
if (mError == CHIP_NO_ERROR)
{
mError = mpWriter->PutBoolean(TLV::ContextTag(Tag::kMoreChunkedMessages), aMoreChunkedMessages);
}
return *this;
}

CHIP_ERROR InvokeResponseMessage::Builder::EndOfInvokeResponseMessage()
{
if (mError == CHIP_NO_ERROR)
Expand Down
22 changes: 20 additions & 2 deletions src/app/MessageDef/InvokeResponseMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ namespace app {
namespace InvokeResponseMessage {
enum class Tag : uint8_t
{
kSuppressResponse = 0,
kInvokeResponses = 1,
kSuppressResponse = 0,
kInvokeResponses = 1,
kMoreChunkedMessages = 2,
};

class Parser : public MessageParser
Expand All @@ -61,6 +62,16 @@ class Parser : public MessageParser
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetInvokeResponses(InvokeResponseIBs::Parser * const apInvokeResponses) const;

/**
* @brief Get MoreChunkedMessages boolean
*
* @param [out] apMoreChunkedMessages A pointer to bool for storing more chunked messages value.
*
* @return #CHIP_NO_ERROR on success
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetMoreChunkedMessages(bool * const apMoreChunkedMessages) const;
};

class Builder : public MessageBuilder
Expand All @@ -86,6 +97,13 @@ class Builder : public MessageBuilder
*/
InvokeResponseIBs::Builder & GetInvokeResponses() { return mInvokeResponses; }

/**
* @brief Set True if the set of InvokeResponseIB have to be sent across multiple packets in a single transaction
* @param [in] aMoreChunkedMessages true if more chunked messages are needed
* @return A reference to *this
*/
InvokeResponseMessage::Builder & MoreChunkedMessages(const bool aMoreChunkedMessages);

/**
* @brief Mark the end of this InvokeResponseMessage
*
Expand Down
12 changes: 11 additions & 1 deletion src/app/tests/TestMessageDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,9 @@ void BuildInvokeResponseMessage(nlTestSuite * apSuite, chip::TLV::TLVWriter & aW

BuildInvokeResponses(apSuite, invokeResponsesBuilder);

invokeResponseMessageBuilder.MoreChunkedMessages(true);
NL_TEST_ASSERT(apSuite, invokeResponseMessageBuilder.GetError() == CHIP_NO_ERROR);

invokeResponseMessageBuilder.EndOfInvokeResponseMessage();
NL_TEST_ASSERT(apSuite, invokeResponseMessageBuilder.GetError() == CHIP_NO_ERROR);
}
Expand All @@ -966,8 +969,15 @@ void ParseInvokeResponseMessage(nlTestSuite * apSuite, chip::TLV::TLVReader & aR
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

bool suppressResponse = false;
invokeResponseMessageParser.GetSuppressResponse(&suppressResponse);
err = invokeResponseMessageParser.GetSuppressResponse(&suppressResponse);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, suppressResponse == true);

bool moreChunkedMessages = true;
err = invokeResponseMessageParser.GetMoreChunkedMessages(&suppressResponse);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite, moreChunkedMessages == true);

#if CHIP_CONFIG_IM_PRETTY_PRINT
invokeResponseMessageParser.PrettyPrint();
#endif
Expand Down
Loading