File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,14 @@ CHIP_ERROR CommandDataIB::Parser::PrettyPrint() const
64
64
ReturnErrorOnFailure (CheckIMPayload (reader, 0 , " CommandFields" ));
65
65
PRETTY_PRINT_DECDEPTH ();
66
66
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 (" \t Ref = 0x%x," , reference);
73
+ }
74
+ break ;
67
75
default :
68
76
PRETTY_PRINT (" Unknown tag num %" PRIu32, tagNum);
69
77
break ;
@@ -96,12 +104,22 @@ CHIP_ERROR CommandDataIB::Parser::GetFields(TLV::TLVReader * const apReader) con
96
104
return CHIP_NO_ERROR;
97
105
}
98
106
107
+ CHIP_ERROR CommandDataIB::Parser::GetRef (uint16_t * const apRef) const
108
+ {
109
+ return GetUnsignedInteger (to_underlying (Tag::kRef ), apRef);
110
+ }
111
+
99
112
CommandPathIB::Builder & CommandDataIB::Builder::CreatePath ()
100
113
{
101
114
mError = mPath .Init (mpWriter, to_underlying (Tag::kPath ));
102
115
return mPath ;
103
116
}
104
117
118
+ CHIP_ERROR CommandDataIB::Builder::Ref (const uint16_t aRef)
119
+ {
120
+ return mpWriter->Put (TLV::ContextTag (Tag::kRef ), aRef);
121
+ }
122
+
105
123
CHIP_ERROR CommandDataIB::Builder::EndOfCommandDataIB ()
106
124
{
107
125
EndOfContainer ();
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ enum class Tag : uint8_t
37
37
{
38
38
kPath = 0 ,
39
39
kFields = 1 ,
40
+ kRef = 2 ,
40
41
};
41
42
42
43
class Parser : public StructParser
@@ -66,6 +67,17 @@ class Parser : public StructParser
66
67
* #CHIP_END_OF_TLV if there is no such element
67
68
*/
68
69
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 ;
69
81
};
70
82
71
83
class Builder : public StructBuilder
@@ -78,6 +90,16 @@ class Builder : public StructBuilder
78
90
*/
79
91
CommandPathIB::Builder & CreatePath ();
80
92
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
+
81
103
/* *
82
104
* @brief Mark the end of this CommandDataIB
83
105
*
You can’t perform that action at this time.
0 commit comments