Skip to content

Commit 0956d9e

Browse files
authored
Changes to CommandDataIB to reflect 1.3 spec (project-chip#30522)
* Changes to CommandDataIB to reflect 1.3 spec * Fix CI
1 parent edbd2b6 commit 0956d9e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/app/MessageDef/CommandDataIB.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ CHIP_ERROR CommandDataIB::Parser::PrettyPrint() const
6464
ReturnErrorOnFailure(CheckIMPayload(reader, 0, "CommandFields"));
6565
PRETTY_PRINT_DECDEPTH();
6666
break;
67+
case to_underlying(Tag::kRef):
68+
VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
69+
{
70+
uint16_t reference;
71+
ReturnErrorOnFailure(reader.Get(reference));
72+
PRETTY_PRINT("\tRef = 0x%x,", reference);
73+
}
74+
break;
6775
default:
6876
PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
6977
break;
@@ -96,12 +104,22 @@ CHIP_ERROR CommandDataIB::Parser::GetFields(TLV::TLVReader * const apReader) con
96104
return CHIP_NO_ERROR;
97105
}
98106

107+
CHIP_ERROR CommandDataIB::Parser::GetRef(uint16_t * const apRef) const
108+
{
109+
return GetUnsignedInteger(to_underlying(Tag::kRef), apRef);
110+
}
111+
99112
CommandPathIB::Builder & CommandDataIB::Builder::CreatePath()
100113
{
101114
mError = mPath.Init(mpWriter, to_underlying(Tag::kPath));
102115
return mPath;
103116
}
104117

118+
CHIP_ERROR CommandDataIB::Builder::Ref(const uint16_t aRef)
119+
{
120+
return mpWriter->Put(TLV::ContextTag(Tag::kRef), aRef);
121+
}
122+
105123
CHIP_ERROR CommandDataIB::Builder::EndOfCommandDataIB()
106124
{
107125
EndOfContainer();

src/app/MessageDef/CommandDataIB.h

+22
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum class Tag : uint8_t
3737
{
3838
kPath = 0,
3939
kFields = 1,
40+
kRef = 2,
4041
};
4142

4243
class Parser : public StructParser
@@ -66,6 +67,17 @@ class Parser : public StructParser
6667
* #CHIP_END_OF_TLV if there is no such element
6768
*/
6869
CHIP_ERROR GetFields(TLV::TLVReader * const apReader) const;
70+
71+
/**
72+
* @brief Get the provided command reference associated with the CommandData
73+
*
74+
* @param [in] apRef A pointer to apRef
75+
*
76+
* @return #CHIP_NO_ERROR on success
77+
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
78+
* #CHIP_END_OF_TLV if there is no such element
79+
*/
80+
CHIP_ERROR GetRef(uint16_t * const apRef) const;
6981
};
7082

7183
class Builder : public StructBuilder
@@ -78,6 +90,16 @@ class Builder : public StructBuilder
7890
*/
7991
CommandPathIB::Builder & CreatePath();
8092

93+
/**
94+
* @brief Inject Command Ref into the TLV stream.
95+
*
96+
* @param [in] aRef refer to the CommandRef to set in CommandDataIB.
97+
*
98+
* TODO What are some more errors
99+
* @return #CHIP_NO_ERROR on success
100+
*/
101+
CHIP_ERROR Ref(const uint16_t aRef);
102+
81103
/**
82104
* @brief Mark the end of this CommandDataIB
83105
*

0 commit comments

Comments
 (0)