diff --git a/src/app/MessageDef/InvokeResponseMessage.cpp b/src/app/MessageDef/InvokeResponseMessage.cpp index 225f2c3dc4acac..cb36aa15160633 100644 --- a/src/app/MessageDef/InvokeResponseMessage.cpp +++ b/src/app/MessageDef/InvokeResponseMessage.cpp @@ -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)); @@ -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) @@ -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) diff --git a/src/app/MessageDef/InvokeResponseMessage.h b/src/app/MessageDef/InvokeResponseMessage.h index 87cb7c14746646..34cc69aecfe976 100644 --- a/src/app/MessageDef/InvokeResponseMessage.h +++ b/src/app/MessageDef/InvokeResponseMessage.h @@ -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 @@ -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 @@ -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 * diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index 16f7db862ff692..c78545926f59b2 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -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); } @@ -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