diff --git a/examples/chip-tool/commands/clusters/CustomArgument.h b/examples/chip-tool/commands/clusters/CustomArgument.h index 9d56ac0043959d..451f8b96a3dbd8 100644 --- a/examples/chip-tool/commands/clusters/CustomArgument.h +++ b/examples/chip-tool/commands/clusters/CustomArgument.h @@ -255,6 +255,10 @@ class CustomArgument return writer.CopyElement(tag, reader); } + // We trust our consumers to do the encoding of our data correctly, so don't + // need to know whether we are being encoded for a write. + static constexpr bool kIsFabricScoped = false; + private: uint8_t * mData = nullptr; uint32_t mDataLen = 0; diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index d12ea80e25bce0..8e489a260024b4 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -77,11 +77,19 @@ class AttributeReportBuilder /** * EncodeValue encodes the value field of the report, it should be called exactly once. */ - template - CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, Ts &&... aArgs) + template ::value, bool> = true, typename... Ts> + CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, T && item, Ts &&... aArgs) { return DataModel::Encode(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), - TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData)), std::forward(aArgs)...); + TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData)), item, std::forward(aArgs)...); + } + + template ::value, bool> = true, typename... Ts> + CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, FabricIndex accessingFabricIndex, T && item, + Ts &&... aArgs) + { + return DataModel::EncodeForRead(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), + TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData)), accessingFabricIndex, item); } }; @@ -104,12 +112,14 @@ class AttributeValueEncoder template ::value, bool> = true> CHIP_ERROR Encode(T && aArg) const { + VerifyOrReturnError(aArg.GetFabricIndex() != kUndefinedFabricIndex, CHIP_ERROR_INVALID_FABRIC_ID); + // If we are encoding for a fabric filtered attribute read and the fabric index does not match that present in the // request, skip encoding this list item. VerifyOrReturnError(!mAttributeValueEncoder.mIsFabricFiltered || aArg.GetFabricIndex() == mAttributeValueEncoder.mAccessingFabricIndex, CHIP_NO_ERROR); - return mAttributeValueEncoder.EncodeListItem(std::forward(aArg)); + return mAttributeValueEncoder.EncodeListItem(mAttributeValueEncoder.mAccessingFabricIndex, std::forward(aArg)); } template ::value, bool> = true> diff --git a/src/app/EventLogging.h b/src/app/EventLogging.h index 6b9f35be83bf86..9580dcb40a57f4 100644 --- a/src/app/EventLogging.h +++ b/src/app/EventLogging.h @@ -75,6 +75,15 @@ CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aE eventOptions.mPath = path; eventOptions.mPriority = aEventData.GetPriorityLevel(); eventOptions.mFabricIndex = aEventData.GetFabricIndex(); + + // + // Unlike attributes which have a different 'EncodeForRead' for fabric-scoped structs, + // fabric-sensitive events don't require that since the actual omission of the event in its entirety + // happens within the event management framework itself at the time of access. + // + // The 'mFabricIndex' field in the event options above is encoded out-of-band alongside the event payload + // and used to match against the accessing fabric. + // return logMgmt.LogEvent(&eventData, eventOptions, aEventNumber); } diff --git a/src/app/WriteClient.h b/src/app/WriteClient.h index ef4c698a9b2c63..d46ca789bcea8f 100644 --- a/src/app/WriteClient.h +++ b/src/app/WriteClient.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -260,7 +261,7 @@ class WriteClient : public Messaging::ExchangeDelegate /** * Encode an attribute value that can be directly encoded using DataModel::Encode. */ - template + template ::value, int> = 0> CHIP_ERROR TryEncodeSingleAttributeDataIB(const ConcreteDataAttributePath & attributePath, const T & value) { chip::TLV::TLVWriter * writer = nullptr; @@ -274,6 +275,20 @@ class WriteClient : public Messaging::ExchangeDelegate return CHIP_NO_ERROR; } + template ::value, int> = 0> + CHIP_ERROR TryEncodeSingleAttributeDataIB(const ConcreteDataAttributePath & attributePath, const T & value) + { + chip::TLV::TLVWriter * writer = nullptr; + + ReturnErrorOnFailure(PrepareAttributeIB(attributePath)); + VerifyOrReturnError((writer = GetAttributeDataIBTLVWriter()) != nullptr, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(DataModel::EncodeForWrite( + *writer, chip::TLV::ContextTag(to_underlying(chip::app::AttributeDataIB::Tag::kData)), value)); + ReturnErrorOnFailure(FinishAttributeIB()); + + return CHIP_NO_ERROR; + } + /** * A wrapper for TryEncodeSingleAttributeDataIB which will start a new chunk when failed with CHIP_ERROR_NO_MEMORY or * CHIP_ERROR_BUFFER_TOO_SMALL. diff --git a/src/app/clusters/access-control-server/access-control-server.cpp b/src/app/clusters/access-control-server/access-control-server.cpp index d6ba6912345bbd..a85daee3588a01 100644 --- a/src/app/clusters/access-control-server/access-control-server.cpp +++ b/src/app/clusters/access-control-server/access-control-server.cpp @@ -225,7 +225,7 @@ struct AccessControlEntryCodec return CHIP_NO_ERROR; } - CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const + CHIP_ERROR EncodeForRead(TLV::TLVWriter & aWriter, TLV::Tag aTag, FabricIndex accessingFabricIndex) const { AccessControlCluster::Structs::AccessControlEntry::Type staging; @@ -272,7 +272,7 @@ struct AccessControlEntryCodec staging.targets.SetNonNull(targetBuffer, targetCount); } - return staging.Encode(aWriter, aTag); + return staging.EncodeForRead(aWriter, aTag, accessingFabricIndex); } CHIP_ERROR Decode(TLV::TLVReader & aReader) diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp index 4206e049c6cb9f..731dbdc4ee95ed 100644 --- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp +++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp @@ -72,7 +72,7 @@ struct GroupTableCodec auto GetFabricIndex() const { return mFabric; } - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 82a39e8d8b2ed9..dd76f00e6681fb 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -546,9 +546,6 @@ CHIP_ERROR TestAttrAccess::ReadListFabricScopedAttribute(AttributeValueEncoder & ReturnErrorOnFailure(encoder.Encode(val)); } - // Always append a fake fabric index so we can test fabric filter even when there is only one fabric provisioned. - val.fabricIndex = kUndefinedFabricIndex; - ReturnErrorOnFailure(encoder.Encode(val)); return CHIP_NO_ERROR; }); } diff --git a/src/app/data-model/Encode.h b/src/app/data-model/Encode.h index 979d31a0340540..fe3cc48ab46321 100644 --- a/src/app/data-model/Encode.h +++ b/src/app/data-model/Encode.h @@ -18,8 +18,10 @@ #pragma once +#include #include #include +#include #include #include @@ -71,7 +73,7 @@ inline CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, Span /* * @brief * - * This specific variant that encodes cluster objects (like structs, commands, events) to TLV + * This specific variant that encodes cluster objects (like non fabric-scoped structs, commands, events) to TLV * depends on the presence of an Encode method on the object. The signature of that method * is as follows: * @@ -90,6 +92,44 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, const X & x) return x.Encode(writer, tag); } +/* + * @brief + * + * A way to encode fabric-scoped structs for a write that omits encoding the containing fabric index field. + */ +template ::value && + std::is_same().EncodeForWrite(std::declval(), + std::declval())), + CHIP_ERROR>::value && + DataModel::IsFabricScoped::value, + X> * = nullptr> +CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag, const X & x) +{ + return x.EncodeForWrite(writer, tag); +} + +/* + * @brief + * + * A way to encode fabric-scoped structs for a read that always encodes the containing fabric index field. + * + * An accessing fabric index must be passed in to permit including/omitting sensitive fields based on a match with the fabric index + * associated with the scoped struct. + */ +template ::value && + std::is_same().EncodeForRead(std::declval(), std::declval(), + std::declval())), + CHIP_ERROR>::value && + DataModel::IsFabricScoped::value, + X> * = nullptr> +CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex, const X & x) +{ + return x.EncodeForRead(writer, tag, accessingFabricIndex); +} + /* * @brief * @@ -140,6 +180,54 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, const Nullable & x) #pragma GCC diagnostic pop } +/* + * @brief + * + * Encodes a nullable fabric-scoped struct for a write. + */ +template ::value, bool> = true> +CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag, const Nullable & x) +{ + if (x.IsNull()) + { + return writer.PutNull(tag); + } + + // The -Wmaybe-uninitialized warning gets confused about the fact + // that x.mValue is always initialized if x.IsNull() is not + // true, so suppress it for our access to x.Value(). +#pragma GCC diagnostic push +#if !defined(__clang__) +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif // !defined(__clang__) + return EncodeForWrite(writer, tag, x.Value()); +#pragma GCC diagnostic pop +} + +/* + * @brief + * + * Encodes a nullable fabric-scoped struct for a read. + */ +template ::value, bool> = true> +CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex, const Nullable & x) +{ + if (x.IsNull()) + { + return writer.PutNull(tag); + } + + // The -Wmaybe-uninitialized warning gets confused about the fact + // that x.mValue is always initialized if x.IsNull() is not + // true, so suppress it for our access to x.Value(). +#pragma GCC diagnostic push +#if !defined(__clang__) +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif // !defined(__clang__) + return EncodeForRead(writer, tag, accessingFabricIndex, x.Value()); +#pragma GCC diagnostic pop +} + } // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/data-model/List.h b/src/app/data-model/List.h index 9d805fef9c6f30..a68c3fb4ef6d5b 100644 --- a/src/app/data-model/List.h +++ b/src/app/data-model/List.h @@ -20,6 +20,7 @@ #include #include +#include #include namespace chip { @@ -55,6 +56,11 @@ struct List : public Span Span::operator=(databuf); return (*this); } + + // + // A list is deemed fabric scoped if the type of its elements is as well. + // + static constexpr bool kIsFabricScoped = DataModel::IsFabricScoped::value; }; template @@ -72,6 +78,36 @@ inline CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, List list) return CHIP_NO_ERROR; } +template ::value, bool> = true> +inline CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag, List list) +{ + TLV::TLVType type; + + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Array, type)); + for (auto & item : list) + { + ReturnErrorOnFailure(EncodeForWrite(writer, TLV::AnonymousTag(), item)); + } + ReturnErrorOnFailure(writer.EndContainer(type)); + + return CHIP_NO_ERROR; +} + +template ::value, bool> = true> +inline CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex, List list) +{ + TLV::TLVType type; + + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Array, type)); + for (auto & item : list) + { + ReturnErrorOnFailure(EncodeForRead(writer, TLV::AnonymousTag(), accessingFabricIndex, item)); + } + ReturnErrorOnFailure(writer.EndContainer(type)); + + return CHIP_NO_ERROR; +} + } // namespace DataModel } // namespace app } // namespace chip diff --git a/src/app/tests/TestAttributeValueDecoder.cpp b/src/app/tests/TestAttributeValueDecoder.cpp index cf9245549ab51d..04f65d0171bc63 100644 --- a/src/app/tests/TestAttributeValueDecoder.cpp +++ b/src/app/tests/TestAttributeValueDecoder.cpp @@ -52,7 +52,7 @@ struct TestSetup TLVType ignored; writer.Init(buf); ReturnErrorOnFailure(writer.StartContainer(AnonymousTag(), kTLVType_Structure, ignored)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(0), value)); + ReturnErrorOnFailure(DataModel::EncodeForWrite(writer, TLV::ContextTag(0), value)); ReturnErrorOnFailure(writer.EndContainer(ignored)); ReturnErrorOnFailure(writer.Finalize()); return CHIP_NO_ERROR; diff --git a/src/app/tests/TestAttributeValueEncoder.cpp b/src/app/tests/TestAttributeValueEncoder.cpp index ebebfef11a5a55..4363582c29cb2a 100644 --- a/src/app/tests/TestAttributeValueEncoder.cpp +++ b/src/app/tests/TestAttributeValueEncoder.cpp @@ -255,9 +255,9 @@ void TestEncodeFabricScoped(nlTestSuite * aSuite, void * aContext) { TestSetup test(aSuite, kTestFabricIndex); Clusters::AccessControl::Structs::ExtensionEntry::Type items[3]; - items[0].fabricIndex = 0; - items[1].fabricIndex = 1; - items[2].fabricIndex = 2; + items[0].fabricIndex = 1; + items[1].fabricIndex = 2; + items[2].fabricIndex = 3; // We tried to encode three items, however, the encoder should only put the item with matching fabric index into the final list. CHIP_ERROR err = test.encoder.EncodeList([items](const auto & encoder) -> CHIP_ERROR { diff --git a/src/app/zap-templates/partials/cluster-objects-struct.zapt b/src/app/zap-templates/partials/cluster-objects-struct.zapt index 3956fecc8e3853..c5c07a17025457 100644 --- a/src/app/zap-templates/partials/cluster-objects-struct.zapt +++ b/src/app/zap-templates/partials/cluster-objects-struct.zapt @@ -12,7 +12,6 @@ namespace {{asUpperCamelCase name}} { {{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}}; {{/zcl_struct_items}} - CHIP_ERROR Encode(TLV::TLVWriter &writer, TLV::Tag tag) const; {{#unless struct_contains_array}} CHIP_ERROR Decode(TLV::TLVReader &reader); {{/unless}} @@ -27,6 +26,14 @@ namespace {{asUpperCamelCase name}} { void SetFabricIndex(chip::FabricIndex fabricIndex_) { {{ asLowerCamelCase struct_fabric_idx_field }} = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter &writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter &writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + + private: + CHIP_ERROR DoEncode(TLV::TLVWriter &writer, TLV::Tag tag, const Optional &accessingFabricIndex) const; + {{else}} + CHIP_ERROR Encode(TLV::TLVWriter &writer, TLV::Tag tag) const; {{/if}} }; @@ -58,7 +65,36 @@ namespace {{asUpperCamelCase name}} { } // namespace {{asUpperCamelCase name}} {{else}} namespace {{asUpperCamelCase name}} { -CHIP_ERROR Type::Encode(TLV::TLVWriter &writer, TLV::Tag tag) const{ +{{#if struct_is_fabric_scoped}} +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter &writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter &writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter &writer, TLV::Tag tag, const Optional & accessingFabricIndex) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + {{#zcl_struct_items}} + {{#if (isStrEqual label ../struct_fabric_idx_field)}} + if (accessingFabricIndex.HasValue()) { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase label}})), {{asLowerCamelCase label}})); + } + {{else}} + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase label}})), {{asLowerCamelCase label}})); + {{/if}} + {{/zcl_struct_items}} + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} +{{else}} +CHIP_ERROR Type::Encode(TLV::TLVWriter &writer, TLV::Tag tag) const +{ TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); {{#zcl_struct_items}} @@ -67,6 +103,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter &writer, TLV::Tag tag) const{ ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } +{{/if}} CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) { CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/src/app/zap-templates/templates/app/cluster-objects-src.zapt b/src/app/zap-templates/templates/app/cluster-objects-src.zapt index f966be83caa0c3..be048a3e15d1fc 100644 --- a/src/app/zap-templates/templates/app/cluster-objects-src.zapt +++ b/src/app/zap-templates/templates/app/cluster-objects-src.zapt @@ -95,7 +95,11 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter &writer, TLV::Tag tag) const{ TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); {{#zcl_event_fields}} + {{#if_is_fabric_scoped_struct type}} + ReturnErrorOnFailure(DataModel::EncodeForRead(writer, TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase name}})), GetFabricIndex(), {{asLowerCamelCase name}})); + {{else}} ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase name}})), {{asLowerCamelCase name}})); + {{/if_is_fabric_scoped_struct}} {{/zcl_event_fields}} ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 1c41a49d8bbce5..0547f6f8d80617 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -4613,11 +4613,24 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace Target namespace AccessControlEntry { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kPrivilege)), privilege)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAuthMode)), authMode)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kSubjects)), subjects)); @@ -4666,11 +4679,24 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace AccessControlEntry namespace ExtensionEntry { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kData)), data)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; @@ -4755,7 +4781,8 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAdminNodeID)), adminNodeID)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAdminPasscodeID)), adminPasscodeID)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kChangeType)), changeType)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kLatestValue)), latestValue)); + ReturnErrorOnFailure( + DataModel::EncodeForRead(writer, TLV::ContextTag(to_underlying(Fields::kLatestValue)), GetFabricIndex(), latestValue)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -4805,7 +4832,8 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAdminNodeID)), adminNodeID)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAdminPasscodeID)), adminPasscodeID)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kChangeType)), changeType)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kLatestValue)), latestValue)); + ReturnErrorOnFailure( + DataModel::EncodeForRead(writer, TLV::ContextTag(to_underlying(Fields::kLatestValue)), GetFabricIndex(), latestValue)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -6328,11 +6356,24 @@ namespace Events { namespace OtaSoftwareUpdateRequestor { namespace Structs { namespace ProviderLocation { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kProviderNodeID)), providerNodeID)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kEndpoint)), endpoint)); ReturnErrorOnFailure(writer.EndContainer(outer)); @@ -10155,11 +10196,24 @@ namespace Events { namespace OperationalCredentials { namespace Structs { namespace FabricDescriptor { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kRootPublicKey)), rootPublicKey)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kVendorId)), vendorId)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricId)), fabricId)); @@ -10212,11 +10266,24 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace FabricDescriptor namespace NOCStruct { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kNoc)), noc)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kIcac)), icac)); ReturnErrorOnFailure(writer.EndContainer(outer)); @@ -10795,11 +10862,24 @@ namespace Events { namespace GroupKeyManagement { namespace Structs { namespace GroupInfoMapStruct { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kGroupId)), groupId)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kEndpoints)), endpoints)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kGroupName)), groupName)); @@ -10844,11 +10924,24 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace GroupInfoMapStruct namespace GroupKeyMapStruct { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kGroupId)), groupId)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kGroupKeySetID)), groupKeySetID)); ReturnErrorOnFailure(writer.EndContainer(outer)); @@ -22836,11 +22929,24 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace DoubleNestedStructList namespace TestFabricScoped { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +CHIP_ERROR Type::EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + return DoEncode(writer, tag, NullOptional); +} + +CHIP_ERROR Type::EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const +{ + return DoEncode(writer, tag, MakeOptional(accessingFabricIndex)); +} + +CHIP_ERROR Type::DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + if (accessingFabricIndex.HasValue()) + { + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + } ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 1ef5fbdbb8d54c..fcb5a8a188d782 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -55,10 +55,11 @@ struct Type chip::CharSpan label; chip::CharSpan value; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -1914,10 +1915,11 @@ struct Type uint8_t length = static_cast(0); uint8_t value = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -4846,10 +4848,11 @@ struct Type bool powerProfileRemoteControl = static_cast(0); uint8_t powerProfileState = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -4868,10 +4871,11 @@ struct Type uint8_t energyPhaseId = static_cast(0); uint16_t scheduledTime = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -4898,10 +4902,11 @@ struct Type uint16_t energy = static_cast(0); uint16_t maxActivationDelay = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -6504,10 +6509,11 @@ struct Type chip::DeviceTypeId type = static_cast(0); uint16_t revision = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -6871,10 +6877,11 @@ struct Type DataModel::Nullable endpoint; DataModel::Nullable deviceType; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -6899,13 +6906,17 @@ struct Type DataModel::Nullable> subjects; DataModel::Nullable> targets; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = true; auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; struct DecodableType @@ -6940,7 +6951,6 @@ struct Type chip::FabricIndex fabricIndex = static_cast(0); chip::ByteSpan data; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -6948,6 +6958,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -7595,10 +7611,11 @@ struct Type uint16_t supportedCommands = static_cast(0); ActionStateEnum status = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -7621,9 +7638,9 @@ struct Type EndpointListTypeEnum type = static_cast(0); DataModel::List endpoints; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -9254,7 +9271,6 @@ struct Type chip::NodeId providerNodeID = static_cast(0); chip::EndpointId endpoint = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -9262,6 +9278,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -10132,9 +10154,9 @@ struct Type DataModel::List current; DataModel::List previous; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -10162,9 +10184,9 @@ struct Type DataModel::List current; DataModel::List previous; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -10192,9 +10214,9 @@ struct Type DataModel::List current; DataModel::List previous; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -10727,10 +10749,11 @@ struct Type public: uint16_t failSafeExpiryLengthSeconds = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -11170,10 +11193,11 @@ struct Type chip::ByteSpan networkID; bool connected = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -11204,10 +11228,11 @@ struct Type int8_t rssi = static_cast(0); uint8_t lqi = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -11234,10 +11259,11 @@ struct Type WiFiBand wiFiBand = static_cast(0); int8_t rssi = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12129,9 +12155,9 @@ struct Type DataModel::List IPv6Addresses; InterfaceType type = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -12501,10 +12527,11 @@ struct Type chip::CharSpan name; chip::ByteSpan faultRecording; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12529,10 +12556,11 @@ struct Type uint32_t stackFreeMinimum = static_cast(0); uint32_t stackSize = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12830,10 +12858,11 @@ struct Type bool fullNetworkData = static_cast(0); bool isChild = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12872,10 +12901,11 @@ struct Type bool securityPolicyPresent = static_cast(0); bool channelMaskPresent = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12910,10 +12940,11 @@ struct Type bool allocated = static_cast(0); bool linkEstablished = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -12932,10 +12963,11 @@ struct Type uint16_t rotationTime = static_cast(0); uint16_t flags = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -15798,7 +15830,6 @@ struct Type chip::NodeId nodeId = static_cast(0); chip::CharSpan label; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -15806,6 +15837,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -15826,7 +15863,6 @@ struct Type chip::ByteSpan noc; DataModel::Nullable icac; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -15834,6 +15870,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -16545,13 +16587,17 @@ struct Type DataModel::List endpoints; Optional groupName; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = true; auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; struct DecodableType @@ -16587,7 +16633,6 @@ struct Type chip::GroupId groupId = static_cast(0); uint16_t groupKeySetID = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -16595,6 +16640,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -16625,10 +16676,11 @@ struct Type DataModel::Nullable epochKey2; DataModel::Nullable epochStartTime2; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -17596,10 +17648,11 @@ struct Type uint8_t mode = static_cast(0); uint32_t semanticTag = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -17618,10 +17671,11 @@ struct Type uint16_t mfgCode = static_cast(0); uint16_t value = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -18389,10 +18443,11 @@ struct Type DlCredentialType credentialType = static_cast(0); uint16_t credentialIndex = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -32204,10 +32259,11 @@ struct Type uint8_t zoneId = static_cast(0); chip::BitFlags zoneStatus = static_cast>(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -33427,10 +33483,11 @@ struct Type Optional callSign; Optional affiliateCallSign; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -33453,10 +33510,11 @@ struct Type Optional postalCode; LineupInfoTypeEnum lineupInfoType = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -33771,10 +33829,11 @@ struct Type uint8_t identifier = static_cast(0); chip::CharSpan name; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -34012,10 +34071,11 @@ struct Type uint64_t updatedAt = static_cast(0); DataModel::Nullable position; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -34659,10 +34719,11 @@ struct Type chip::CharSpan name; chip::CharSpan description; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -35382,10 +35443,11 @@ struct Type double height = static_cast(0); MetricTypeEnum metric = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -35404,10 +35466,11 @@ struct Type chip::CharSpan name; chip::CharSpan value; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -35428,9 +35491,9 @@ struct Type chip::CharSpan value; Optional> externalIDList; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -35457,9 +35520,9 @@ struct Type public: DataModel::List parameterList; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -35488,10 +35551,11 @@ struct Type Optional color; Optional size; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -35518,10 +35582,11 @@ struct Type Optional splash; Optional waterMark; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -35803,10 +35868,11 @@ struct Type OutputTypeEnum outputType = static_cast(0); chip::CharSpan name; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36042,10 +36108,11 @@ struct Type uint16_t catalogVendorId = static_cast(0); chip::CharSpan applicationId; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36064,10 +36131,11 @@ struct Type Structs::Application::Type application; Optional endpoint; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36369,10 +36437,11 @@ struct Type uint16_t catalogVendorId = static_cast(0); chip::CharSpan applicationId; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36849,10 +36918,11 @@ struct Type float g = static_cast(0); double h = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36891,9 +36961,9 @@ struct Type Optional> optionalList; Optional>> nullableOptionalList; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -36933,10 +37003,11 @@ struct Type bool b = static_cast(0); Structs::SimpleStruct::Type c; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type; @@ -36965,9 +37036,9 @@ struct Type DataModel::List f; DataModel::List g; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -36998,9 +37069,9 @@ struct Type public: DataModel::List a; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; struct DecodableType @@ -37025,7 +37096,6 @@ struct Type public: chip::FabricIndex fabricIndex = static_cast(0); - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = true; @@ -37033,6 +37103,12 @@ struct Type auto GetFabricIndex() const { return fabricIndex; } void SetFabricIndex(chip::FabricIndex fabricIndex_) { fabricIndex = fabricIndex_; } + + CHIP_ERROR EncodeForWrite(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR EncodeForRead(TLV::TLVWriter & writer, TLV::Tag tag, FabricIndex accessingFabricIndex) const; + +private: + CHIP_ERROR DoEncode(TLV::TLVWriter & writer, TLV::Tag tag, const Optional & accessingFabricIndex) const; }; using DecodableType = Type; @@ -37051,10 +37127,11 @@ struct Type uint64_t fabricIndex = static_cast(0); chip::ByteSpan operationalCert; - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; using DecodableType = Type;