From 564283353a2c0d2b5a1adce370ec61b8741e1de9 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 9 Feb 2023 11:20:11 +0100 Subject: [PATCH] Remove AttributeWritePermission from types-silabs.xml and makes it a not generated enum (#24926) --- src/app/common/templates/weak-enum-list.yaml | 1 - src/app/util/attribute-metadata.h | 11 +++++++++++ src/app/util/attribute-table.cpp | 8 ++++---- src/app/util/generic-callback-stubs.cpp | 2 +- .../zcl/data-model/silabs/types-silabs.xml | 9 --------- .../app-common/app-common/zap-generated/enums.h | 12 ------------ 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/app/common/templates/weak-enum-list.yaml b/src/app/common/templates/weak-enum-list.yaml index 515e30bde00831..06501dff5f4f0c 100644 --- a/src/app/common/templates/weak-enum-list.yaml +++ b/src/app/common/templates/weak-enum-list.yaml @@ -1,6 +1,5 @@ # Allow-list of enums that we generate as enums, not enum classes. The goal is # to drive this down to 0. -- AttributeWritePermission - BarrierControlBarrierPosition - BarrierControlMovingState - ColorControlOptions diff --git a/src/app/util/attribute-metadata.h b/src/app/util/attribute-metadata.h index 0f9c9b26258758..f957e51c0ad14a 100644 --- a/src/app/util/attribute-metadata.h +++ b/src/app/util/attribute-metadata.h @@ -105,6 +105,17 @@ union EmberAfDefaultOrMinMaxAttributeValue const EmberAfAttributeMinMaxValue * ptrToMinMaxValue; }; +enum class EmberAfAttributeWritePermission +{ + DenyWrite = 0, + AllowWriteNormal = 1, + AllowWriteOfReadOnly = 2, + UnsupportedAttribute = 0x86, // Protocols::InteractionModel::Status::UnsupportedAttribute + InvalidValue = 0x87, // Protocols::InteractionModel::Status::ConstraintError + ReadOnly = 0x88, // Protocols::InteractionModel::Status::UnsupportedWrite + InvalidDataType = 0x8d, // Protocols::InteractionModel::Status::InvalidDataType +}; + // Attribute masks modify how attributes are used by the framework // // Attribute that has this mask is NOT read-only diff --git a/src/app/util/attribute-table.cpp b/src/app/util/attribute-table.cpp index 6e4106ead2d02d..8cbb47e5b70d77 100644 --- a/src/app/util/attribute-table.cpp +++ b/src/app/util/attribute-table.cpp @@ -48,12 +48,12 @@ EmberAfStatus emberAfWriteAttributeExternal(EndpointId endpoint, ClusterId clust emberAfAllowNetworkWriteAttributeCallback(endpoint, cluster, attributeID, dataPtr, dataType); switch (extWritePermission) { - case EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_DENY_WRITE: + case EmberAfAttributeWritePermission::DenyWrite: return EMBER_ZCL_STATUS_FAILURE; - case EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL: - case EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_OF_READ_ONLY: + case EmberAfAttributeWritePermission::AllowWriteNormal: + case EmberAfAttributeWritePermission::AllowWriteOfReadOnly: return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, - (extWritePermission == EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_OF_READ_ONLY), false); + (extWritePermission == EmberAfAttributeWritePermission::AllowWriteOfReadOnly), false); default: return (EmberAfStatus) extWritePermission; } diff --git a/src/app/util/generic-callback-stubs.cpp b/src/app/util/generic-callback-stubs.cpp index ba8ee45b766ed5..c9c332b71fc1bd 100644 --- a/src/app/util/generic-callback-stubs.cpp +++ b/src/app/util/generic-callback-stubs.cpp @@ -28,7 +28,7 @@ EmberAfAttributeWritePermission __attribute__((weak)) emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t * value, uint8_t type) { - return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default + return EmberAfAttributeWritePermission::AllowWriteNormal; // Default } bool __attribute__((weak)) emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) diff --git a/src/app/zap-templates/zcl/data-model/silabs/types-silabs.xml b/src/app/zap-templates/zcl/data-model/silabs/types-silabs.xml index 2ba27133278bcd..7b3cdee16e6ed9 100644 --- a/src/app/zap-templates/zcl/data-model/silabs/types-silabs.xml +++ b/src/app/zap-templates/zcl/data-model/silabs/types-silabs.xml @@ -23,15 +23,6 @@ limitations under the License. - - - - - - - - - diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index 2e20556e1826d9..1492f34440ce89 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -24,18 +24,6 @@ // ZCL enums -// Enum for AttributeWritePermission -enum EmberAfAttributeWritePermission : uint8_t -{ - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_DENY_WRITE = 0, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL = 1, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_OF_READ_ONLY = 2, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_UNSUPPORTED_ATTRIBUTE = 134, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_INVALID_VALUE = 135, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_READ_ONLY = 136, - EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_INVALID_DATA_TYPE = 141, -}; - // Enum for BarrierControlBarrierPosition enum EmberAfBarrierControlBarrierPosition : uint8_t {