From aa1f11c8ca4ac1e3a5e20b0f8b9b9fae77c32a90 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 12 Oct 2020 17:44:58 -0400 Subject: [PATCH] Use enum class for TLVElementType and TLVTagControl. (#3157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use enum class for TLVElementType and TLVTagControl. This makes it easy to give them as specific size spec, which will prevent issues with people adding out-of-range values and simplify -Wconversion work. * Check if the result of EncodeCommand is successful before trying to send the command (#3151) * Remove verbose code comments (#3187) Some devices are configured to act as Thread router instead of sleepy-end device. This PR removes these incorrect or verbose comments. * Remove {#mainpage} from the main README.md file (#3190) * Remove Makefiles introduced by #3099 (#3191) * [nRF Connect] README updates on Docker for MacOS and NCS version (#3175) * [nRF Connect] README updates on Docker for MacOS and NCS version * Restyled by prettier-markdown * Rephrase a sentence Co-authored-by: Restyled.io * Modify the generated files for example lighting and lock apps to include server init callbacks. (#3180) This allows the app to implement emberAfPluginOnOffClusterServerPostInitCallback to sync up the data model state with the state of the actual device when the data model initializes. * Use pragma once in more places (#3182) * Add a lot of pragma once changes. Now scripted! * update pragma once in setup payload * More pragma once * Pragma once within platform and more * pragma once in the crypto layer * pragma once in examples * Fix by restyle-diff * [android] Use ATT Write Request instead of ATT Write Command (#3161) Co-authored-by: Vivien Nicolas Co-authored-by: Yakun Xu Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: Restyled.io Co-authored-by: Andrei Litvin Co-authored-by: Łukasz Duda --- src/lib/core/CHIPTLV.h | 10 +++ src/lib/core/CHIPTLVData.hpp | 64 ++++++++--------- src/lib/core/CHIPTLVDebug.cpp | 16 ++--- src/lib/core/CHIPTLVReader.cpp | 58 +++++++-------- src/lib/core/CHIPTLVTags.h | 28 +++++--- src/lib/core/CHIPTLVTypes.h | 111 +++++++++++++++++------------ src/lib/core/CHIPTLVUpdater.cpp | 8 ++- src/lib/core/CHIPTLVWriter.cpp | 64 ++++++++--------- src/lib/core/tests/TestCHIPTLV.cpp | 2 +- 9 files changed, 202 insertions(+), 159 deletions(-) diff --git a/src/lib/core/CHIPTLV.h b/src/lib/core/CHIPTLV.h index 0361b88769411b..cdde54cc2d2e87 100644 --- a/src/lib/core/CHIPTLV.h +++ b/src/lib/core/CHIPTLV.h @@ -57,6 +57,16 @@ class PacketBuffer; namespace chip { namespace TLV { +inline uint8_t operator|(TLVElementType lhs, TLVTagControl rhs) +{ + return static_cast(lhs) | static_cast(rhs); +} + +inline uint8_t operator|(TLVTagControl lhs, TLVElementType rhs) +{ + return static_cast(lhs) | static_cast(rhs); +} + using chip::System::PacketBuffer; enum diff --git a/src/lib/core/CHIPTLVData.hpp b/src/lib/core/CHIPTLVData.hpp index c8a1e037460197..b3a3532f7f6499 100644 --- a/src/lib/core/CHIPTLVData.hpp +++ b/src/lib/core/CHIPTLVData.hpp @@ -104,41 +104,41 @@ /* * @brief Specifies an anonymous TLV element, which doesn't have any tag */ -#define CHIP_TLV_TAG_ANONYMOUS chip::TLV::kTLVTagControl_Anonymous +#define CHIP_TLV_TAG_ANONYMOUS chip::TLV::TLVTagControl::Anonymous /* * @brief Specifies a TLV element with a context-specific tag * @param Tag The context-specific tag for this TLV element. Would be truncated to 8 bits. */ -#define CHIP_TLV_TAG_CONTEXT_SPECIFIC(Tag) chip::TLV::kTLVTagControl_ContextSpecific, CHIP_TLV_Serialize8(Tag) +#define CHIP_TLV_TAG_CONTEXT_SPECIFIC(Tag) chip::TLV::TLVTagControl::ContextSpecific, CHIP_TLV_Serialize8(Tag) /* * @brief Specifies a TLV element with a Common Profile tag * @param Tag The tag for this TLV element, defined under Common Profile. * Would be truncated to 16 bites. */ -#define CHIP_TLV_TAG_COMMON_PROFILE_2Bytes(Tag) chip::TLV::kTLVTagControl_CommonProfile_2Bytes, CHIP_TLV_Serialize16(Tag) +#define CHIP_TLV_TAG_COMMON_PROFILE_2Bytes(Tag) chip::TLV::TLVTagControl::CommonProfile_2Bytes, CHIP_TLV_Serialize16(Tag) /* * @brief Specifies a TLV element with a Common Profile tag * @param Tag The tag for this TLV element, defined under Common Profile. * Would be truncated to 32 bites. */ -#define CHIP_TLV_TAG_COMMON_PROFILE_4Bytes(Tag) chip::TLV::kTLVTagControl_CommonProfile_4Bytes, CHIP_TLV_Serialize32(Tag) +#define CHIP_TLV_TAG_COMMON_PROFILE_4Bytes(Tag) chip::TLV::TLVTagControl::CommonProfile_4Bytes, CHIP_TLV_Serialize32(Tag) /* * @brief Specifies a TLV element with an Implicit Profile tag * @param Tag The tag for this TLV element, defined under the current implicit profile. * Would be truncated to 16 bits. */ -#define CHIP_TLV_TAG_IMPLICIT_PROFILE_2Bytes(Tag) chip::TLV::kTLVTagControl_ImplicitProfile_2Bytes, CHIP_TLV_Serialize16(Tag) +#define CHIP_TLV_TAG_IMPLICIT_PROFILE_2Bytes(Tag) chip::TLV::TLVTagControl::ImplicitProfile_2Bytes, CHIP_TLV_Serialize16(Tag) /* * @brief Specifies a TLV element with an Implicit Profile tag * @param Tag The tag for this TLV element, defined under the current implicit profile. * Would be truncated to 32 bits. */ -#define CHIP_TLV_TAG_IMPLICIT_PROFILE_4Bytes(Tag) chip::TLV::kTLVTagControl_ImplicitProfile_4Bytes, CHIP_TLV_Serialize32(Tag) +#define CHIP_TLV_TAG_IMPLICIT_PROFILE_4Bytes(Tag) chip::TLV::TLVTagControl::ImplicitProfile_4Bytes, CHIP_TLV_Serialize32(Tag) /* * @brief Specifies a TLV element with a Fully Qualified tag @@ -147,7 +147,7 @@ * Would be truncated to 16 bits. */ #define CHIP_TLV_TAG_FULLY_QUALIFIED_6Bytes(ProfileId, Tag) \ - chip::TLV::kTLVTagControl_FullyQualified_6Bytes, CHIP_TLV_Serialize16(ProfileId >> 16), CHIP_TLV_Serialize16(ProfileId), \ + chip::TLV::TLVTagControl::FullyQualified_6Bytes, CHIP_TLV_Serialize16(ProfileId >> 16), CHIP_TLV_Serialize16(ProfileId), \ CHIP_TLV_Serialize16(Tag) /* @@ -157,32 +157,32 @@ * Would be truncated to 32 bits. */ #define CHIP_TLV_TAG_FULLY_QUALIFIED_8Bytes(ProfileId, Tag) \ - chip::TLV::kTLVTagControl_FullyQualified_8Bytes, CHIP_TLV_Serialize16(ProfileId >> 16), CHIP_TLV_Serialize16(ProfileId), \ + chip::TLV::TLVTagControl::FullyQualified_8Bytes, CHIP_TLV_Serialize16(ProfileId >> 16), CHIP_TLV_Serialize16(ProfileId), \ CHIP_TLV_Serialize32(Tag) /* * @brief Specifies a NULL TLV element, which has just the tag but no value * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ */ -#define CHIP_TLV_NULL(TagSpec) chip::TLV::kTLVElementType_Null | TagSpec +#define CHIP_TLV_NULL(TagSpec) chip::TLV::TLVElementType::Null | TagSpec /* * @brief Specifies a Structure TLV element, marking the beginning of a Structure * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ */ -#define CHIP_TLV_STRUCTURE(TagSpec) chip::TLV::kTLVElementType_Structure | TagSpec +#define CHIP_TLV_STRUCTURE(TagSpec) chip::TLV::TLVElementType::Structure | TagSpec /* * @brief Specifies a Array TLV element, marking the beginning of an Array * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ */ -#define CHIP_TLV_ARRAY(TagSpec) chip::TLV::kTLVElementType_Array | TagSpec +#define CHIP_TLV_ARRAY(TagSpec) chip::TLV::TLVElementType::Array | TagSpec /* * @brief Specifies a Path TLV element, marking the beginning of a Path * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ */ -#define CHIP_TLV_PATH(TagSpec) chip::TLV::kTLVElementType_Path | TagSpec +#define CHIP_TLV_PATH(TagSpec) chip::TLV::TLVElementType::Path | TagSpec /* * @brief Specifies a Boolean TLV element, which can be either true or false @@ -190,7 +190,7 @@ * @param Value Should be either true or false */ #define CHIP_TLV_BOOL(TagSpec, Value) \ - ((Value) ? chip::TLV::kTLVElementType_BooleanTrue : chip::TLV::kTLVElementType_BooleanFalse) | TagSpec + ((Value) ? chip::TLV::TLVElementType::BooleanTrue : chip::TLV::TLVElementType::BooleanFalse) | TagSpec /** * @brief @@ -200,7 +200,7 @@ * * @param ... Bytes representing the floating point value to serialize */ -#define CHIP_TLV_FLOAT32(TagSpec, ...) chip::TLV::kTLVElementType_FloatingPointNumber32 | TagSpec, ##__VA_ARGS__ +#define CHIP_TLV_FLOAT32(TagSpec, ...) chip::TLV::TLVElementType::FloatingPointNumber32 | TagSpec, ##__VA_ARGS__ /** * @brief @@ -210,12 +210,12 @@ * * @param ... Bytes representing the floating point value to serialize */ -#define CHIP_TLV_FLOAT64(TagSpec, ...) chip::TLV::kTLVElementType_FloatingPointNumber64 | TagSpec, ##__VA_ARGS__ +#define CHIP_TLV_FLOAT64(TagSpec, ...) chip::TLV::TLVElementType::FloatingPointNumber64 | TagSpec, ##__VA_ARGS__ /* * @brief Specifies a EndOfContainer TLV element, marking the end of a Structure, Array, or Path */ -#define CHIP_TLV_END_OF_CONTAINER chip::TLV::kTLVElementType_EndOfContainer | chip::TLV::kTLVTagControl_Anonymous +#define CHIP_TLV_END_OF_CONTAINER chip::TLV::TLVElementType::EndOfContainer | chip::TLV::TLVTagControl::Anonymous /* * @brief Specifies a EndOfContainer TLV element, marking the end of a Structure, Array, or Path @@ -237,56 +237,56 @@ * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to int8_t, and then serialized */ -#define CHIP_TLV_INT8(TagSpec, Value) chip::TLV::kTLVElementType_Int8 | TagSpec, CHIP_TLV_Serialize8(int8_t(Value)) +#define CHIP_TLV_INT8(TagSpec, Value) chip::TLV::TLVElementType::Int8 | TagSpec, CHIP_TLV_Serialize8(int8_t(Value)) /* * @brief Specifies a 16-bit Signed Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to int16_t, and then serialized */ -#define CHIP_TLV_INT16(TagSpec, Value) chip::TLV::kTLVElementType_Int16 | TagSpec, CHIP_TLV_Serialize16(int16_t(Value)) +#define CHIP_TLV_INT16(TagSpec, Value) chip::TLV::TLVElementType::Int16 | TagSpec, CHIP_TLV_Serialize16(int16_t(Value)) /* * @brief Specifies a 32-bit Signed Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to int32_t, and then serialized */ -#define CHIP_TLV_INT32(TagSpec, Value) chip::TLV::kTLVElementType_Int32 | TagSpec, CHIP_TLV_Serialize32(int32_t(Value)) +#define CHIP_TLV_INT32(TagSpec, Value) chip::TLV::TLVElementType::Int32 | TagSpec, CHIP_TLV_Serialize32(int32_t(Value)) /* * @brief Specifies a 32-bit Signed Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to int64_t, and then serialized */ -#define CHIP_TLV_INT64(TagSpec, Value) chip::TLV::kTLVElementType_Int64 | TagSpec, CHIP_TLV_Serialize64(int64_t(Value)) +#define CHIP_TLV_INT64(TagSpec, Value) chip::TLV::TLVElementType::Int64 | TagSpec, CHIP_TLV_Serialize64(int64_t(Value)) /* * @brief Specifies an 8-bit Unsigned Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to (uint8_t), and then serialized */ -#define CHIP_TLV_UINT8(TagSpec, Value) chip::TLV::kTLVElementType_UInt8 | TagSpec, CHIP_TLV_Serialize8((uint8_t)(Value)) +#define CHIP_TLV_UINT8(TagSpec, Value) chip::TLV::TLVElementType::UInt8 | TagSpec, CHIP_TLV_Serialize8((uint8_t)(Value)) /* * @brief Specifies a 16-bit Unsigned Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to (uint16_t), and then serialized */ -#define CHIP_TLV_UINT16(TagSpec, Value) chip::TLV::kTLVElementType_UInt16 | TagSpec, CHIP_TLV_Serialize16((uint16_t)(Value)) +#define CHIP_TLV_UINT16(TagSpec, Value) chip::TLV::TLVElementType::UInt16 | TagSpec, CHIP_TLV_Serialize16((uint16_t)(Value)) /* * @brief Specifies a 32-bit Unsigned Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to (uint32_t), and then serialized */ -#define CHIP_TLV_UINT32(TagSpec, Value) chip::TLV::kTLVElementType_UInt32 | TagSpec, CHIP_TLV_Serialize32((uint32_t)(Value)) +#define CHIP_TLV_UINT32(TagSpec, Value) chip::TLV::TLVElementType::UInt32 | TagSpec, CHIP_TLV_Serialize32((uint32_t)(Value)) /* * @brief Specifies a 64-bit Unsigned Integer TLV element * @param TagSpec Should be filled with macros begin with CHIP_TLV_TAG_ * @param Value Would be first converted to (uint64_t), and then serialized */ -#define CHIP_TLV_UINT64(TagSpec, Value) chip::TLV::kTLVElementType_UInt64 | TagSpec, CHIP_TLV_Serialize64((uint64_t)(Value)) +#define CHIP_TLV_UINT64(TagSpec, Value) chip::TLV::TLVElementType::UInt64 | TagSpec, CHIP_TLV_Serialize64((uint64_t)(Value)) /** * @brief @@ -299,7 +299,7 @@ * @param ... Bytes representing the string characters to serialize */ #define CHIP_TLV_UTF8_STRING_1ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_UTF8String_1ByteLength | TagSpec, CHIP_TLV_Serialize8((uint8_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::UTF8String_1ByteLength | TagSpec, CHIP_TLV_Serialize8((uint8_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -312,7 +312,7 @@ * @param ... Bytes representing the string characters to serialize */ #define CHIP_TLV_UTF8_STRING_2ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_UTF8String_2ByteLength | TagSpec, CHIP_TLV_Serialize16((uint16_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::UTF8String_2ByteLength | TagSpec, CHIP_TLV_Serialize16((uint16_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -325,7 +325,7 @@ * @param ... Bytes representing the string characters to serialize */ #define CHIP_TLV_UTF8_STRING_4ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_UTF8String_4ByteLength | TagSpec, CHIP_TLV_Serialize32((uint32_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::UTF8String_4ByteLength | TagSpec, CHIP_TLV_Serialize32((uint32_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -338,7 +338,7 @@ * @param ... Bytes representing the string characters to serialize */ #define CHIP_TLV_UTF8_STRING_8ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_UTF8String_8ByteLength | TagSpec, CHIP_TLV_Serialize64((uint64_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::UTF8String_8ByteLength | TagSpec, CHIP_TLV_Serialize64((uint64_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -351,7 +351,7 @@ * @param ... Bytes to serialize */ #define CHIP_TLV_BYTE_STRING_1ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_ByteString_1ByteLength | TagSpec, CHIP_TLV_Serialize8((uint8_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::ByteString_1ByteLength | TagSpec, CHIP_TLV_Serialize8((uint8_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -364,7 +364,7 @@ * @param ... Bytes to serialize */ #define CHIP_TLV_BYTE_STRING_2ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_ByteString_2ByteLength | TagSpec, CHIP_TLV_Serialize16((uint16_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::ByteString_2ByteLength | TagSpec, CHIP_TLV_Serialize16((uint16_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -377,7 +377,7 @@ * @param ... Bytes to serialize */ #define CHIP_TLV_BYTE_STRING_4ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_ByteString_4ByteLength | TagSpec, CHIP_TLV_Serialize32((uint32_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::ByteString_4ByteLength | TagSpec, CHIP_TLV_Serialize32((uint32_t)(StringLength)), ##__VA_ARGS__ /** * @brief @@ -390,4 +390,4 @@ * @param ... Bytes to serialize */ #define CHIP_TLV_BYTE_STRING_8ByteLength(TagSpec, StringLength, ...) \ - chip::TLV::kTLVElementType_ByteString_8ByteLength | TagSpec, CHIP_TLV_Serialize64((uint64_t)(StringLength)), ##__VA_ARGS__ + chip::TLV::TLVElementType::ByteString_8ByteLength | TagSpec, CHIP_TLV_Serialize64((uint64_t)(StringLength)), ##__VA_ARGS__ diff --git a/src/lib/core/CHIPTLVDebug.cpp b/src/lib/core/CHIPTLVDebug.cpp index 21015d90009fb7..7a45a8d19156f7 100644 --- a/src/lib/core/CHIPTLVDebug.cpp +++ b/src/lib/core/CHIPTLVDebug.cpp @@ -185,35 +185,35 @@ const char * DecodeTagControl(const TLVTagControl aTagControl) switch (aTagControl) { - case kTLVTagControl_Anonymous: + case TLVTagControl::Anonymous: retval = "Anonymous"; break; - case kTLVTagControl_ContextSpecific: + case TLVTagControl::ContextSpecific: retval = "Context Specific"; break; - case kTLVTagControl_CommonProfile_2Bytes: + case TLVTagControl::CommonProfile_2Bytes: retval = "Common Profile (2 Bytes)"; break; - case kTLVTagControl_CommonProfile_4Bytes: + case TLVTagControl::CommonProfile_4Bytes: retval = "Common Profile (4 Bytes)"; break; - case kTLVTagControl_ImplicitProfile_2Bytes: + case TLVTagControl::ImplicitProfile_2Bytes: retval = "Implicit Profile (2 Bytes)"; break; - case kTLVTagControl_ImplicitProfile_4Bytes: + case TLVTagControl::ImplicitProfile_4Bytes: retval = "Implicit Profile (4 Bytes)"; break; - case kTLVTagControl_FullyQualified_6Bytes: + case TLVTagControl::FullyQualified_6Bytes: retval = "Fully Qualified (6 Bytes)"; break; - case kTLVTagControl_FullyQualified_8Bytes: + case TLVTagControl::FullyQualified_8Bytes: retval = "Fully Qualified (8 Bytes)"; break; diff --git a/src/lib/core/CHIPTLVReader.cpp b/src/lib/core/CHIPTLVReader.cpp index 6ec52057b7556a..81193dfd577e99 100644 --- a/src/lib/core/CHIPTLVReader.cpp +++ b/src/lib/core/CHIPTLVReader.cpp @@ -266,13 +266,13 @@ void TLVReader::Init(const TLVReader & aReader) TLVType TLVReader::GetType() const { TLVElementType elemType = ElementType(); - if (elemType == kTLVElementType_EndOfContainer) + if (elemType == TLVElementType::EndOfContainer) return kTLVType_NotSpecified; - if (elemType == kTLVElementType_FloatingPointNumber32 || elemType == kTLVElementType_FloatingPointNumber64) + if (elemType == TLVElementType::FloatingPointNumber32 || elemType == TLVElementType::FloatingPointNumber64) return kTLVType_FloatingPointNumber; - if (elemType == kTLVElementType_NotSpecified || elemType >= kTLVElementType_Null) + if (elemType == TLVElementType::NotSpecified || elemType >= TLVElementType::Null) return static_cast(elemType); - return static_cast(elemType & ~kTLVTypeSizeMask); + return static_cast(static_cast(elemType) & ~kTLVTypeSizeMask); } /** @@ -346,9 +346,9 @@ uint32_t TLVReader::GetLength() const CHIP_ERROR TLVReader::Get(bool & v) { TLVElementType elemType = ElementType(); - if (elemType == kTLVElementType_BooleanFalse) + if (elemType == TLVElementType::BooleanFalse) v = false; - else if (elemType == kTLVElementType_BooleanTrue) + else if (elemType == TLVElementType::BooleanTrue) v = true; else return CHIP_ERROR_WRONG_TLV_TYPE; @@ -521,20 +521,20 @@ CHIP_ERROR TLVReader::Get(uint64_t & v) { switch (ElementType()) { - case kTLVElementType_Int8: + case TLVElementType::Int8: v = static_cast(static_cast(CastToSigned(static_cast(mElemLenOrVal)))); break; - case kTLVElementType_Int16: + case TLVElementType::Int16: v = static_cast(static_cast(CastToSigned(static_cast(mElemLenOrVal)))); break; - case kTLVElementType_Int32: + case TLVElementType::Int32: v = static_cast(static_cast(CastToSigned(static_cast(mElemLenOrVal)))); break; - case kTLVElementType_Int64: - case kTLVElementType_UInt8: - case kTLVElementType_UInt16: - case kTLVElementType_UInt32: - case kTLVElementType_UInt64: + case TLVElementType::Int64: + case TLVElementType::UInt8: + case TLVElementType::UInt16: + case TLVElementType::UInt32: + case TLVElementType::UInt64: v = mElemLenOrVal; break; default: @@ -557,7 +557,7 @@ CHIP_ERROR TLVReader::Get(double & v) { switch (ElementType()) { - case kTLVElementType_FloatingPointNumber32: { + case TLVElementType::FloatingPointNumber32: { union { uint32_t u32; @@ -567,7 +567,7 @@ CHIP_ERROR TLVReader::Get(double & v) v = cvt.f; break; } - case kTLVElementType_FloatingPointNumber64: { + case TLVElementType::FloatingPointNumber64: { union { uint64_t u64; @@ -1095,7 +1095,7 @@ CHIP_ERROR TLVReader::Next() return err; elemType = ElementType(); - if (elemType == kTLVElementType_EndOfContainer) + if (elemType == TLVElementType::EndOfContainer) return CHIP_END_OF_TLV; return CHIP_NO_ERROR; @@ -1167,7 +1167,7 @@ CHIP_ERROR TLVReader::Skip() CHIP_ERROR err; TLVElementType elemType = ElementType(); - if (elemType == kTLVElementType_EndOfContainer) + if (elemType == TLVElementType::EndOfContainer) return CHIP_END_OF_TLV; if (TLVTypeIsContainer(elemType)) @@ -1246,7 +1246,7 @@ CHIP_ERROR TLVReader::SkipToEndOfContainer() { TLVElementType elemType = ElementType(); - if (elemType == kTLVElementType_EndOfContainer) + if (elemType == TLVElementType::EndOfContainer) { if (nestLevel == 0) return CHIP_NO_ERROR; @@ -1354,7 +1354,7 @@ CHIP_ERROR TLVReader::ReadElement() CHIP_ERROR TLVReader::VerifyElement() { - if (ElementType() == kTLVElementType_EndOfContainer) + if (ElementType() == TLVElementType::EndOfContainer) { if (mContainerType == kTLVType_NotSpecified) return CHIP_ERROR_INVALID_TLV_ELEMENT; @@ -1412,29 +1412,29 @@ uint64_t TLVReader::ReadTag(TLVTagControl tagControl, const uint8_t *& p) switch (tagControl) { - case kTLVTagControl_ContextSpecific: + case TLVTagControl::ContextSpecific: return ContextTag(Read8(p)); - case kTLVTagControl_CommonProfile_2Bytes: + case TLVTagControl::CommonProfile_2Bytes: return CommonTag(LittleEndian::Read16(p)); - case kTLVTagControl_CommonProfile_4Bytes: + case TLVTagControl::CommonProfile_4Bytes: return CommonTag(LittleEndian::Read32(p)); - case kTLVTagControl_ImplicitProfile_2Bytes: + case TLVTagControl::ImplicitProfile_2Bytes: if (ImplicitProfileId == kProfileIdNotSpecified) return UnknownImplicitTag; return ProfileTag(ImplicitProfileId, LittleEndian::Read16(p)); - case kTLVTagControl_ImplicitProfile_4Bytes: + case TLVTagControl::ImplicitProfile_4Bytes: if (ImplicitProfileId == kProfileIdNotSpecified) return UnknownImplicitTag; return ProfileTag(ImplicitProfileId, LittleEndian::Read32(p)); - case kTLVTagControl_FullyQualified_6Bytes: + case TLVTagControl::FullyQualified_6Bytes: vendorId = LittleEndian::Read16(p); profileNum = LittleEndian::Read16(p); return ProfileTag(vendorId, profileNum, LittleEndian::Read16(p)); - case kTLVTagControl_FullyQualified_8Bytes: + case TLVTagControl::FullyQualified_8Bytes: vendorId = LittleEndian::Read16(p); profileNum = LittleEndian::Read16(p); return ProfileTag(vendorId, profileNum, LittleEndian::Read32(p)); - case kTLVTagControl_Anonymous: + case TLVTagControl::Anonymous: default: return AnonymousTag; } @@ -1543,7 +1543,7 @@ CHIP_ERROR TLVReader::GetElementHeadLength(uint8_t & elemHeadBytes) const TLVElementType TLVReader::ElementType() const { if (mControlByte == static_cast(kTLVControlByte_NotSpecified)) - return kTLVElementType_NotSpecified; + return TLVElementType::NotSpecified; return static_cast(mControlByte & kTLVTypeMask); } diff --git a/src/lib/core/CHIPTLVTags.h b/src/lib/core/CHIPTLVTags.h index d97c54f61e8f7c..021ebf7d1b2a31 100644 --- a/src/lib/core/CHIPTLVTags.h +++ b/src/lib/core/CHIPTLVTags.h @@ -52,18 +52,26 @@ enum TLVTagFields }; // TODO: Move to private namespace -enum TLVTagControl -{ - kTLVTagControl_Anonymous = 0x00, - kTLVTagControl_ContextSpecific = 0x20, - kTLVTagControl_CommonProfile_2Bytes = 0x40, - kTLVTagControl_CommonProfile_4Bytes = 0x60, - kTLVTagControl_ImplicitProfile_2Bytes = 0x80, - kTLVTagControl_ImplicitProfile_4Bytes = 0xA0, - kTLVTagControl_FullyQualified_6Bytes = 0xC0, - kTLVTagControl_FullyQualified_8Bytes = 0xE0 +enum class TLVTagControl : uint8_t +{ + // IMPORTANT: All values here must have no bits in common with specified + // values of TLVElementType. + Anonymous = 0x00, + ContextSpecific = 0x20, + CommonProfile_2Bytes = 0x40, + CommonProfile_4Bytes = 0x60, + ImplicitProfile_2Bytes = 0x80, + ImplicitProfile_4Bytes = 0xA0, + FullyQualified_6Bytes = 0xC0, + FullyQualified_8Bytes = 0xE0 }; +template +inline uint8_t operator>>(TLVTagControl lhs, const T & rhs) +{ + return static_cast(lhs) >> rhs; +} + // TODO: Move to private namespace enum { diff --git a/src/lib/core/CHIPTLVTypes.h b/src/lib/core/CHIPTLVTypes.h index ecd79f428caf2b..b43fb70b182626 100644 --- a/src/lib/core/CHIPTLVTypes.h +++ b/src/lib/core/CHIPTLVTypes.h @@ -41,43 +41,61 @@ enum TLVType kTLVType_FloatingPointNumber = 0x0A, kTLVType_UTF8String = 0x0C, kTLVType_ByteString = 0x10, - kTLVType_Null = 0x14, - kTLVType_Structure = 0x15, - kTLVType_Array = 0x16, - kTLVType_Path = 0x17 + // IMPORTANT: Values starting at Null must match the corresponding values of + // TLVElementType. + kTLVType_Null = 0x14, + kTLVType_Structure = 0x15, + kTLVType_Array = 0x16, + kTLVType_Path = 0x17 }; // TODO: Move to private namespace -enum TLVElementType +enum class TLVElementType : int8_t { - kTLVElementType_NotSpecified = -1, - kTLVElementType_Int8 = 0x00, - kTLVElementType_Int16 = 0x01, - kTLVElementType_Int32 = 0x02, - kTLVElementType_Int64 = 0x03, - kTLVElementType_UInt8 = 0x04, - kTLVElementType_UInt16 = 0x05, - kTLVElementType_UInt32 = 0x06, - kTLVElementType_UInt64 = 0x07, - kTLVElementType_BooleanFalse = 0x08, - kTLVElementType_BooleanTrue = 0x09, - kTLVElementType_FloatingPointNumber32 = 0x0A, - kTLVElementType_FloatingPointNumber64 = 0x0B, - kTLVElementType_UTF8String_1ByteLength = 0x0C, - kTLVElementType_UTF8String_2ByteLength = 0x0D, - kTLVElementType_UTF8String_4ByteLength = 0x0E, - kTLVElementType_UTF8String_8ByteLength = 0x0F, - kTLVElementType_ByteString_1ByteLength = 0x10, - kTLVElementType_ByteString_2ByteLength = 0x11, - kTLVElementType_ByteString_4ByteLength = 0x12, - kTLVElementType_ByteString_8ByteLength = 0x13, - kTLVElementType_Null = 0x14, - kTLVElementType_Structure = 0x15, - kTLVElementType_Array = 0x16, - kTLVElementType_Path = 0x17, - kTLVElementType_EndOfContainer = 0x18 + // IMPORTANT: All values here except NotSpecified must have no bits in + // common with values of TagControl. + NotSpecified = -1, + Int8 = 0x00, + Int16 = 0x01, + Int32 = 0x02, + Int64 = 0x03, + UInt8 = 0x04, + UInt16 = 0x05, + UInt32 = 0x06, + UInt64 = 0x07, + BooleanFalse = 0x08, + BooleanTrue = 0x09, + FloatingPointNumber32 = 0x0A, + FloatingPointNumber64 = 0x0B, + UTF8String_1ByteLength = 0x0C, + UTF8String_2ByteLength = 0x0D, + UTF8String_4ByteLength = 0x0E, + UTF8String_8ByteLength = 0x0F, + ByteString_1ByteLength = 0x10, + ByteString_2ByteLength = 0x11, + ByteString_4ByteLength = 0x12, + ByteString_8ByteLength = 0x13, + // IMPORTANT: Values starting at Null must match the corresponding values of + // TLVType. + Null = 0x14, + Structure = 0x15, + Array = 0x16, + Path = 0x17, + EndOfContainer = 0x18 }; +template +inline bool operator<=(const T & lhs, TLVElementType rhs) +{ + return lhs <= static_cast(rhs); +} + +template +inline bool operator>=(const T & lhs, TLVElementType rhs) +{ + return lhs >= static_cast(rhs); +} + // TODO: Move to private namespace enum TLVFieldSize { @@ -100,9 +118,9 @@ enum * * @return @p true if the specified TLV type is valid; otherwise @p false. */ -inline bool IsValidTLVType(uint8_t type) +inline bool IsValidTLVType(TLVElementType type) { - return type <= kTLVElementType_EndOfContainer; + return type <= TLVElementType::EndOfContainer; } /** @@ -110,10 +128,10 @@ inline bool IsValidTLVType(uint8_t type) * * @return @p true if the specified TLV type implies the presence of an associated value field; otherwise @p false. */ -inline bool TLVTypeHasValue(uint8_t type) +inline bool TLVTypeHasValue(TLVElementType type) { - return (type <= kTLVElementType_UInt64 || - (type >= kTLVElementType_FloatingPointNumber32 && type <= kTLVElementType_ByteString_8ByteLength)); + return (type <= TLVElementType::UInt64 || + (type >= TLVElementType::FloatingPointNumber32 && type <= TLVElementType::ByteString_8ByteLength)); } /** @@ -121,9 +139,9 @@ inline bool TLVTypeHasValue(uint8_t type) * * @return @p true if the specified TLV type implies the presence of an associated length field; otherwise @p false. */ -inline bool TLVTypeHasLength(uint8_t type) +inline bool TLVTypeHasLength(TLVElementType type) { - return type >= kTLVElementType_UTF8String_1ByteLength && type <= kTLVElementType_ByteString_8ByteLength; + return type >= TLVElementType::UTF8String_1ByteLength && type <= TLVElementType::ByteString_8ByteLength; } /** @@ -131,9 +149,14 @@ inline bool TLVTypeHasLength(uint8_t type) * * @return @p true if the specified TLV type is a container; otherwise @p false. */ -inline bool TLVTypeIsContainer(uint8_t type) +inline bool TLVTypeIsContainer(TLVElementType type) +{ + return type >= TLVElementType::Structure && type <= TLVElementType::Path; +} + +inline bool TLVTypeIsContainer(TLVType type) { - return type >= kTLVElementType_Structure && type <= kTLVElementType_Path; + return type >= kTLVType_Structure && type <= kTLVType_Path; } /** @@ -141,16 +164,16 @@ inline bool TLVTypeIsContainer(uint8_t type) * * @return @p true if the specified TLV type is a UTF8 or byte string; otherwise @p false. */ -inline bool TLVTypeIsString(uint8_t type) +inline bool TLVTypeIsString(TLVElementType type) { - return type >= kTLVElementType_UTF8String_1ByteLength && type <= kTLVElementType_ByteString_8ByteLength; + return type >= TLVElementType::UTF8String_1ByteLength && type <= TLVElementType::ByteString_8ByteLength; } // TODO: move to private namespace -inline TLVFieldSize GetTLVFieldSize(uint8_t type) +inline TLVFieldSize GetTLVFieldSize(TLVElementType type) { if (TLVTypeHasValue(type)) - return static_cast(type & kTLVTypeSizeMask); + return static_cast(static_cast(type) & kTLVTypeSizeMask); return kTLVFieldSize_0Byte; } diff --git a/src/lib/core/CHIPTLVUpdater.cpp b/src/lib/core/CHIPTLVUpdater.cpp index 82b636c0612b5c..b71b9ab24b4c6e 100644 --- a/src/lib/core/CHIPTLVUpdater.cpp +++ b/src/lib/core/CHIPTLVUpdater.cpp @@ -121,7 +121,7 @@ CHIP_ERROR TLVUpdater::Init(TLVReader & aReader, uint32_t freeLen) VerifyOrExit(buf != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); // If reader is already on an element, reset it to start of element - if (aReader.ElementType() != kTLVElementType_NotSpecified) + if (aReader.ElementType() != TLVElementType::NotSpecified) { uint8_t elemHeadLen; @@ -289,7 +289,8 @@ CHIP_ERROR TLVUpdater::Move() const uint8_t * elementEnd; uint32_t copyLen; - VerifyOrExit((mUpdaterReader.mControlByte & kTLVTypeMask) != kTLVElementType_EndOfContainer, err = CHIP_END_OF_TLV); + VerifyOrExit(static_cast((mUpdaterReader.mControlByte & kTLVTypeMask)) != TLVElementType::EndOfContainer, + err = CHIP_END_OF_TLV); VerifyOrExit(mUpdaterReader.GetType() != kTLVType_NotSpecified, err = CHIP_ERROR_INVALID_TLV_ELEMENT); @@ -397,7 +398,8 @@ CHIP_ERROR TLVUpdater::EnterContainer(TLVType & outerContainerType) CHIP_ERROR err = CHIP_NO_ERROR; TLVType containerType; - VerifyOrExit(TLVTypeIsContainer(mUpdaterReader.mControlByte & kTLVTypeMask), err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(TLVTypeIsContainer(static_cast(mUpdaterReader.mControlByte & kTLVTypeMask)), + err = CHIP_ERROR_INCORRECT_STATE); // Change the updater state AdjustInternalWriterFreeSpace(); diff --git a/src/lib/core/CHIPTLVWriter.cpp b/src/lib/core/CHIPTLVWriter.cpp index cd95e27729a32c..67efc38f52956b 100644 --- a/src/lib/core/CHIPTLVWriter.cpp +++ b/src/lib/core/CHIPTLVWriter.cpp @@ -313,7 +313,7 @@ CHIP_ERROR TLVWriter::Finalize() */ CHIP_ERROR TLVWriter::PutBoolean(uint64_t tag, bool v) { - return WriteElementHead((v) ? kTLVElementType_BooleanTrue : kTLVElementType_BooleanFalse, tag, 0); + return WriteElementHead((v) ? TLVElementType::BooleanTrue : TLVElementType::BooleanFalse, tag, 0); } /** @@ -380,7 +380,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, uint8_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, uint8_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_UInt8, tag, v); + return WriteElementHead(TLVElementType::UInt8, tag, v); return Put(tag, v); } @@ -398,7 +398,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, uint16_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, uint16_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_UInt16, tag, v); + return WriteElementHead(TLVElementType::UInt16, tag, v); return Put(tag, v); } @@ -416,7 +416,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, uint32_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, uint32_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_UInt32, tag, v); + return WriteElementHead(TLVElementType::UInt32, tag, v); return Put(tag, v); } @@ -427,13 +427,13 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, uint64_t v) { TLVElementType elemType; if (v <= UINT8_MAX) - elemType = kTLVElementType_UInt8; + elemType = TLVElementType::UInt8; else if (v <= UINT16_MAX) - elemType = kTLVElementType_UInt16; + elemType = TLVElementType::UInt16; else if (v <= UINT32_MAX) - elemType = kTLVElementType_UInt32; + elemType = TLVElementType::UInt32; else - elemType = kTLVElementType_UInt64; + elemType = TLVElementType::UInt64; return WriteElementHead(elemType, tag, v); } @@ -443,7 +443,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, uint64_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, uint64_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_UInt64, tag, v); + return WriteElementHead(TLVElementType::UInt64, tag, v); return Put(tag, v); } @@ -511,7 +511,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, int8_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, int8_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_Int8, tag, v); + return WriteElementHead(TLVElementType::Int8, tag, v); return Put(tag, v); } @@ -529,7 +529,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, int16_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, int16_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_Int16, tag, v); + return WriteElementHead(TLVElementType::Int16, tag, v); return Put(tag, v); } @@ -547,7 +547,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, int32_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, int32_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_Int32, tag, v); + return WriteElementHead(TLVElementType::Int32, tag, v); return Put(tag, v); } @@ -558,13 +558,13 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, int64_t v) { TLVElementType elemType; if (v >= INT8_MIN && v <= INT8_MAX) - elemType = kTLVElementType_Int8; + elemType = TLVElementType::Int8; else if (v >= INT16_MIN && v <= INT16_MAX) - elemType = kTLVElementType_Int16; + elemType = TLVElementType::Int16; else if (v >= INT32_MIN && v <= INT32_MAX) - elemType = kTLVElementType_Int32; + elemType = TLVElementType::Int32; else - elemType = kTLVElementType_Int64; + elemType = TLVElementType::Int64; return WriteElementHead(elemType, tag, v); } @@ -574,7 +574,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, int64_t v) CHIP_ERROR TLVWriter::Put(uint64_t tag, int64_t v, bool preserveSize) { if (preserveSize) - return WriteElementHead(kTLVElementType_Int64, tag, v); + return WriteElementHead(TLVElementType::Int64, tag, v); return Put(tag, v); } @@ -589,7 +589,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, float v) uint32_t u32; } cvt; cvt.f = v; - return WriteElementHead(kTLVElementType_FloatingPointNumber32, tag, cvt.u32); + return WriteElementHead(TLVElementType::FloatingPointNumber32, tag, cvt.u32); } /** @@ -626,7 +626,7 @@ CHIP_ERROR TLVWriter::Put(uint64_t tag, double v) uint64_t u64; } cvt; cvt.d = v; - return WriteElementHead(kTLVElementType_FloatingPointNumber64, tag, cvt.u64); + return WriteElementHead(TLVElementType::FloatingPointNumber64, tag, cvt.u64); } /** @@ -975,7 +975,7 @@ CHIP_ERROR TLVWriter::VPutStringF(uint64_t tag, const char * fmt, va_list ap) */ CHIP_ERROR TLVWriter::PutNull(uint64_t tag) { - return WriteElementHead(kTLVElementType_Null, tag, 0); + return WriteElementHead(TLVElementType::Null, tag, 0); } /** @@ -1085,7 +1085,7 @@ CHIP_ERROR TLVWriter::CopyElement(uint64_t tag, TLVReader & reader) uint32_t copyDataLen; uint8_t chunk[kCHIPTLVCopyChunkSize]; - VerifyOrExit(elemType != kTLVElementType_NotSpecified && elemType != kTLVElementType_EndOfContainer, + VerifyOrExit(elemType != TLVElementType::NotSpecified && elemType != TLVElementType::EndOfContainer, err = CHIP_ERROR_INCORRECT_STATE); // Initialize the helper @@ -1264,7 +1264,7 @@ CHIP_ERROR TLVWriter::CloseContainer(TLVWriter & containerWriter) // Reset the container writer so that it can't accidentally be used again. containerWriter.Init(static_cast(nullptr), 0); - return WriteElementHead(kTLVElementType_EndOfContainer, AnonymousTag, 0); + return WriteElementHead(TLVElementType::EndOfContainer, AnonymousTag, 0); } /** @@ -1382,7 +1382,7 @@ CHIP_ERROR TLVWriter::EndContainer(TLVType outerContainerType) if (IsCloseContainerReserved()) mMaxLen += kEndOfContainerMarkerSize; - return WriteElementHead(kTLVElementType_EndOfContainer, AnonymousTag, 0); + return WriteElementHead(TLVElementType::EndOfContainer, AnonymousTag, 0); } /** @@ -1654,16 +1654,16 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, uint64_t tag, ui if (mContainerType != kTLVType_Structure && mContainerType != kTLVType_Path) return CHIP_ERROR_INVALID_TLV_TAG; - Write8(p, kTLVTagControl_ContextSpecific | elemType); + Write8(p, TLVTagControl::ContextSpecific | elemType); Write8(p, static_cast(tagNum)); } else { - if (elemType != kTLVElementType_EndOfContainer && mContainerType != kTLVType_NotSpecified && + if (elemType != TLVElementType::EndOfContainer && mContainerType != kTLVType_NotSpecified && mContainerType != kTLVType_Array && mContainerType != kTLVType_Path) return CHIP_ERROR_INVALID_TLV_TAG; - Write8(p, kTLVTagControl_Anonymous | elemType); + Write8(p, TLVTagControl::Anonymous | elemType); } } else @@ -1677,12 +1677,12 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, uint64_t tag, ui { if (tagNum < 65536) { - Write8(p, kTLVTagControl_CommonProfile_2Bytes | elemType); + Write8(p, TLVTagControl::CommonProfile_2Bytes | elemType); LittleEndian::Write16(p, static_cast(tagNum)); } else { - Write8(p, kTLVTagControl_CommonProfile_4Bytes | elemType); + Write8(p, TLVTagControl::CommonProfile_4Bytes | elemType); LittleEndian::Write32(p, tagNum); } } @@ -1690,12 +1690,12 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, uint64_t tag, ui { if (tagNum < 65536) { - Write8(p, kTLVTagControl_ImplicitProfile_2Bytes | elemType); + Write8(p, TLVTagControl::ImplicitProfile_2Bytes | elemType); LittleEndian::Write16(p, static_cast(tagNum)); } else { - Write8(p, kTLVTagControl_ImplicitProfile_4Bytes | elemType); + Write8(p, TLVTagControl::ImplicitProfile_4Bytes | elemType); LittleEndian::Write32(p, tagNum); } } @@ -1706,14 +1706,14 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, uint64_t tag, ui if (tagNum < 65536) { - Write8(p, kTLVTagControl_FullyQualified_6Bytes | elemType); + Write8(p, TLVTagControl::FullyQualified_6Bytes | elemType); LittleEndian::Write16(p, vendorId); LittleEndian::Write16(p, profileNum); LittleEndian::Write16(p, static_cast(tagNum)); } else { - Write8(p, kTLVTagControl_FullyQualified_8Bytes | elemType); + Write8(p, TLVTagControl::FullyQualified_8Bytes | elemType); LittleEndian::Write16(p, vendorId); LittleEndian::Write16(p, profileNum); LittleEndian::Write32(p, tagNum); diff --git a/src/lib/core/tests/TestCHIPTLV.cpp b/src/lib/core/tests/TestCHIPTLV.cpp index 8c43c2794c9072..2bc50798ea8e24 100644 --- a/src/lib/core/tests/TestCHIPTLV.cpp +++ b/src/lib/core/tests/TestCHIPTLV.cpp @@ -2637,7 +2637,7 @@ void PreserveSizeWrite(nlTestSuite * inSuite, TLVWriter & writer, bool preserveS CHIP_ERROR err; TLVWriter writer2; - // kTLVTagControl_FullyQualified_8Bytes + // TLVTagControl::FullyQualified_8Bytes err = writer.Put(ProfileTag(TestProfile_1, 4000000000ULL), static_cast(40000000000ULL), true); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);