Skip to content

Commit

Permalink
Changes to CommandStatusIB to reflect 1.3 spec (project-chip#30595)
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson authored Nov 22, 2023
1 parent 41971ba commit 4e2d489
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/MessageDef/CommandDataIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Parser : public StructParser
/**
* @brief Get the provided command reference associated with the CommandData
*
* @param [in] apRef A pointer to apRef
* @param [out] apRef A pointer to apRef
*
* @return #CHIP_NO_ERROR on success
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
Expand Down
18 changes: 18 additions & 0 deletions src/app/MessageDef/CommandStatusIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ CHIP_ERROR CommandStatusIB::Parser::PrettyPrint() const
PRETTY_PRINT_DECDEPTH();
}
break;
case to_underlying(Tag::kRef):
VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
{
uint16_t reference;
ReturnErrorOnFailure(reader.Get(reference));
PRETTY_PRINT("\tRef = 0x%x,", reference);
}
break;
default:
PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
break;
Expand Down Expand Up @@ -108,6 +116,11 @@ CHIP_ERROR CommandStatusIB::Parser::GetErrorStatus(StatusIB::Parser * const apEr
return apErrorStatus->Init(reader);
}

CHIP_ERROR CommandStatusIB::Parser::GetRef(uint16_t * const apRef) const
{
return GetUnsignedInteger(to_underlying(Tag::kRef), apRef);
}

CommandPathIB::Builder & CommandStatusIB::Builder::CreatePath()
{
if (mError == CHIP_NO_ERROR)
Expand All @@ -126,6 +139,11 @@ StatusIB::Builder & CommandStatusIB::Builder::CreateErrorStatus()
return mErrorStatus;
}

CHIP_ERROR CommandStatusIB::Builder::Ref(const uint16_t aRef)
{
return mpWriter->Put(TLV::ContextTag(Tag::kRef), aRef);
}

CHIP_ERROR CommandStatusIB::Builder::EndOfCommandStatusIB()
{
EndOfContainer();
Expand Down
21 changes: 21 additions & 0 deletions src/app/MessageDef/CommandStatusIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum class Tag : uint8_t
{
kPath = 0,
kErrorStatus = 1,
kRef = 2,
};

class Parser : public StructParser
Expand Down Expand Up @@ -67,6 +68,17 @@ class Parser : public StructParser
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetErrorStatus(StatusIB::Parser * const apErrorStatus) const;

/**
* @brief Get the provided command reference associated with the CommandStatus
*
* @param [out] apRef A pointer to apRef
*
* @return #CHIP_NO_ERROR on success
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetRef(uint16_t * const apRef) const;
};

class Builder : public StructBuilder
Expand All @@ -86,6 +98,15 @@ class Builder : public StructBuilder
*/
StatusIB::Builder & CreateErrorStatus();

/**
* @brief Inject Command Ref into the TLV stream.
*
* @param [in] aRef refer to the CommandRef to set in CommandStatusIB.
*
* @return #CHIP_NO_ERROR on success
*/
CHIP_ERROR Ref(const uint16_t aRef);

/**
* @brief Mark the end of this CommandStatusIB
*
Expand Down

0 comments on commit 4e2d489

Please sign in to comment.