From 1693744c9fe62149122c252d8df1930b492909ea Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 5 Jan 2022 17:27:33 -0800 Subject: [PATCH] Add missing parts in Localization Configuration cluster (#13322) * Add missing parts in Localization Configuration cluster * Run codegen --- .../localization-configuration-cluster.xml | 13 +++---- .../python/chip/clusters/Objects.py | 36 +++++++++++++++++++ .../app-common/zap-generated/attribute-id.h | 2 ++ .../zap-generated/attributes/Accessors.cpp | 32 +++++++++++++++++ .../zap-generated/attributes/Accessors.h | 5 +++ .../zap-generated/cluster-objects.cpp | 6 ++++ .../zap-generated/cluster-objects.h | 26 ++++++++++++++ .../app-common/zap-generated/ids/Attributes.h | 8 +++++ 8 files changed, 120 insertions(+), 8 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml index 5dc456c7d2f168..0365a576485b45 100644 --- a/src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml @@ -16,8 +16,6 @@ limitations under the License. --> - - General Localization Configuration @@ -26,12 +24,11 @@ limitations under the License. true true Nodes should be expected to be deployed to any and all regions of the world. These global regions -may have differing common languages, units of measurements, and numerical formatting -standards. As such, Nodes that visually or audibly convey information need a mechanism by which -they can be configured to use a user’s preferred language, units, etc + may have differing common languages, units of measurements, and numerical formatting + standards. As such, Nodes that visually or audibly convey information need a mechanism by which + they can be configured to use a user’s preferred language, units, etc - - - + ActiveLocale + SupportedLocales diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 3cf2286c7811c7..c4e864f8d31322 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -6989,11 +6989,15 @@ class LocalizationConfiguration(Cluster): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ + ClusterObjectFieldDescriptor(Label="activeLocale", Tag=0x00000001, Type=str), + ClusterObjectFieldDescriptor(Label="supportedLocales", Tag=0x00000002, Type=typing.List[str]), ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), ]) + activeLocale: 'str' = None + supportedLocales: 'typing.List[str]' = None attributeList: 'typing.List[uint]' = None featureMap: 'typing.Optional[uint]' = None clusterRevision: 'uint' = None @@ -7002,6 +7006,38 @@ def descriptor(cls) -> ClusterObjectDescriptor: class Attributes: + @dataclass + class ActiveLocale(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002B + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=str) + + value: 'str' = "" + + @dataclass + class SupportedLocales(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002B + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.List[str]) + + value: 'typing.List[str]' = field(default_factory=lambda: []) + @dataclass class AttributeList(ClusterAttributeDescriptor): @ChipUtility.classproperty diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h index afc4f8ff51c769..1ffdf799e54ce5 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h @@ -327,6 +327,8 @@ // Client attributes // Server attributes +#define ZCL_ACTIVE_LOCALE_ATTRIBUTE_ID (0x0001) +#define ZCL_SUPPORTED_LOCALES_ATTRIBUTE_ID (0x0002) // Attribute ids for cluster: Localization Time Format diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 7c2f4dfc21a3fb..3d5a9ae4952b40 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -6431,6 +6431,38 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace LocalizationConfiguration { namespace Attributes { +namespace ActiveLocale { + +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value) +{ + uint8_t zclString[35 + 1]; + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, sizeof(zclString)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + size_t length = emberAfStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + + VerifyOrReturnError(value.size() == 35, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[1], 35); + value.reduce_size(length); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) +{ + static_assert(35 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 35, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[35 + 1]; + emberAfCopyInt8u(zclString, 0, static_cast(value.size())); + memcpy(&zclString[1], value.data(), value.size()); + return emberAfWriteServerAttribute(endpoint, Clusters::LocalizationConfiguration::Id, Id, zclString, + ZCL_CHAR_STRING_ATTRIBUTE_TYPE); +} + +} // namespace ActiveLocale + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index f61ee2fda728e0..0ce1351af9c40e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1169,6 +1169,11 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace LocalizationConfiguration { namespace Attributes { +namespace ActiveLocale { +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan value); // char_string +EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); +} // namespace ActiveLocale + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); 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 8695d79361b94b..fb89826bc8c921 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 @@ -6322,6 +6322,12 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre { switch (path.mAttributeId) { + case Attributes::ActiveLocale::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, activeLocale)); + break; + case Attributes::SupportedLocales::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, supportedLocales)); + break; case Attributes::AttributeList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, attributeList)); break; 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 f46d1b5607e29d..ce2838c525fd5b 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 @@ -8807,6 +8807,30 @@ namespace LocalizationConfiguration { namespace Attributes { +namespace ActiveLocale { +struct TypeInfo +{ + using Type = chip::CharSpan; + using DecodableType = chip::CharSpan; + using DecodableArgType = chip::CharSpan; + + static constexpr ClusterId GetClusterId() { return Clusters::LocalizationConfiguration::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ActiveLocale::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace ActiveLocale +namespace SupportedLocales { +struct TypeInfo +{ + using Type = chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList; + using DecodableArgType = const chip::app::DataModel::DecodableList &; + + static constexpr ClusterId GetClusterId() { return Clusters::LocalizationConfiguration::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::SupportedLocales::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace SupportedLocales namespace AttributeList { struct TypeInfo { @@ -8852,6 +8876,8 @@ struct TypeInfo CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); + Attributes::ActiveLocale::TypeInfo::DecodableType activeLocale; + Attributes::SupportedLocales::TypeInfo::DecodableType supportedLocales; Attributes::AttributeList::TypeInfo::DecodableType attributeList; Attributes::FeatureMap::TypeInfo::DecodableType featureMap; Attributes::ClusterRevision::TypeInfo::DecodableType clusterRevision; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index bfb90cd718b185..d68608b0479683 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -1094,6 +1094,14 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; namespace LocalizationConfiguration { namespace Attributes { +namespace ActiveLocale { +static constexpr AttributeId Id = 0x00000001; +} // namespace ActiveLocale + +namespace SupportedLocales { +static constexpr AttributeId Id = 0x00000002; +} // namespace SupportedLocales + namespace AttributeList { static constexpr AttributeId Id = Globals::Attributes::AttributeList::Id; } // namespace AttributeList