From 3260993499aea032e8dc2cf5861728266d972b70 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Mon, 11 Oct 2021 17:12:06 -0700 Subject: [PATCH] Rename StatusElement to StatusIB (#10395) --- src/app/BUILD.gn | 8 +- src/app/CommandHandler.cpp | 13 ++- src/app/CommandSender.cpp | 18 ++-- src/app/CommandSender.h | 4 +- ...tatusElement.cpp => AttributeStatusIB.cpp} | 42 ++++----- ...uteStatusElement.h => AttributeStatusIB.h} | 32 +++---- src/app/MessageDef/AttributeStatusList.cpp | 6 +- src/app/MessageDef/AttributeStatusList.h | 6 +- src/app/MessageDef/CommandDataElement.cpp | 33 ++++--- src/app/MessageDef/CommandDataElement.h | 22 ++--- .../{StatusElement.cpp => StatusIB.cpp} | 26 +++--- .../{StatusElement.h => StatusIB.h} | 32 +++---- src/app/WriteClient.cpp | 14 +-- src/app/WriteClient.h | 4 +- src/app/WriteHandler.cpp | 24 ++--- src/app/WriteHandler.h | 2 +- src/app/tests/TestMessageDef.cpp | 87 +++++++++---------- src/app/tests/TestWriteInteraction.cpp | 19 ++-- 18 files changed, 194 insertions(+), 198 deletions(-) rename src/app/MessageDef/{AttributeStatusElement.cpp => AttributeStatusIB.cpp} (76%) rename src/app/MessageDef/{AttributeStatusElement.h => AttributeStatusIB.h} (77%) rename src/app/MessageDef/{StatusElement.cpp => StatusIB.cpp} (83%) rename src/app/MessageDef/{StatusElement.h => StatusIB.h} (77%) diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index ae8a9dd65f1312..24ec4557a92876 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -51,8 +51,8 @@ static_library("app") { "MessageDef/AttributePath.h", "MessageDef/AttributePathList.cpp", "MessageDef/AttributePathList.h", - "MessageDef/AttributeStatusElement.cpp", - "MessageDef/AttributeStatusElement.h", + "MessageDef/AttributeStatusIB.cpp", + "MessageDef/AttributeStatusIB.h", "MessageDef/AttributeStatusList.cpp", "MessageDef/AttributeStatusList.h", "MessageDef/Builder.cpp", @@ -85,8 +85,8 @@ static_library("app") { "MessageDef/ReadRequest.h", "MessageDef/ReportData.cpp", "MessageDef/ReportData.h", - "MessageDef/StatusElement.cpp", - "MessageDef/StatusElement.h", + "MessageDef/StatusIB.cpp", + "MessageDef/StatusIB.h", "MessageDef/StatusResponse.cpp", "MessageDef/SubscribeRequest.cpp", "MessageDef/SubscribeResponse.cpp", diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index f33f27cdbd3808..63a5922b3b7a89 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -155,7 +155,7 @@ CHIP_ERROR CommandHandler::AddStatusCode(const ConcreteCommandPath & aCommandPat const Protocols::Id aProtocolId, const Protocols::InteractionModel::Status aStatus) { CHIP_ERROR err = CHIP_NO_ERROR; - StatusElement::Builder statusElementBuilder; + StatusIB::Builder statusIBBuilder; chip::app::CommandPathParams commandPathParams = { aCommandPath.mEndpointId, 0, // GroupId @@ -165,18 +165,17 @@ CHIP_ERROR CommandHandler::AddStatusCode(const ConcreteCommandPath & aCommandPat err = PrepareCommand(commandPathParams, false /* aStartDataStruct */); SuccessOrExit(err); - statusElementBuilder = - mInvokeCommandBuilder.GetCommandListBuilder().GetCommandDataElementBuilder().CreateStatusElementBuilder(); + statusIBBuilder = mInvokeCommandBuilder.GetCommandListBuilder().GetCommandDataElementBuilder().CreateStatusIBBuilder(); // // TODO: Most of the callers are incorrectly passing SecureChannel as the protocol ID, when in fact, the status code provided // above is always an IM code. Instead of fixing all the callers (which is a fairly sizeable change), we'll embark on fixing // this more completely when we fix #9530. // - statusElementBuilder - .EncodeStatusElement(aGeneralCode, Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm(), chip::to_underlying(aStatus)) - .EndOfStatusElement(); - err = statusElementBuilder.GetError(); + statusIBBuilder + .EncodeStatusIB(aGeneralCode, Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm(), chip::to_underlying(aStatus)) + .EndOfStatusIB(); + err = statusIBBuilder.GetError(); SuccessOrExit(err); err = FinishCommand(false /* aEndDataStruct */); diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 163b4614db03c5..70c6afe3178445 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -145,14 +145,14 @@ CHIP_ERROR CommandSender::ProcessCommandDataElement(CommandDataElement::Parser & chip::TLV::TLVReader commandDataReader; // Default to success when an invoke response is received. - StatusElement::Type statusElement{ chip::Protocols::SecureChannel::GeneralStatusCode::kSuccess, - chip::Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm(), - to_underlying(Protocols::InteractionModel::Status::Success) }; - StatusElement::Parser statusElementParser; - err = aCommandElement.GetStatusElement(&statusElementParser); + StatusIB::Type statusIB{ chip::Protocols::SecureChannel::GeneralStatusCode::kSuccess, + chip::Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm(), + to_underlying(Protocols::InteractionModel::Status::Success) }; + StatusIB::Parser statusIBParser; + err = aCommandElement.GetStatusIB(&statusIBParser); if (CHIP_NO_ERROR == err) { - err = statusElementParser.DecodeStatusElement(statusElement); + err = statusIBParser.DecodeStatusIB(statusIB); } else if (CHIP_END_OF_TLV == err) { @@ -163,16 +163,16 @@ CHIP_ERROR CommandSender::ProcessCommandDataElement(CommandDataElement::Parser & if (mpCallback != nullptr) { - if (statusElement.protocolId == Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm()) + if (statusIB.protocolId == Protocols::InteractionModel::Id.ToFullyQualifiedSpecForm()) { - if (statusElement.protocolCode == to_underlying(Protocols::InteractionModel::Status::Success)) + if (statusIB.protocolCode == to_underlying(Protocols::InteractionModel::Status::Success)) { mpCallback->OnResponse(this, ConcreteCommandPath(endpointId, clusterId, commandId), hasDataResponse ? &commandDataReader : nullptr); } else { - mpCallback->OnError(this, static_cast(statusElement.protocolCode), + mpCallback->OnError(this, static_cast(statusIB.protocolCode), CHIP_ERROR_IM_STATUS_CODE_RECEIVED); } } diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index 1d599a460d7dac..89c6106b1ba520 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -39,7 +39,7 @@ #include #include -#include +#include #define COMMON_STATUS_SUCCESS 0 @@ -65,7 +65,7 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate * * @param[in] apCommandSender: The command sender object that initiated the command transaction. * @param[in] aPath: The command path field in invoke command response. - * @param[in] aData: The command data, will be nullptr if the server returns a StatusElement. + * @param[in] aData: The command data, will be nullptr if the server returns a StatusIB. */ virtual void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, TLV::TLVReader * aData) {} diff --git a/src/app/MessageDef/AttributeStatusElement.cpp b/src/app/MessageDef/AttributeStatusIB.cpp similarity index 76% rename from src/app/MessageDef/AttributeStatusElement.cpp rename to src/app/MessageDef/AttributeStatusIB.cpp index cab149c8f6ee4a..addb3e547a96fb 100644 --- a/src/app/MessageDef/AttributeStatusElement.cpp +++ b/src/app/MessageDef/AttributeStatusIB.cpp @@ -17,11 +17,11 @@ */ /** * @file - * This file defines AttributeStatusElement parser and builder in CHIP interaction model + * This file defines AttributeStatusIB parser and builder in CHIP interaction model * */ -#include "AttributeStatusElement.h" +#include "AttributeStatusIB.h" #include "MessageDefHelper.h" @@ -36,12 +36,12 @@ using namespace chip::TLV; namespace chip { namespace app { -CHIP_ERROR AttributeStatusElement::Builder::Init(chip::TLV::TLVWriter * const apWriter) +CHIP_ERROR AttributeStatusIB::Builder::Init(chip::TLV::TLVWriter * const apWriter) { return InitAnonymousStructure(apWriter); } -AttributePath::Builder & AttributeStatusElement::Builder::CreateAttributePathBuilder() +AttributePath::Builder & AttributeStatusIB::Builder::CreateAttributePathBuilder() { // skip if error has already been set VerifyOrExit(CHIP_NO_ERROR == mError, mAttributePathBuilder.ResetError(mError)); @@ -52,24 +52,24 @@ AttributePath::Builder & AttributeStatusElement::Builder::CreateAttributePathBui return mAttributePathBuilder; } -StatusElement::Builder & AttributeStatusElement::Builder::CreateStatusElementBuilder() +StatusIB::Builder & AttributeStatusIB::Builder::CreateStatusIBBuilder() { // skip if error has already been set - VerifyOrExit(CHIP_NO_ERROR == mError, mStatusElementBuilder.ResetError(mError)); + VerifyOrExit(CHIP_NO_ERROR == mError, mStatusIBBuilder.ResetError(mError)); - mError = mStatusElementBuilder.Init(mpWriter, kCsTag_StatusElement); + mError = mStatusIBBuilder.Init(mpWriter, kCsTag_StatusIB); exit: - return mStatusElementBuilder; + return mStatusIBBuilder; } -AttributeStatusElement::Builder & AttributeStatusElement::Builder::EndOfAttributeStatusElement() +AttributeStatusIB::Builder & AttributeStatusIB::Builder::EndOfAttributeStatusIB() { EndOfContainer(); return *this; } -CHIP_ERROR AttributeStatusElement::Parser::Init(const chip::TLV::TLVReader & aReader) +CHIP_ERROR AttributeStatusIB::Parser::Init(const chip::TLV::TLVReader & aReader) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -84,13 +84,13 @@ CHIP_ERROR AttributeStatusElement::Parser::Init(const chip::TLV::TLVReader & aRe } #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK -CHIP_ERROR AttributeStatusElement::Parser::CheckSchemaValidity() const +CHIP_ERROR AttributeStatusIB::Parser::CheckSchemaValidity() const { CHIP_ERROR err = CHIP_NO_ERROR; uint16_t TagPresenceMask = 0; chip::TLV::TLVReader reader; - PRETTY_PRINT("AttributeStatusElement ="); + PRETTY_PRINT("AttributeStatusIB ="); PRETTY_PRINT("{"); // make a copy of the reader @@ -115,11 +115,11 @@ CHIP_ERROR AttributeStatusElement::Parser::CheckSchemaValidity() const PRETTY_PRINT_DECDEPTH(); } break; - case kCsTag_StatusElement: - VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_StatusElement)), err = CHIP_ERROR_INVALID_TLV_TAG); - TagPresenceMask |= (1 << kCsTag_StatusElement); + case kCsTag_StatusIB: + VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_StatusIB)), err = CHIP_ERROR_INVALID_TLV_TAG); + TagPresenceMask |= (1 << kCsTag_StatusIB); { - StatusElement::Parser status; + StatusIB::Parser status; err = status.Init(reader); SuccessOrExit(err); @@ -141,7 +141,7 @@ CHIP_ERROR AttributeStatusElement::Parser::CheckSchemaValidity() const if (CHIP_END_OF_TLV == err) { // check for required fields: - const uint16_t RequiredFields = (1 << kCsTag_AttributePath) | (1 << kCsTag_StatusElement); + const uint16_t RequiredFields = (1 << kCsTag_AttributePath) | (1 << kCsTag_StatusIB); if ((TagPresenceMask & RequiredFields) == RequiredFields) { @@ -161,7 +161,7 @@ CHIP_ERROR AttributeStatusElement::Parser::CheckSchemaValidity() const } #endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK -CHIP_ERROR AttributeStatusElement::Parser::GetAttributePath(AttributePath::Parser * const apAttributePath) const +CHIP_ERROR AttributeStatusIB::Parser::GetAttributePath(AttributePath::Parser * const apAttributePath) const { CHIP_ERROR err = CHIP_NO_ERROR; chip::TLV::TLVReader reader; @@ -180,17 +180,17 @@ CHIP_ERROR AttributeStatusElement::Parser::GetAttributePath(AttributePath::Parse return err; } -CHIP_ERROR AttributeStatusElement::Parser::GetStatusElement(StatusElement::Parser * const apStatusElement) const +CHIP_ERROR AttributeStatusIB::Parser::GetStatusIB(StatusIB::Parser * const apStatusIB) const { CHIP_ERROR err = CHIP_NO_ERROR; chip::TLV::TLVReader reader; - err = mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_StatusElement), reader); + err = mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_StatusIB), reader); SuccessOrExit(err); VerifyOrExit(chip::TLV::kTLVType_Array == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); - err = apStatusElement->Init(reader); + err = apStatusIB->Init(reader); SuccessOrExit(err); exit: diff --git a/src/app/MessageDef/AttributeStatusElement.h b/src/app/MessageDef/AttributeStatusIB.h similarity index 77% rename from src/app/MessageDef/AttributeStatusElement.h rename to src/app/MessageDef/AttributeStatusIB.h index e3ff34fc1e9e82..05918d6df72f10 100644 --- a/src/app/MessageDef/AttributeStatusElement.h +++ b/src/app/MessageDef/AttributeStatusIB.h @@ -17,7 +17,7 @@ */ /** * @file - * This file defines AttributeStatusElement parser and builder in CHIP interaction model + * This file defines AttributeStatusIB parser and builder in CHIP interaction model * */ @@ -26,7 +26,7 @@ #include "AttributePath.h" #include "Builder.h" #include "Parser.h" -#include "StatusElement.h" +#include "StatusIB.h" #include #include @@ -37,18 +37,18 @@ namespace chip { namespace app { -namespace AttributeStatusElement { +namespace AttributeStatusIB { enum { kCsTag_AttributePath = 0, - kCsTag_StatusElement = 1, + kCsTag_StatusIB = 1, }; class Builder : public chip::app::Builder { public: /** - * @brief Initialize a AttributeStatusElement::Builder for writing into a TLV stream + * @brief Initialize a AttributeStatusIB::Builder for writing into a TLV stream * * @param [in] apWriter A pointer to TLVWriter * @@ -64,22 +64,22 @@ class Builder : public chip::app::Builder AttributePath::Builder & CreateAttributePathBuilder(); /** - * @brief Initialize a StatusElement::Builder for writing into the TLV stream + * @brief Initialize a StatusIB::Builder for writing into the TLV stream * - * @return A reference to StatusElement::Builder + * @return A reference to StatusIB::Builder */ - StatusElement::Builder & CreateStatusElementBuilder(); + StatusIB::Builder & CreateStatusIBBuilder(); /** - * @brief Mark the end of this AttributeStatusElement + * @brief Mark the end of this AttributeStatusIB * * @return A reference to *this */ - AttributeStatusElement::Builder & EndOfAttributeStatusElement(); + AttributeStatusIB::Builder & EndOfAttributeStatusIB(); private: AttributePath::Builder mAttributePathBuilder; - StatusElement::Builder mStatusElementBuilder; + StatusIB::Builder mStatusIBBuilder; }; class Parser : public chip::app::Parser @@ -88,7 +88,7 @@ class Parser : public chip::app::Parser /** * @brief Initialize the parser object with TLVReader * - * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this AttributeStatusElement + * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this AttributeStatusIB * * @return #CHIP_NO_ERROR on success */ @@ -122,17 +122,17 @@ class Parser : public chip::app::Parser CHIP_ERROR GetAttributePath(AttributePath::Parser * const apAttributePath) const; /** - * @brief Get a TLVReader for the StatusElement. Next() must be called before accessing them. + * @brief Get a TLVReader for the StatusIB. Next() must be called before accessing them. * - * @param [in] apStatusElement A pointer to apStatusElement + * @param [in] apStatusIB A pointer to apStatusIB * * @return #CHIP_NO_ERROR on success * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path * #CHIP_END_OF_TLV if there is no such element */ - CHIP_ERROR GetStatusElement(StatusElement::Parser * const apStatusElement) const; + CHIP_ERROR GetStatusIB(StatusIB::Parser * const apStatusIB) const; }; -}; // namespace AttributeStatusElement +}; // namespace AttributeStatusIB }; // namespace app }; // namespace chip diff --git a/src/app/MessageDef/AttributeStatusList.cpp b/src/app/MessageDef/AttributeStatusList.cpp index 63f1554ad793f8..c24641a408d25c 100644 --- a/src/app/MessageDef/AttributeStatusList.cpp +++ b/src/app/MessageDef/AttributeStatusList.cpp @@ -22,7 +22,7 @@ */ #include "AttributeStatusList.h" -#include "AttributeStatusElement.h" +#include "AttributeStatusIB.h" #include "MessageDefHelper.h" @@ -37,7 +37,7 @@ using namespace chip::TLV; namespace chip { namespace app { -AttributeStatusElement::Builder & AttributeStatusList::Builder::CreateAttributeStatusBuilder() +AttributeStatusIB::Builder & AttributeStatusList::Builder::CreateAttributeStatusBuilder() { // skip if error has already been set VerifyOrExit(CHIP_NO_ERROR == mError, mAttributeStatusBuilder.ResetError(mError)); @@ -73,7 +73,7 @@ CHIP_ERROR AttributeStatusList::Parser::CheckSchemaValidity() const VerifyOrExit(chip::TLV::kTLVType_Structure == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); { - AttributeStatusElement::Parser status; + AttributeStatusIB::Parser status; err = status.Init(reader); SuccessOrExit(err); diff --git a/src/app/MessageDef/AttributeStatusList.h b/src/app/MessageDef/AttributeStatusList.h index fa3b9e6041af74..6ee48d9851a00a 100644 --- a/src/app/MessageDef/AttributeStatusList.h +++ b/src/app/MessageDef/AttributeStatusList.h @@ -23,7 +23,7 @@ #pragma once -#include "AttributeStatusElement.h" +#include "AttributeStatusIB.h" #include "ListBuilder.h" #include "ListParser.h" @@ -45,7 +45,7 @@ class Builder : public ListBuilder * * @return A reference to AttributeStatus::Builder */ - AttributeStatusElement::Builder & CreateAttributeStatusBuilder(); + AttributeStatusIB::Builder & CreateAttributeStatusBuilder(); /** * @brief Mark the end of this AttributeStatusList @@ -55,7 +55,7 @@ class Builder : public ListBuilder AttributeStatusList::Builder & EndOfAttributeStatusList(); private: - AttributeStatusElement::Builder mAttributeStatusBuilder; + AttributeStatusIB::Builder mAttributeStatusBuilder; }; class Parser : public ListParser diff --git a/src/app/MessageDef/CommandDataElement.cpp b/src/app/MessageDef/CommandDataElement.cpp index b9de752ef9e7db..1e280e8b25d973 100644 --- a/src/app/MessageDef/CommandDataElement.cpp +++ b/src/app/MessageDef/CommandDataElement.cpp @@ -270,14 +270,14 @@ CHIP_ERROR CommandDataElement::Parser::CheckSchemaValidity() const err = ParseData(reader, 0); SuccessOrExit(err); break; - case kCsTag_StatusElement: + case kCsTag_StatusIB: // check if this tag has appeared before - VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_StatusElement)), err = CHIP_ERROR_INVALID_TLV_TAG); - TagPresenceMask |= (1 << kCsTag_StatusElement); + VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_StatusIB)), err = CHIP_ERROR_INVALID_TLV_TAG); + TagPresenceMask |= (1 << kCsTag_StatusIB); VerifyOrExit(chip::TLV::kTLVType_Array == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); { - StatusElement::Parser status; + StatusIB::Parser status; err = status.Init(reader); SuccessOrExit(err); @@ -301,13 +301,12 @@ CHIP_ERROR CommandDataElement::Parser::CheckSchemaValidity() const if (CHIP_END_OF_TLV == err) { // check for at most field: - const uint16_t CheckDataField = 1 << kCsTag_Data; - const uint16_t CheckStatusElementField = 1 << kCsTag_StatusElement; + const uint16_t CheckDataField = 1 << kCsTag_Data; + const uint16_t CheckStatusIBField = 1 << kCsTag_StatusIB; - if ((TagPresenceMask & CheckDataField) == CheckDataField && - (TagPresenceMask & CheckStatusElementField) == CheckStatusElementField) + if ((TagPresenceMask & CheckDataField) == CheckDataField && (TagPresenceMask & CheckStatusIBField) == CheckStatusIBField) { - // kCsTag_Data and kCsTag_StatusElement both exist + // kCsTag_Data and kCsTag_StatusIB both exist err = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; } else @@ -355,17 +354,17 @@ CHIP_ERROR CommandDataElement::Parser::GetData(chip::TLV::TLVReader * const apRe return err; } -CHIP_ERROR CommandDataElement::Parser::GetStatusElement(StatusElement::Parser * const apStatusElement) const +CHIP_ERROR CommandDataElement::Parser::GetStatusIB(StatusIB::Parser * const apStatusIB) const { CHIP_ERROR err = CHIP_NO_ERROR; chip::TLV::TLVReader reader; - err = mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_StatusElement), reader); + err = mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_StatusIB), reader); SuccessOrExit(err); VerifyOrExit(chip::TLV::kTLVType_Array == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); - err = apStatusElement->Init(reader); + err = apStatusIB->Init(reader); SuccessOrExit(err); exit: @@ -391,16 +390,16 @@ CommandPath::Builder & CommandDataElement::Builder::CreateCommandPathBuilder() return mCommandPathBuilder; } -StatusElement::Builder & CommandDataElement::Builder::CreateStatusElementBuilder() +StatusIB::Builder & CommandDataElement::Builder::CreateStatusIBBuilder() { // skip if error has already been set - VerifyOrExit(CHIP_NO_ERROR == mError, mStatusElementBuilder.ResetError(mError)); + VerifyOrExit(CHIP_NO_ERROR == mError, mStatusIBBuilder.ResetError(mError)); - mError = mStatusElementBuilder.Init(mpWriter, kCsTag_StatusElement); + mError = mStatusIBBuilder.Init(mpWriter, kCsTag_StatusIB); exit: - // on error, mStatusElementBuilder would be un-/partial initialized and cannot be used to write anything - return mStatusElementBuilder; + // on error, mStatusIBBuilder would be un-/partial initialized and cannot be used to write anything + return mStatusIBBuilder; } CommandDataElement::Builder & CommandDataElement::Builder::EndOfCommandDataElement() diff --git a/src/app/MessageDef/CommandDataElement.h b/src/app/MessageDef/CommandDataElement.h index bcc03268b9f658..b58929461b37e0 100644 --- a/src/app/MessageDef/CommandDataElement.h +++ b/src/app/MessageDef/CommandDataElement.h @@ -27,7 +27,7 @@ #include "CommandPath.h" #include "Parser.h" -#include "StatusElement.h" +#include "StatusIB.h" #include #include @@ -41,9 +41,9 @@ namespace app { namespace CommandDataElement { enum { - kCsTag_CommandPath = 0, - kCsTag_Data = 1, - kCsTag_StatusElement = 2, + kCsTag_CommandPath = 0, + kCsTag_Data = 1, + kCsTag_StatusIB = 2, }; class Parser : public chip::app::Parser @@ -97,15 +97,15 @@ class Parser : public chip::app::Parser CHIP_ERROR GetData(chip::TLV::TLVReader * const apReader) const; /** - * @brief Get a TLVReader for the StatusElement. Next() must be called before accessing them. + * @brief Get a TLVReader for the StatusIB. Next() must be called before accessing them. * - * @param [in] apStatusElement A pointer to apStatusElement + * @param [in] apStatusIB A pointer to apStatusIB * * @return #CHIP_NO_ERROR on success * # CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a structure * #CHIP_END_OF_TLV if there is no such element */ - CHIP_ERROR GetStatusElement(StatusElement::Parser * const apStatusElement) const; + CHIP_ERROR GetStatusIB(StatusIB::Parser * const apStatusIB) const; protected: // A recursively callable function to parse a data element and pretty-print it. @@ -132,11 +132,11 @@ class Builder : public chip::app::Builder CommandPath::Builder & CreateCommandPathBuilder(); /** - * @brief Initialize a StatusElement::Builder for writing into the TLV stream + * @brief Initialize a StatusIB::Builder for writing into the TLV stream * - * @return A reference to StatusElement::Builder + * @return A reference to StatusIB::Builder */ - StatusElement::Builder & CreateStatusElementBuilder(); + StatusIB::Builder & CreateStatusIBBuilder(); /** * @brief Mark the end of this CommandDataElement @@ -147,7 +147,7 @@ class Builder : public chip::app::Builder private: CommandPath::Builder mCommandPathBuilder; - StatusElement::Builder mStatusElementBuilder; + StatusIB::Builder mStatusIBBuilder; }; }; // namespace CommandDataElement }; // namespace app diff --git a/src/app/MessageDef/StatusElement.cpp b/src/app/MessageDef/StatusIB.cpp similarity index 83% rename from src/app/MessageDef/StatusElement.cpp rename to src/app/MessageDef/StatusIB.cpp index 3a955d76de7c21..c9ab5792649532 100644 --- a/src/app/MessageDef/StatusElement.cpp +++ b/src/app/MessageDef/StatusIB.cpp @@ -17,11 +17,11 @@ */ /** * @file - * This file defines StatusElement parser and builder in CHIP interaction model + * This file defines StatusIB parser and builder in CHIP interaction model * */ -#include "StatusElement.h" +#include "StatusIB.h" #include "MessageDefHelper.h" @@ -36,7 +36,7 @@ using namespace chip::TLV; namespace chip { namespace app { -CHIP_ERROR StatusElement::Parser::Init(const chip::TLV::TLVReader & aReader) +CHIP_ERROR StatusIB::Parser::Init(const chip::TLV::TLVReader & aReader) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -50,8 +50,8 @@ CHIP_ERROR StatusElement::Parser::Init(const chip::TLV::TLVReader & aReader) return err; } -CHIP_ERROR StatusElement::Parser::DecodeStatusElement(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode, - uint32_t * apProtocolId, uint16_t * apProtocolCode) const +CHIP_ERROR StatusIB::Parser::DecodeStatusIB(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode, uint32_t * apProtocolId, + uint16_t * apProtocolCode) const { CHIP_ERROR err = CHIP_NO_ERROR; chip::TLV::TLVReader lReader; @@ -83,13 +83,13 @@ CHIP_ERROR StatusElement::Parser::DecodeStatusElement(Protocols::SecureChannel:: } #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK -CHIP_ERROR StatusElement::Parser::CheckSchemaValidity() const +CHIP_ERROR StatusIB::Parser::CheckSchemaValidity() const { CHIP_ERROR err = CHIP_NO_ERROR; uint16_t TagPresenceMask = 0; chip::TLV::TLVReader reader; - PRETTY_PRINT("StatusElement ="); + PRETTY_PRINT("StatusIB ="); PRETTY_PRINT("{"); // make a copy of the reader @@ -147,7 +147,7 @@ CHIP_ERROR StatusElement::Parser::CheckSchemaValidity() const } else { - PRETTY_PRINT("\tExtra element in StatusElement"); + PRETTY_PRINT("\tExtra element in StatusIB"); } } @@ -177,18 +177,18 @@ CHIP_ERROR StatusElement::Parser::CheckSchemaValidity() const } #endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK -CHIP_ERROR StatusElement::Builder::Init(chip::TLV::TLVWriter * const apWriter) +CHIP_ERROR StatusIB::Builder::Init(chip::TLV::TLVWriter * const apWriter) { return ListBuilder::Init(apWriter); } -CHIP_ERROR StatusElement::Builder::Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse) +CHIP_ERROR StatusIB::Builder::Init(chip::TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse) { return ListBuilder::Init(apWriter, aContextTagToUse); } -StatusElement::Builder & StatusElement::Builder::EncodeStatusElement(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, - const uint32_t aProtocolId, const uint16_t aProtocolCode) +StatusIB::Builder & StatusIB::Builder::EncodeStatusIB(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, + const uint32_t aProtocolId, const uint16_t aProtocolCode) { Tag tag = chip::TLV::AnonymousTag; @@ -207,7 +207,7 @@ StatusElement::Builder & StatusElement::Builder::EncodeStatusElement(const Proto return *this; } -StatusElement::Builder & StatusElement::Builder::EndOfStatusElement() +StatusIB::Builder & StatusIB::Builder::EndOfStatusIB() { EndOfContainer(); return *this; diff --git a/src/app/MessageDef/StatusElement.h b/src/app/MessageDef/StatusIB.h similarity index 77% rename from src/app/MessageDef/StatusElement.h rename to src/app/MessageDef/StatusIB.h index d31ade7c5e869d..54a8d387592648 100644 --- a/src/app/MessageDef/StatusElement.h +++ b/src/app/MessageDef/StatusIB.h @@ -17,7 +17,7 @@ */ /** * @file - * This file defines StatusElement parser and builder in CHIP interaction model + * This file defines StatusIB parser and builder in CHIP interaction model * */ @@ -36,7 +36,7 @@ namespace chip { namespace app { -namespace StatusElement { +namespace StatusIB { enum { kCsTag_GeneralCode = 1, @@ -58,7 +58,7 @@ class Parser : public ListParser /** * @brief Initialize the parser object with TLVReader * - * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this StatusElement + * @param [in] aReader A pointer to a TLVReader, which should point to the beginning of this StatusIB * * @return #CHIP_NO_ERROR on success */ @@ -92,12 +92,12 @@ class Parser : public ListParser * element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong * type. */ - CHIP_ERROR DecodeStatusElement(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode, uint32_t * apProtocolId, - uint16_t * apProtocolCode) const; + CHIP_ERROR DecodeStatusIB(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode, uint32_t * apProtocolId, + uint16_t * apProtocolCode) const; - inline CHIP_ERROR DecodeStatusElement(Type & aStatusElement) + inline CHIP_ERROR DecodeStatusIB(Type & aStatusIB) { - return DecodeStatusElement(&aStatusElement.generalCode, &aStatusElement.protocolId, &aStatusElement.protocolCode); + return DecodeStatusIB(&aStatusIB.generalCode, &aStatusIB.protocolId, &aStatusIB.protocolCode); }; }; @@ -105,7 +105,7 @@ class Builder : public ListBuilder { public: /** - * @brief Initialize a StatusElement::Builder for writing into a TLV stream + * @brief Initialize a StatusIB::Builder for writing into a TLV stream * * @param [in] apWriter A pointer to TLVWriter * @@ -114,7 +114,7 @@ class Builder : public ListBuilder CHIP_ERROR Init(chip::TLV::TLVWriter * const apWriter); /** - * Init the StatusElement container with an particular context tag. + * Init the StatusIB container with an particular context tag. * Required to implement arrays of arrays, and to test ListBuilder. * * @param[in] apWriter Pointer to the TLVWriter that is encoding the message. @@ -135,22 +135,22 @@ class Builder : public ListBuilder * element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong * type. */ - StatusElement::Builder & EncodeStatusElement(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, - const uint32_t aProtocolId, const uint16_t aProtocolCode); + StatusIB::Builder & EncodeStatusIB(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, const uint32_t aProtocolId, + const uint16_t aProtocolCode); - inline StatusElement::Builder & EncodeStatusElement(const Type & aStatusElement) + inline StatusIB::Builder & EncodeStatusIB(const Type & aStatusIB) { - return EncodeStatusElement(aStatusElement.generalCode, aStatusElement.protocolId, aStatusElement.protocolCode); + return EncodeStatusIB(aStatusIB.generalCode, aStatusIB.protocolId, aStatusIB.protocolCode); } /** - * @brief Mark the end of this StatusElement + * @brief Mark the end of this StatusIB * * @return A reference to *this */ - StatusElement::Builder & EndOfStatusElement(); + StatusIB::Builder & EndOfStatusIB(); }; -}; // namespace StatusElement +}; // namespace StatusIB }; // namespace app }; // namespace chip diff --git a/src/app/WriteClient.cpp b/src/app/WriteClient.cpp index b4379efad33e25..145d0b6161e997 100644 --- a/src/app/WriteClient.cpp +++ b/src/app/WriteClient.cpp @@ -115,12 +115,12 @@ CHIP_ERROR WriteClient::ProcessWriteResponseMessage(System::PacketBufferHandle & VerifyOrExit(TLV::AnonymousTag == attributeStatusListReader.GetTag(), err = CHIP_ERROR_INVALID_TLV_TAG); VerifyOrExit(TLV::kTLVType_Structure == attributeStatusListReader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); - AttributeStatusElement::Parser element; + AttributeStatusIB::Parser element; err = element.Init(attributeStatusListReader); SuccessOrExit(err); - err = ProcessAttributeStatusElement(element); + err = ProcessAttributeStatusIB(element); SuccessOrExit(err); } @@ -325,18 +325,18 @@ void WriteClient::OnResponseTimeout(Messaging::ExchangeContext * apExchangeConte ShutdownInternal(); } -CHIP_ERROR WriteClient::ProcessAttributeStatusElement(AttributeStatusElement::Parser & aAttributeStatusElement) +CHIP_ERROR WriteClient::ProcessAttributeStatusIB(AttributeStatusIB::Parser & aAttributeStatusIB) { CHIP_ERROR err = CHIP_NO_ERROR; AttributePath::Parser attributePath; Protocols::SecureChannel::GeneralStatusCode generalCode = Protocols::SecureChannel::GeneralStatusCode::kSuccess; uint32_t protocolId = 0; uint16_t protocolCode = 0; - StatusElement::Parser statusElementParser; + StatusIB::Parser StatusIBParser; AttributePathParams attributePathParams; mAttributeStatusIndex++; - err = aAttributeStatusElement.GetAttributePath(&attributePath); + err = aAttributeStatusIB.GetAttributePath(&attributePath); SuccessOrExit(err); err = attributePath.GetNodeId(&(attributePathParams.mNodeId)); SuccessOrExit(err); @@ -364,10 +364,10 @@ CHIP_ERROR WriteClient::ProcessAttributeStatusElement(AttributeStatusElement::Pa attributePathParams.mFlags.Set(AttributePathParams::Flags::kListIndexValid); } - err = aAttributeStatusElement.GetStatusElement(&(statusElementParser)); + err = aAttributeStatusIB.GetStatusIB(&(StatusIBParser)); if (CHIP_NO_ERROR == err) { - err = statusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode); + err = StatusIBParser.DecodeStatusIB(&generalCode, &protocolId, &protocolCode); SuccessOrExit(err); if (mpDelegate != nullptr) { diff --git a/src/app/WriteClient.h b/src/app/WriteClient.h index 9a55151cb923e4..182f4c428b7653 100644 --- a/src/app/WriteClient.h +++ b/src/app/WriteClient.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -124,7 +124,7 @@ class WriteClient : public Messaging::ExchangeDelegate void MoveToState(const State aTargetState); CHIP_ERROR ProcessWriteResponseMessage(System::PacketBufferHandle && payload); - CHIP_ERROR ProcessAttributeStatusElement(AttributeStatusElement::Parser & aAttributeStatusElement); + CHIP_ERROR ProcessAttributeStatusIB(AttributeStatusIB::Parser & aAttributeStatusIB); CHIP_ERROR ConstructAttributePath(const AttributePathParams & aAttributePathParams, AttributeDataElement::Builder aAttributeDataElement); void ClearExistingExchangeContext(); diff --git a/src/app/WriteHandler.cpp b/src/app/WriteHandler.cpp index 21beac4cb71b8f..502546e6e89a37 100644 --- a/src/app/WriteHandler.cpp +++ b/src/app/WriteHandler.cpp @@ -203,9 +203,9 @@ CHIP_ERROR WriteHandler::ProcessWriteRequest(System::PacketBufferHandle && aPayl } CHIP_ERROR WriteHandler::ConstructAttributePath(const AttributePathParams & aAttributePathParams, - AttributeStatusElement::Builder aAttributeStatusElement) + AttributeStatusIB::Builder aAttributeStatusIB) { - AttributePath::Builder attributePath = aAttributeStatusElement.CreateAttributePathBuilder(); + AttributePath::Builder attributePath = aAttributeStatusIB.CreateAttributePathBuilder(); if (aAttributePathParams.mFlags.Has(AttributePathParams::Flags::kFieldIdValid)) { attributePath.FieldId(aAttributePathParams.mFieldId); @@ -229,23 +229,23 @@ CHIP_ERROR WriteHandler::AddAttributeStatusCode(const AttributePathParams & aAtt const Protocols::Id aProtocolId, const Protocols::InteractionModel::Status aStatus) { CHIP_ERROR err = CHIP_NO_ERROR; - StatusElement::Builder statusElementBuilder; - AttributeStatusElement::Builder attributeStatusElement = + StatusIB::Builder statusIBBuilder; + AttributeStatusIB::Builder attributeStatusIB = mWriteResponseBuilder.GetAttributeStatusListBuilder().CreateAttributeStatusBuilder(); - err = attributeStatusElement.GetError(); + err = attributeStatusIB.GetError(); SuccessOrExit(err); - err = ConstructAttributePath(aAttributePathParams, attributeStatusElement); + err = ConstructAttributePath(aAttributePathParams, attributeStatusIB); SuccessOrExit(err); - statusElementBuilder = attributeStatusElement.CreateStatusElementBuilder(); - statusElementBuilder.EncodeStatusElement(aGeneralCode, aProtocolId.ToFullyQualifiedSpecForm(), chip::to_underlying(aStatus)) - .EndOfStatusElement(); - err = statusElementBuilder.GetError(); + statusIBBuilder = attributeStatusIB.CreateStatusIBBuilder(); + statusIBBuilder.EncodeStatusIB(aGeneralCode, aProtocolId.ToFullyQualifiedSpecForm(), chip::to_underlying(aStatus)) + .EndOfStatusIB(); + err = statusIBBuilder.GetError(); SuccessOrExit(err); - attributeStatusElement.EndOfAttributeStatusElement(); - err = attributeStatusElement.GetError(); + attributeStatusIB.EndOfAttributeStatusIB(); + err = attributeStatusIB.GetError(); SuccessOrExit(err); MoveToState(State::AddAttributeStatusCode); diff --git a/src/app/WriteHandler.h b/src/app/WriteHandler.h index d0f4a7326b5a9c..1971a8d81c010a 100644 --- a/src/app/WriteHandler.h +++ b/src/app/WriteHandler.h @@ -88,7 +88,7 @@ class WriteHandler CHIP_ERROR FinalizeMessage(System::PacketBufferHandle & packet); CHIP_ERROR SendWriteResponse(); CHIP_ERROR ConstructAttributePath(const AttributePathParams & aAttributePathParams, - AttributeStatusElement::Builder aAttributeStatusElement); + AttributeStatusIB::Builder aAttributeStatusIB); void MoveToState(const State aTargetState); void ClearState(); diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index 178f8137d25f47..fea44ad33357eb 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -334,30 +334,29 @@ void ParseEventList(nlTestSuite * apSuite, chip::TLV::TLVReader & aReader) #endif } -void BuildStatusElement(nlTestSuite * apSuite, StatusElement::Builder & aStatusElementBuilder) +void BuildStatusIB(nlTestSuite * apSuite, StatusIB::Builder & aStatusIBBuilder) { CHIP_ERROR err = CHIP_NO_ERROR; - aStatusElementBuilder.EncodeStatusElement(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure, 2, 3) - .EndOfStatusElement(); - err = aStatusElementBuilder.GetError(); + aStatusIBBuilder.EncodeStatusIB(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure, 2, 3).EndOfStatusIB(); + err = aStatusIBBuilder.GetError(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); } -void ParseStatusElement(nlTestSuite * apSuite, StatusElement::Parser & aStatusElementParser) +void ParseStatusIB(nlTestSuite * apSuite, StatusIB::Parser & aStatusIBParser) { CHIP_ERROR err = CHIP_NO_ERROR; - StatusElement::Parser StatusElementParser; + StatusIB::Parser StatusIBParser; chip::Protocols::SecureChannel::GeneralStatusCode generalCode = chip::Protocols::SecureChannel::GeneralStatusCode::kFailure; uint32_t protocolId = 0; uint16_t protocolCode = 0; #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK - err = aStatusElementParser.CheckSchemaValidity(); + err = aStatusIBParser.CheckSchemaValidity(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); #endif - err = aStatusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode); + err = aStatusIBParser.DecodeStatusIB(&generalCode, &protocolId, &protocolCode); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR && static_cast(generalCode) == @@ -365,42 +364,42 @@ void ParseStatusElement(nlTestSuite * apSuite, StatusElement::Parser & aStatusEl protocolId == 2 && protocolCode == 3); } -void BuildAttributeStatusElement(nlTestSuite * apSuite, AttributeStatusElement::Builder & aAttributeStatusElementBuilder) +void BuildAttributeStatusIB(nlTestSuite * apSuite, AttributeStatusIB::Builder & aAttributeStatusIBBuilder) { - AttributePath::Builder attributePathBuilder = aAttributeStatusElementBuilder.CreateAttributePathBuilder(); + AttributePath::Builder attributePathBuilder = aAttributeStatusIBBuilder.CreateAttributePathBuilder(); NL_TEST_ASSERT(apSuite, attributePathBuilder.GetError() == CHIP_NO_ERROR); BuildAttributePath(apSuite, attributePathBuilder); - StatusElement::Builder statusElementBuilder = aAttributeStatusElementBuilder.CreateStatusElementBuilder(); - NL_TEST_ASSERT(apSuite, statusElementBuilder.GetError() == CHIP_NO_ERROR); - BuildStatusElement(apSuite, statusElementBuilder); + StatusIB::Builder statusIBBuilder = aAttributeStatusIBBuilder.CreateStatusIBBuilder(); + NL_TEST_ASSERT(apSuite, statusIBBuilder.GetError() == CHIP_NO_ERROR); + BuildStatusIB(apSuite, statusIBBuilder); - aAttributeStatusElementBuilder.EndOfAttributeStatusElement(); - NL_TEST_ASSERT(apSuite, aAttributeStatusElementBuilder.GetError() == CHIP_NO_ERROR); + aAttributeStatusIBBuilder.EndOfAttributeStatusIB(); + NL_TEST_ASSERT(apSuite, aAttributeStatusIBBuilder.GetError() == CHIP_NO_ERROR); } -void ParseAttributeStatusElement(nlTestSuite * apSuite, AttributeStatusElement::Parser & aAttributeStatusElementParser) +void ParseAttributeStatusIB(nlTestSuite * apSuite, AttributeStatusIB::Parser & aAttributeStatusIBParser) { CHIP_ERROR err = CHIP_NO_ERROR; AttributePath::Parser attributePathParser; - StatusElement::Parser statusElementParser; + StatusIB::Parser StatusIBParser; #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK - err = aAttributeStatusElementParser.CheckSchemaValidity(); + err = aAttributeStatusIBParser.CheckSchemaValidity(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); #endif - err = aAttributeStatusElementParser.GetAttributePath(&attributePathParser); + err = aAttributeStatusIBParser.GetAttributePath(&attributePathParser); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = aAttributeStatusElementParser.GetStatusElement(&statusElementParser); + err = aAttributeStatusIBParser.GetStatusIB(&StatusIBParser); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); } void BuildAttributeStatusList(nlTestSuite * apSuite, AttributeStatusList::Builder & aAttributeStatusListBuilder) { - AttributeStatusElement::Builder aAttributeStatusElementBuilder = aAttributeStatusListBuilder.CreateAttributeStatusBuilder(); + AttributeStatusIB::Builder aAttributeStatusIBBuilder = aAttributeStatusListBuilder.CreateAttributeStatusBuilder(); NL_TEST_ASSERT(apSuite, aAttributeStatusListBuilder.GetError() == CHIP_NO_ERROR); - BuildAttributeStatusElement(apSuite, aAttributeStatusElementBuilder); + BuildAttributeStatusIB(apSuite, aAttributeStatusIBBuilder); aAttributeStatusListBuilder.EndOfAttributeStatusList(); NL_TEST_ASSERT(apSuite, aAttributeStatusListBuilder.GetError() == CHIP_NO_ERROR); @@ -459,7 +458,7 @@ void ParseAttributeDataElement(nlTestSuite * apSuite, AttributeDataElement::Pars { CHIP_ERROR err = CHIP_NO_ERROR; AttributePath::Parser attributePathParser; - StatusElement::Parser statusElementParser; + StatusIB::Parser StatusIBParser; chip::DataVersion version = 0; bool moreClusterDataFlag = false; #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK @@ -604,9 +603,9 @@ void BuildCommandDataElementWithStatusCode(nlTestSuite * apSuite, CommandDataEle NL_TEST_ASSERT(apSuite, aCommandDataElementBuilder.GetError() == CHIP_NO_ERROR); BuildCommandPath(apSuite, commandPathBuilder); - StatusElement::Builder statusElementBuilder = aCommandDataElementBuilder.CreateStatusElementBuilder(); - NL_TEST_ASSERT(apSuite, statusElementBuilder.GetError() == CHIP_NO_ERROR); - BuildStatusElement(apSuite, statusElementBuilder); + StatusIB::Builder statusIBBuilder = aCommandDataElementBuilder.CreateStatusIBBuilder(); + NL_TEST_ASSERT(apSuite, statusIBBuilder.GetError() == CHIP_NO_ERROR); + BuildStatusIB(apSuite, statusIBBuilder); aCommandDataElementBuilder.EndOfCommandDataElement(); NL_TEST_ASSERT(apSuite, aCommandDataElementBuilder.GetError() == CHIP_NO_ERROR); @@ -616,7 +615,7 @@ void ParseCommandDataElementWithStatusCode(nlTestSuite * apSuite, CommandDataEle { CHIP_ERROR err = CHIP_NO_ERROR; CommandPath::Parser commandPathParser; - StatusElement::Parser statusElementParser; + StatusIB::Parser StatusIBParser; #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK err = aCommandDataElementParser.CheckSchemaValidity(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -624,7 +623,7 @@ void ParseCommandDataElementWithStatusCode(nlTestSuite * apSuite, CommandDataEle err = aCommandDataElementParser.GetCommandPath(&commandPathParser); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = aCommandDataElementParser.GetStatusElement(&statusElementParser); + err = aCommandDataElementParser.GetStatusIB(&StatusIBParser); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); } @@ -1210,16 +1209,16 @@ void EventListTest(nlTestSuite * apSuite, void * apContext) ParseEventList(apSuite, reader); } -void StatusElementTest(nlTestSuite * apSuite, void * apContext) +void StatusIBTest(nlTestSuite * apSuite, void * apContext) { CHIP_ERROR err = CHIP_NO_ERROR; - StatusElement::Builder statusElementBuilder; - StatusElement::Parser statusElementParser; + StatusIB::Builder statusIBBuilder; + StatusIB::Parser StatusIBParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); - statusElementBuilder.Init(&writer); - BuildStatusElement(apSuite, statusElementBuilder); + statusIBBuilder.Init(&writer); + BuildStatusIB(apSuite, statusIBBuilder); chip::System::PacketBufferHandle buf; err = writer.Finalize(&buf); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -1230,20 +1229,20 @@ void StatusElementTest(nlTestSuite * apSuite, void * apContext) err = reader.Next(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - statusElementParser.Init(reader); - ParseStatusElement(apSuite, statusElementParser); + StatusIBParser.Init(reader); + ParseStatusIB(apSuite, StatusIBParser); } -void AttributeStatusElementTest(nlTestSuite * apSuite, void * apContext) +void AttributeStatusIBTest(nlTestSuite * apSuite, void * apContext) { CHIP_ERROR err = CHIP_NO_ERROR; - AttributeStatusElement::Builder attributeStatusElementBuilder; - AttributeStatusElement::Parser attributeStatusElementParser; + AttributeStatusIB::Builder attributeStatusIBBuilder; + AttributeStatusIB::Parser attributeStatusIBParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); - attributeStatusElementBuilder.Init(&writer); - BuildAttributeStatusElement(apSuite, attributeStatusElementBuilder); + attributeStatusIBBuilder.Init(&writer); + BuildAttributeStatusIB(apSuite, attributeStatusIBBuilder); chip::System::PacketBufferHandle buf; err = writer.Finalize(&buf); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -1254,8 +1253,8 @@ void AttributeStatusElementTest(nlTestSuite * apSuite, void * apContext) err = reader.Next(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - attributeStatusElementParser.Init(reader); - ParseAttributeStatusElement(apSuite, attributeStatusElementParser); + attributeStatusIBParser.Init(reader); + ParseAttributeStatusIB(apSuite, attributeStatusIBParser); } void AttributeStatusListTest(nlTestSuite * apSuite, void * apContext) @@ -1634,8 +1633,8 @@ const nlTest sTests[] = NL_TEST_DEF("CommandPathTest", CommandPathTest), NL_TEST_DEF("EventDataElementTest", EventDataElementTest), NL_TEST_DEF("EventListTest", EventListTest), - NL_TEST_DEF("StatusElementTest", StatusElementTest), - NL_TEST_DEF("AttributeStatusElementTest", AttributeStatusElementTest), + NL_TEST_DEF("StatusIBTest", StatusIBTest), + NL_TEST_DEF("AttributeStatusIBTest", AttributeStatusIBTest), NL_TEST_DEF("AttributeStatusListTest", AttributeStatusListTest), NL_TEST_DEF("AttributeDataElementTest", AttributeDataElementTest), NL_TEST_DEF("AttributeDataListTest", AttributeDataListTest), diff --git a/src/app/tests/TestWriteInteraction.cpp b/src/app/tests/TestWriteInteraction.cpp index bb7bd03189c568..a45aa4c68b4480 100644 --- a/src/app/tests/TestWriteInteraction.cpp +++ b/src/app/tests/TestWriteInteraction.cpp @@ -172,24 +172,23 @@ void TestWriteInteraction::GenerateWriteResponse(nlTestSuite * apSuite, void * a NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); AttributeStatusList::Builder attributeStatusListBuilder = writeResponseBuilder.CreateAttributeStatusListBuilder(); NL_TEST_ASSERT(apSuite, attributeStatusListBuilder.GetError() == CHIP_NO_ERROR); - AttributeStatusElement::Builder attributeStatusElementBuilder = attributeStatusListBuilder.CreateAttributeStatusBuilder(); - NL_TEST_ASSERT(apSuite, attributeStatusElementBuilder.GetError() == CHIP_NO_ERROR); + AttributeStatusIB::Builder attributeStatusIBBuilder = attributeStatusListBuilder.CreateAttributeStatusBuilder(); + NL_TEST_ASSERT(apSuite, attributeStatusIBBuilder.GetError() == CHIP_NO_ERROR); - AttributePath::Builder attributePathBuilder = attributeStatusElementBuilder.CreateAttributePathBuilder(); + AttributePath::Builder attributePathBuilder = attributeStatusIBBuilder.CreateAttributePathBuilder(); NL_TEST_ASSERT(apSuite, attributePathBuilder.GetError() == CHIP_NO_ERROR); attributePathBuilder.NodeId(1).EndpointId(2).ClusterId(3).FieldId(4).ListIndex(5).EndOfAttributePath(); err = attributePathBuilder.GetError(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - StatusElement::Builder statusElementBuilder = attributeStatusElementBuilder.CreateStatusElementBuilder(); - NL_TEST_ASSERT(apSuite, statusElementBuilder.GetError() == CHIP_NO_ERROR); - statusElementBuilder.EncodeStatusElement(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure, 2, 3) - .EndOfStatusElement(); - err = statusElementBuilder.GetError(); + StatusIB::Builder statusIBBuilder = attributeStatusIBBuilder.CreateStatusIBBuilder(); + NL_TEST_ASSERT(apSuite, statusIBBuilder.GetError() == CHIP_NO_ERROR); + statusIBBuilder.EncodeStatusIB(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure, 2, 3).EndOfStatusIB(); + err = statusIBBuilder.GetError(); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - attributeStatusElementBuilder.EndOfAttributeStatusElement(); - NL_TEST_ASSERT(apSuite, attributeStatusElementBuilder.GetError() == CHIP_NO_ERROR); + attributeStatusIBBuilder.EndOfAttributeStatusIB(); + NL_TEST_ASSERT(apSuite, attributeStatusIBBuilder.GetError() == CHIP_NO_ERROR); attributeStatusListBuilder.EndOfAttributeStatusList(); NL_TEST_ASSERT(apSuite, attributeStatusListBuilder.GetError() == CHIP_NO_ERROR);