Skip to content

Commit

Permalink
Rename StatusElement to StatusIB (#10395)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google authored and pull[bot] committed Nov 5, 2021
1 parent 496ac92 commit 3260993
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 198 deletions.
8 changes: 4 additions & 4 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 6 additions & 7 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */);
Expand Down
18 changes: 9 additions & 9 deletions src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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<Protocols::InteractionModel::Status>(statusElement.protocolCode),
mpCallback->OnError(this, static_cast<Protocols::InteractionModel::Status>(statusIB.protocolCode),
CHIP_ERROR_IM_STATUS_CODE_RECEIVED);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include <app/Command.h>
#include <app/MessageDef/CommandPath.h>
#include <app/MessageDef/StatusElement.h>
#include <app/MessageDef/StatusIB.h>

#define COMMON_STATUS_SUCCESS 0

Expand All @@ -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) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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));
Expand All @@ -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;

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
*/

Expand All @@ -26,7 +26,7 @@
#include "AttributePath.h"
#include "Builder.h"
#include "Parser.h"
#include "StatusElement.h"
#include "StatusIB.h"

#include <app/AppBuildConfig.h>
#include <app/util/basic-types.h>
Expand All @@ -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
*
Expand All @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/app/MessageDef/AttributeStatusList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

#include "AttributeStatusList.h"
#include "AttributeStatusElement.h"
#include "AttributeStatusIB.h"

#include "MessageDefHelper.h"

Expand All @@ -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));
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/app/MessageDef/AttributeStatusList.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#pragma once

#include "AttributeStatusElement.h"
#include "AttributeStatusIB.h"
#include "ListBuilder.h"
#include "ListParser.h"

Expand All @@ -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
Expand All @@ -55,7 +55,7 @@ class Builder : public ListBuilder
AttributeStatusList::Builder & EndOfAttributeStatusList();

private:
AttributeStatusElement::Builder mAttributeStatusBuilder;
AttributeStatusIB::Builder mAttributeStatusBuilder;
};

class Parser : public ListParser
Expand Down
Loading

0 comments on commit 3260993

Please sign in to comment.