From 4c37486c51ee1b96f98a8aedcea30a0da732aec4 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 29 Nov 2021 21:26:26 -0800 Subject: [PATCH] Update General Commissioning cluster to align with the latest spec (#12343) * Update General Commissioning cluster to align with the latest spec * Run codegen --- .../chip/general-commissioning-cluster.xml | 5 +- .../python/chip/clusters/Objects.py | 13 +++-- .../app-common/zap-generated/attribute-id.h | 4 +- .../zap-generated/attributes/Accessors.cpp | 58 +++++++++++++++++++ .../zap-generated/attributes/Accessors.h | 10 ++++ .../zap-generated/cluster-objects.h | 25 ++++---- .../app-common/zap-generated/ids/Attributes.h | 8 +-- 7 files changed, 97 insertions(+), 26 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml index 8b5b3652adcafb..0957d69b704b3a 100644 --- a/src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml @@ -21,6 +21,7 @@ limitations under the License. + @@ -40,8 +41,8 @@ limitations under the License. This cluster is used to set, remove and update fabric information on a commissionee. Breadcrumb BasicCommissioningInfoList - RegulatoryConfigList - LocationCapabilityList + RegulatoryConfig + LocationCapability Arm the persistent fail-safe timer with an expiry time of now + ExpiryLengthSeconds using device clock diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 1fb41413cc819e..be946a135b6d61 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -6525,6 +6525,7 @@ class GeneralCommissioningError(IntEnum): kOk = 0x00 kValueOutsideRange = 0x01 kInvalidAuthentication = 0x02 + kNotCommissioning = 0x03 class RegulatoryLocationType(IntEnum): kIndoor = 0x00 @@ -6695,7 +6696,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.List[GeneralCommissioning.Structs.BasicCommissioningInfoType]' = None @dataclass - class RegulatoryConfigList(ClusterAttributeDescriptor): + class RegulatoryConfig(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x0030 @@ -6706,12 +6707,12 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[typing.List[GeneralCommissioning.Enums.RegulatoryLocationType]]) + return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - value: 'typing.Optional[typing.List[GeneralCommissioning.Enums.RegulatoryLocationType]]' = None + value: 'typing.Optional[uint]' = None @dataclass - class LocationCapabilityList(ClusterAttributeDescriptor): + class LocationCapability(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x0030 @@ -6722,9 +6723,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[typing.List[GeneralCommissioning.Enums.RegulatoryLocationType]]) + return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - value: 'typing.Optional[typing.List[GeneralCommissioning.Enums.RegulatoryLocationType]]' = None + value: 'typing.Optional[uint]' = None @dataclass class FeatureMap(ClusterAttributeDescriptor): 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 f79b7e04b4b590..3420054b90337b 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 @@ -367,8 +367,8 @@ // Server attributes #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0000) #define ZCL_BASICCOMMISSIONINGINFO_LIST_ATTRIBUTE_ID (0x0001) -#define ZCL_REGULATORYCONFIG_LIST_ATTRIBUTE_ID (0x0002) -#define ZCL_LOCATIONCAPABILITY_LIST_ATTRIBUTE_ID (0x0003) +#define ZCL_REGULATORYCONFIG_ATTRIBUTE_ID (0x0002) +#define ZCL_LOCATIONCAPABILITY_ATTRIBUTE_ID (0x0003) // Attribute ids for cluster: Network Commissioning 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 75f8126d7ec313..04e6867ce8887d 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 @@ -5476,6 +5476,64 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) } // namespace Breadcrumb +namespace RegulatoryConfig { + +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +{ + NumericAttributeTraits::StorageType temp; + uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = NumericAttributeTraits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +{ + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + NumericAttributeTraits::StorageType storageValue; + NumericAttributeTraits::WorkingToStorage(value, storageValue); + uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +} // namespace RegulatoryConfig + +namespace LocationCapability { + +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +{ + NumericAttributeTraits::StorageType temp; + uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = NumericAttributeTraits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +{ + if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + NumericAttributeTraits::StorageType storageValue; + NumericAttributeTraits::WorkingToStorage(value, storageValue); + uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteServerAttribute(endpoint, Clusters::GeneralCommissioning::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +} // namespace LocationCapability + } // namespace Attributes } // namespace GeneralCommissioning 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 a637fc51b37221..60ab0babe3e6c2 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 @@ -1059,6 +1059,16 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint64_t * value); // int64u EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); } // namespace Breadcrumb +namespace RegulatoryConfig { +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // enum8 +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +} // namespace RegulatoryConfig + +namespace LocationCapability { +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // enum8 +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +} // namespace LocationCapability + } // namespace Attributes } // namespace GeneralCommissioning 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 ed25803b4b13f8..903b348781c138 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 @@ -7793,6 +7793,7 @@ enum class GeneralCommissioningError : uint8_t kOk = 0x00, kValueOutsideRange = 0x01, kInvalidAuthentication = 0x02, + kNotCommissioning = 0x03, }; // Need to convert consumers to using the new enum classes, so we // don't just have casts all over. @@ -8090,28 +8091,28 @@ struct TypeInfo static constexpr AttributeId GetAttributeId() { return Attributes::BasicCommissioningInfoList::Id; } }; } // namespace BasicCommissioningInfoList -namespace RegulatoryConfigList { +namespace RegulatoryConfig { struct TypeInfo { - using Type = DataModel::List; - using DecodableType = DataModel::DecodableList; - using DecodableArgType = const DataModel::DecodableList &; + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; static constexpr ClusterId GetClusterId() { return Clusters::GeneralCommissioning::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::RegulatoryConfigList::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::RegulatoryConfig::Id; } }; -} // namespace RegulatoryConfigList -namespace LocationCapabilityList { +} // namespace RegulatoryConfig +namespace LocationCapability { struct TypeInfo { - using Type = DataModel::List; - using DecodableType = DataModel::DecodableList; - using DecodableArgType = const DataModel::DecodableList &; + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; static constexpr ClusterId GetClusterId() { return Clusters::GeneralCommissioning::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::LocationCapabilityList::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::LocationCapability::Id; } }; -} // namespace LocationCapabilityList +} // namespace LocationCapability namespace FeatureMap { struct TypeInfo { 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 274616f63e20c2..6d2abd1247bc8e 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 @@ -1146,13 +1146,13 @@ namespace BasicCommissioningInfoList { static constexpr AttributeId Id = 0x00000001; } // namespace BasicCommissioningInfoList -namespace RegulatoryConfigList { +namespace RegulatoryConfig { static constexpr AttributeId Id = 0x00000002; -} // namespace RegulatoryConfigList +} // namespace RegulatoryConfig -namespace LocationCapabilityList { +namespace LocationCapability { static constexpr AttributeId Id = 0x00000003; -} // namespace LocationCapabilityList +} // namespace LocationCapability namespace FeatureMap { static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id;