From 11547118719052976cdd9b11b4a9b0d2848e9fca Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 13 Sep 2023 07:48:19 -0400 Subject: [PATCH] Remove last remaining non-enum-class bitmaps that we codegen. (#29193) --- .../all-clusters-app.matter | 11 +++++++++++ .../barrier-control-server.cpp | 5 +++-- src/app/common/templates/config-data.yaml | 6 ------ src/app/zap-templates/templates/app/enums.zapt | 9 --------- .../draft/barrier-control-cluster.xml | 2 ++ .../data_model/controller-clusters.matter | 11 +++++++++++ src/controller/python/chip/clusters/Objects.py | 10 ++++++++++ .../Framework/CHIP/templates/availability.yaml | 5 +++++ .../CHIP/zap-generated/MTRBaseClusters.h | 11 +++++++++++ .../app-common/zap-generated/cluster-enums.h | 18 +++++++++++++++++- .../app-common/zap-generated/enums.h | 11 ----------- 11 files changed, 70 insertions(+), 29 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index f8619b6f400a60..f42f02a87f8a82 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -3925,6 +3925,17 @@ server cluster WindowCovering = 258 { /** This cluster provides control of a barrier (garage door). */ server cluster BarrierControl = 259 { + bitmap BarrierControlCapabilities : BITMAP8 { + kPartialBarrier = 0x1; + } + + bitmap BarrierControlSafetyStatus : BITMAP16 { + kRemoteLockout = 0x1; + kTemperDetected = 0x2; + kFailedCommunication = 0x4; + kPositionFailure = 0x8; + } + readonly attribute enum8 barrierMovingState = 1; readonly attribute bitmap16 barrierSafetyStatus = 2; readonly attribute bitmap8 barrierCapabilities = 3; diff --git a/src/app/clusters/barrier-control-server/barrier-control-server.cpp b/src/app/clusters/barrier-control-server/barrier-control-server.cpp index 645fc943078355..6cd4998d8aba4a 100644 --- a/src/app/clusters/barrier-control-server/barrier-control-server.cpp +++ b/src/app/clusters/barrier-control-server/barrier-control-server.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -99,7 +100,7 @@ bool emAfPluginBarrierControlServerIsPartialBarrierSupported(EndpointId endpoint uint8_t bitmap; EmberAfStatus status = Attributes::BarrierCapabilities::Get(endpoint, &bitmap); assert(status == EMBER_ZCL_STATUS_SUCCESS); - return READBITS(bitmap, EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER); + return (bitmap & to_underlying(BarrierControlCapabilities::kPartialBarrier)) != 0; } static uint16_t getOpenOrClosePeriod(EndpointId endpoint, bool open) @@ -139,7 +140,7 @@ uint16_t emAfPluginBarrierControlServerGetSafetyStatus(EndpointId endpoint) static bool isRemoteLockoutOn(EndpointId endpoint) { uint16_t safetyStatus = emAfPluginBarrierControlServerGetSafetyStatus(endpoint); - return READBITS(safetyStatus, EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_REMOTE_LOCKOUT); + return (safetyStatus & to_underlying(BarrierControlSafetyStatus::kRemoteLockout)) != 0; } void emAfPluginBarrierControlServerIncrementEvents(EndpointId endpoint, bool open, bool command) diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 601d3f13f613fd..aa59f199cf1d55 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -12,12 +12,6 @@ WeakEnums: - RadioFaultEnum - StepMode -DefineBitmaps: - # Allow-list of bitmaps that we generates as #define as well as enum classes. - # The goal is to drive this down to 0. - - BarrierControlCapabilities - - BarrierControlSafetyStatus - CommandHandlerInterfaceOnlyClusters: # List of clusters that are implemented entirely with # CommandHandlerInterface and hence do not need generated command dispatch. diff --git a/src/app/zap-templates/templates/app/enums.zapt b/src/app/zap-templates/templates/app/enums.zapt index 71b2d32ad75066..d0e95a7df2b75f 100644 --- a/src/app/zap-templates/templates/app/enums.zapt +++ b/src/app/zap-templates/templates/app/enums.zapt @@ -18,12 +18,3 @@ enum EmberAf{{asType label}} : {{asUnderlyingZclType name}} { }; {{/if}} {{/zcl_enums}} - -{{#zcl_bitmaps}} -{{#if (isInConfigList label "DefineBitmaps")}} -{{#zcl_bitmap_items}} -#define EMBER_AF_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}} ({{mask}}) -#define EMBER_AF_{{asDelimitedMacro parent.label}}_{{asDelimitedMacro label}}_OFFSET ({{asOffset mask}}) -{{/zcl_bitmap_items}} -{{/if}} -{{/zcl_bitmaps}} diff --git a/src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml b/src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml index 08eda3b79ded15..d807b23d1f2528 100644 --- a/src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml @@ -18,10 +18,12 @@ limitations under the License. + + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index d2b7233e62c5ed..eb2e77f0a5ac96 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4344,6 +4344,17 @@ client cluster WindowCovering = 258 { /** This cluster provides control of a barrier (garage door). */ client cluster BarrierControl = 259 { + bitmap BarrierControlCapabilities : BITMAP8 { + kPartialBarrier = 0x1; + } + + bitmap BarrierControlSafetyStatus : BITMAP16 { + kRemoteLockout = 0x1; + kTemperDetected = 0x2; + kFailedCommunication = 0x4; + kPositionFailure = 0x8; + } + readonly attribute enum8 barrierMovingState = 1; readonly attribute bitmap16 barrierSafetyStatus = 2; readonly attribute bitmap8 barrierCapabilities = 3; diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 8012a493d3db29..0939509b6f47fd 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -22316,6 +22316,16 @@ def descriptor(cls) -> ClusterObjectDescriptor: featureMap: 'uint' = None clusterRevision: 'uint' = None + class Bitmaps: + class BarrierControlCapabilities(IntFlag): + kPartialBarrier = 0x1 + + class BarrierControlSafetyStatus(IntFlag): + kRemoteLockout = 0x1 + kTemperDetected = 0x2 + kFailedCommunication = 0x4 + kPositionFailure = 0x8 + class Commands: @dataclass class BarrierControlGoToPercent(ClusterCommand): diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 3e23efcf1dbc43..6406a6a666a9e7 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -7686,3 +7686,8 @@ - release: "Future" versions: "future" + provisional: + bitmaps: + BarrierControl: + - BarrierControlCapabilities + - BarrierControlSafetyStatus diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 3afa8df46adf40..8c3d082798aa46 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -27616,6 +27616,17 @@ typedef NS_OPTIONS(uint16_t, MTRWindowCoveringSafetyStatus) { MTRWindowCoveringSafetyStatusProtection API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x800, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_OPTIONS(uint8_t, MTRBarrierControlCapabilities) { + MTRBarrierControlCapabilitiesPartialBarrier MTR_PROVISIONALLY_AVAILABLE = 0x1, +} MTR_PROVISIONALLY_AVAILABLE; + +typedef NS_OPTIONS(uint16_t, MTRBarrierControlSafetyStatus) { + MTRBarrierControlSafetyStatusRemoteLockout MTR_PROVISIONALLY_AVAILABLE = 0x1, + MTRBarrierControlSafetyStatusTemperDetected MTR_PROVISIONALLY_AVAILABLE = 0x2, + MTRBarrierControlSafetyStatusFailedCommunication MTR_PROVISIONALLY_AVAILABLE = 0x4, + MTRBarrierControlSafetyStatusPositionFailure MTR_PROVISIONALLY_AVAILABLE = 0x8, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRPumpConfigurationAndControlControlMode) { MTRPumpConfigurationAndControlControlModeConstantSpeed API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) = 0x00, MTRPumpConfigurationAndControlControlModeConstantPressure API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 60f0c614cb7118..ba288e2a87d987 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -2612,7 +2612,23 @@ enum class SafetyStatus : uint16_t }; } // namespace WindowCovering -namespace BarrierControl {} // namespace BarrierControl +namespace BarrierControl { + +// Bitmap for BarrierControlCapabilities +enum class BarrierControlCapabilities : uint8_t +{ + kPartialBarrier = 0x1, +}; + +// Bitmap for BarrierControlSafetyStatus +enum class BarrierControlSafetyStatus : uint16_t +{ + kRemoteLockout = 0x1, + kTemperDetected = 0x2, + kFailedCommunication = 0x4, + kPositionFailure = 0x8, +}; +} // namespace BarrierControl namespace PumpConfigurationAndControl { 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 2152ee8e992212..7d30ac54349ac7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -113,14 +113,3 @@ enum EmberAfStepMode : uint8_t EMBER_ZCL_STEP_MODE_UP = 0, EMBER_ZCL_STEP_MODE_DOWN = 1, }; - -#define EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER (1) -#define EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER_OFFSET (0) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_REMOTE_LOCKOUT (1) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_REMOTE_LOCKOUT_OFFSET (0) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_TEMPER_DETECTED (2) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_TEMPER_DETECTED_OFFSET (1) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_FAILED_COMMUNICATION (4) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_FAILED_COMMUNICATION_OFFSET (2) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_POSITION_FAILURE (8) -#define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_POSITION_FAILURE_OFFSET (3)