From 07717433d40b71a450734ad13d5a33dfafc9a71d Mon Sep 17 00:00:00 2001 From: Oliver Fan Date: Tue, 30 Jul 2024 22:48:36 -0700 Subject: [PATCH 1/8] [occupancy-sensing]Follow up improvements for Occupancy Sensing Cluster updates for Matter 1.4 * Apply follow-up suggestions from review PR#34293 * Make HoldTime attribute writable * Fix array index mapping issue reported from PR#34593 in occupancy-sensing-stub.cpp Signed-off-by: Oliver Fan --- .../src/occupancy-sensing-stub.cpp | 51 +++++++++++++------ .../occupancy-sensor-server.cpp | 35 +++++++++++-- .../occupancy-sensor-server.h | 8 +-- .../zcl/zcl-with-test-extensions.json | 6 ++- src/app/zap-templates/zcl/zcl.json | 6 ++- 5 files changed, 81 insertions(+), 25 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp index dcbb90ff659bcb..9c56bd1ed71ff0 100644 --- a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include using namespace chip; @@ -28,30 +29,48 @@ using namespace chip::DeviceLayer; using chip::Protocols::InteractionModel::Status; -static std::unique_ptr - gAttrAccess[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; +namespace { + +static constexpr size_t kOccupancySensingClusterTableSize = + MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; + +static_assert(kOccupancySensingClusterTableSize <= kEmberInvalidEndpointIndex, "Occupancy Sensing Cluster table size error"); + +static std::unique_ptr + gOccupancySensingClusterInstances[kOccupancySensingClusterTableSize]; + +} //namespace void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) { - VerifyOrDie(!gAttrAccess[endpointId]); + uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, chip::app::Clusters::OccupancySensing::Id, + MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT); - gAttrAccess[endpointId] = std::make_unique( - BitMask(OccupancySensing::Feature::kOther)); + if (epIndex < kOccupancySensingClusterTableSize) + { + VerifyOrDie(!gOccupancySensingClusterInstances[epIndex]); - OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { - .holdTimeMin = 1, - .holdTimeMax = 300, - .holdTimeDefault = 10, - }; + gOccupancySensingClusterInstances[epIndex] = std::make_unique( + BitMask(OccupancySensing::Feature::kOther)); - uint16_t holdTime = 10; + OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { + .holdTimeMin = 1, + .holdTimeMax = 300, + .holdTimeDefault = 10, + }; - if (gAttrAccess[endpointId]) - { - gAttrAccess[endpointId]->Init(); + uint16_t holdTime = 10; + + if (gOccupancySensingClusterInstances[epIndex]) + { + gOccupancySensingClusterInstances[epIndex]->Init(); - SetHoldTimeLimits(endpointId, holdTimeLimits); + SetHoldTimeLimits(endpointId, holdTimeLimits); - SetHoldTime(endpointId, holdTime); + SetHoldTime(endpointId, holdTime); + } + } + else + { } } diff --git a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp index 4a3ba4103a0b0d..04d2908986e0a2 100644 --- a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp +++ b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp @@ -39,18 +39,18 @@ Structs::HoldTimeLimitsStruct::Type uint16_t sHoldTime[MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; } // namespace -CHIP_ERROR OccupancySensingAttrAccess::Init() +CHIP_ERROR Instance::Init() { VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } -void OccupancySensingAttrAccess::Shutdown() +void Instance::Shutdown() { unregisterAttributeAccessOverride(this); } -CHIP_ERROR OccupancySensingAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) { VerifyOrDie(aPath.mClusterId == app::Clusters::OccupancySensing::Id); @@ -88,7 +88,34 @@ CHIP_ERROR OccupancySensingAttrAccess::Read(const ConcreteReadAttributePath & aP return CHIP_NO_ERROR; } -bool OccupancySensingAttrAccess::HasFeature(Feature aFeature) const +CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) +{ + VerifyOrDie(aPath.mClusterId == app::Clusters::OccupancySensing::Id); + + switch (aPath.mAttributeId) + { + case Attributes::HoldTime::Id: { + + uint16_t newHoldTime; + + ReturnErrorOnFailure(aDecoder.Decode(newHoldTime)); + + Structs::HoldTimeLimitsStruct::Type * currHoldTimeLimits = GetHoldTimeLimitsForEndpoint(aPath.mEndpointId); + VerifyOrReturnError(currHoldTimeLimits != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(newHoldTime >= currHoldTimeLimits->holdTimeMin, CHIP_IM_GLOBAL_STATUS(ConstraintError)); + VerifyOrReturnError(newHoldTime <= currHoldTimeLimits->holdTimeMax, CHIP_IM_GLOBAL_STATUS(ConstraintError)); + + return SetHoldTime(aPath.mEndpointId, newHoldTime); + } + default: { + break; + } + } + + return CHIP_NO_ERROR; +} + +bool Instance::HasFeature(Feature aFeature) const { return mFeature.Has(aFeature); } diff --git a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.h b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.h index f24c64f4dbfbb1..c4c7181b626f3a 100644 --- a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.h +++ b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.h @@ -30,20 +30,22 @@ namespace app { namespace Clusters { namespace OccupancySensing { -class OccupancySensingAttrAccess : public AttributeAccessInterface +class Instance : public AttributeAccessInterface { public: - OccupancySensingAttrAccess(BitMask aFeature) : + Instance(BitMask aFeature) : app::AttributeAccessInterface(Optional::Missing(), app::Clusters::OccupancySensing::Id), mFeature(aFeature) {} - ~OccupancySensingAttrAccess() { Shutdown(); } + ~Instance() { Shutdown(); } CHIP_ERROR Init(); void Shutdown(); CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; + bool HasFeature(Feature aFeature) const; private: diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 4c5a59200e7d49..a7124c8d828fcc 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -282,7 +282,11 @@ "ClientsSupportedPerFabric", "MaximumCheckInBackOff" ], - "Occupancy Sensing": ["HoldTimeLimits"], + "Occupancy Sensing": [ + "HoldTimeLimits", + "HoldTime", + "FeatureMap" + ], "Operational Credentials": [ "SupportedFabrics", "CommissionedFabrics", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 777847fb7f06ad..4ed7631731d3c9 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -280,7 +280,11 @@ "ClientsSupportedPerFabric", "MaximumCheckInBackOff" ], - "Occupancy Sensing": ["HoldTimeLimits"], + "Occupancy Sensing": [ + "HoldTimeLimits", + "HoldTime", + "FeatureMap" + ], "Operational Credentials": [ "SupportedFabrics", "CommissionedFabrics", From 21f9f6512b5a63a695bcddbe59464b95036f80ce Mon Sep 17 00:00:00 2001 From: Oliver Fan Date: Tue, 30 Jul 2024 23:23:17 -0700 Subject: [PATCH 2/8] Regen ZAP after adding FeatureMap and HoldTime to zcl.json and zcl-with-test-extensions.json file for Occupancy Sensing cluster Signed-off-by: Oliver Fan --- .../all-clusters-app.matter | 8 +- .../all-clusters-minimal-app.matter | 4 +- ...rootnode_occupancysensor_iHyVgifZuo.matter | 2 +- .../contact-sensor-app.matter | 2 +- .../lighting-common/lighting-app.matter | 2 +- .../placeholder/linux/apps/app1/config.matter | 2 +- .../placeholder/linux/apps/app2/config.matter | 2 +- .../app-templates/endpoint_config.h | 28 +++--- .../app-templates/endpoint_config.h | 16 ++-- .../zap-generated/attributes/Accessors.cpp | 92 ------------------- .../zap-generated/attributes/Accessors.h | 12 --- 11 files changed, 33 insertions(+), 137 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 dc2d6fe75a3e82..9469bf83fcec47 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 @@ -8998,9 +8998,9 @@ endpoint 1 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute holdTime default = 10; + callback attribute holdTime; callback attribute holdTimeLimits; - ram attribute featureMap default = 0x01; + callback attribute featureMap; ram attribute clusterRevision default = 5; } @@ -9469,9 +9469,9 @@ endpoint 2 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute holdTime default = 20; + callback attribute holdTime; callback attribute holdTimeLimits; - ram attribute featureMap default = 0x01; + callback attribute featureMap; ram attribute clusterRevision default = 5; } } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 8d8811013165b8..6bf552637ab797 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -6682,7 +6682,7 @@ endpoint 1 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute featureMap default = 0; + callback attribute featureMap; ram attribute clusterRevision default = 4; } @@ -7029,7 +7029,7 @@ endpoint 2 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute featureMap default = 0; + callback attribute featureMap; ram attribute clusterRevision default = 4; } } diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 3a1a98807efe29..2dcdc9c07ae4b0 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -1716,7 +1716,7 @@ endpoint 1 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0; + callback attribute featureMap; ram attribute clusterRevision default = 2; } } diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index ed76b4fe052c54..97d385543b5fc8 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -2153,7 +2153,7 @@ endpoint 1 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute featureMap default = 0; + callback attribute featureMap; ram attribute clusterRevision default = 4; } } diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 1ef35f4d106c73..13ee1b09a00efb 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -2977,7 +2977,7 @@ endpoint 1 { ram attribute occupancy; ram attribute occupancySensorType; ram attribute occupancySensorTypeBitmap; - ram attribute featureMap default = 0; + callback attribute featureMap; ram attribute clusterRevision default = 4; } } diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 721a1be46b1540..844af883d992cd 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -9362,7 +9362,7 @@ endpoint 1 { ram attribute physicalContactOccupiedToUnoccupiedDelay default = 0x00; ram attribute physicalContactUnoccupiedToOccupiedDelay default = 0x00; ram attribute physicalContactUnoccupiedToOccupiedThreshold default = 1; - ram attribute featureMap default = 0; + callback attribute featureMap; callback attribute clusterRevision default = 4; } } diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 8b6f16cd07c5d0..826bd9a157136b 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -9301,7 +9301,7 @@ endpoint 1 { ram attribute physicalContactOccupiedToUnoccupiedDelay default = 0x00; ram attribute physicalContactUnoccupiedToOccupiedDelay default = 0x00; ram attribute physicalContactUnoccupiedToOccupiedThreshold default = 1; - ram attribute featureMap default = 0; + callback attribute featureMap; callback attribute clusterRevision default = 4; } } diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index c60950077fb372..45e0b16faffc75 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -1576,11 +1576,11 @@ { ZAP_SIMPLE_DEFAULT(3), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Occupancy Sensing (server) */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ - { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ - { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \ + { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Carbon Monoxide Concentration Measurement (server) */ \ { ZAP_EMPTY_DEFAULT(), 0x00000000, 4, ZAP_TYPE(SINGLE), \ @@ -2017,11 +2017,11 @@ { ZAP_SIMPLE_DEFAULT(1), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 2, Cluster: Occupancy Sensing (server) */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ - { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ - { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \ + { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 65534, Cluster: Descriptor (server) */ \ { ZAP_EMPTY_DEFAULT(), 0x00000000, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* DeviceTypeList */ \ @@ -3879,7 +3879,7 @@ .clusterId = 0x00000406, \ .attributes = ZAP_ATTRIBUTE_INDEX(762), \ .attributeCount = 5, \ - .clusterSize = 9, \ + .clusterSize = 5, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayOccupancySensingServer, \ .acceptedCommandList = nullptr, \ @@ -4152,7 +4152,7 @@ .clusterId = 0x00000406, \ .attributes = ZAP_ATTRIBUTE_INDEX(1034), \ .attributeCount = 5, \ - .clusterSize = 9, \ + .clusterSize = 5, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayOccupancySensingServer, \ .acceptedCommandList = nullptr, \ @@ -4195,7 +4195,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 29, 349 }, { ZAP_CLUSTER_INDEX(29), 74, 3522 }, { ZAP_CLUSTER_INDEX(103), 7, 126 }, \ + { ZAP_CLUSTER_INDEX(0), 29, 349 }, { ZAP_CLUSTER_INDEX(29), 74, 3518 }, { ZAP_CLUSTER_INDEX(103), 7, 122 }, \ { ZAP_CLUSTER_INDEX(110), 2, 0 }, \ } @@ -4208,7 +4208,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (36) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (3997) +#define ATTRIBUTE_MAX_SIZE (3989) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) diff --git a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h index ab7e45dab37b66..8695ffc341d879 100644 --- a/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/lighting-app/app-templates/endpoint_config.h @@ -536,11 +536,11 @@ { ZAP_SIMPLE_DEFAULT(7), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Occupancy Sensing (server) */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ - { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ - { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000000, 1, ZAP_TYPE(BITMAP8), 0 }, /* Occupancy */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(ENUM8), 0 }, /* OccupancySensorType */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000002, 1, ZAP_TYPE(BITMAP8), 0 }, /* OccupancySensorTypeBitmap */ \ + { ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \ + { ZAP_SIMPLE_DEFAULT(4), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ } // clang-format off @@ -1170,7 +1170,7 @@ .clusterId = 0x00000406, \ .attributes = ZAP_ATTRIBUTE_INDEX(271), \ .attributeCount = 5, \ - .clusterSize = 9, \ + .clusterSize = 5, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayOccupancySensingServer, \ .acceptedCommandList = nullptr, \ @@ -1187,7 +1187,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 21, 223 }, { ZAP_CLUSTER_INDEX(21), 8, 121 }, \ + { ZAP_CLUSTER_INDEX(0), 21, 223 }, { ZAP_CLUSTER_INDEX(21), 8, 117 }, \ } // Largest attribute size is needed for various buffers @@ -1199,7 +1199,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (36) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (344) +#define ATTRIBUTE_MAX_SIZE (340) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) 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 81744d5c6994ff..01dff1b9f6cc47 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 @@ -33945,52 +33945,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, } // namespace OccupancySensorTypeBitmap -namespace HoldTime { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::OccupancySensing::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OccupancySensing::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OccupancySensing::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace HoldTime - namespace PIROccupiedToUnoccupiedDelay { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value) @@ -34405,52 +34359,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value } // namespace PhysicalContactUnoccupiedToOccupiedThreshold -namespace FeatureMap { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::OccupancySensing::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OccupancySensing::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::OccupancySensing::Id, Id, writable, ZCL_BITMAP32_ATTRIBUTE_TYPE); -} - -} // namespace FeatureMap - namespace ClusterRevision { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_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 cd73287e99b4ca..bd606488722011 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 @@ -5190,12 +5190,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, MarkAttributeDirty markDirty); } // namespace OccupancySensorTypeBitmap -namespace HoldTime { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // int16u -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty); -} // namespace HoldTime - namespace PIROccupiedToUnoccupiedDelay { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // int16u Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); @@ -5250,12 +5244,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); } // namespace PhysicalContactUnoccupiedToOccupiedThreshold -namespace FeatureMap { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value, MarkAttributeDirty markDirty); -} // namespace FeatureMap - namespace ClusterRevision { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // int16u Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); From 0795773d50120dee35e96064b138a89db556658a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 31 Jul 2024 06:23:49 +0000 Subject: [PATCH 3/8] Restyled by clang-format --- .../all-clusters-common/src/occupancy-sensing-stub.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp index 9c56bd1ed71ff0..b700f03ac15c84 100644 --- a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp @@ -39,19 +39,19 @@ static_assert(kOccupancySensingClusterTableSize <= kEmberInvalidEndpointIndex, " static std::unique_ptr gOccupancySensingClusterInstances[kOccupancySensingClusterTableSize]; -} //namespace +} // namespace void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) { uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, chip::app::Clusters::OccupancySensing::Id, - MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT); + MATTER_DM_OCCUPANCY_SENSING_CLUSTER_SERVER_ENDPOINT_COUNT); if (epIndex < kOccupancySensingClusterTableSize) { VerifyOrDie(!gOccupancySensingClusterInstances[epIndex]); - gOccupancySensingClusterInstances[epIndex] = std::make_unique( - BitMask(OccupancySensing::Feature::kOther)); + gOccupancySensingClusterInstances[epIndex] = + std::make_unique(BitMask(OccupancySensing::Feature::kOther)); OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { .holdTimeMin = 1, From f33137778213d95e40237926a8c401d2ebccf7c1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 31 Jul 2024 06:23:51 +0000 Subject: [PATCH 4/8] Restyled by prettier-json --- src/app/zap-templates/zcl/zcl-with-test-extensions.json | 6 +----- src/app/zap-templates/zcl/zcl.json | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index a7124c8d828fcc..d75884c9e1201f 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -282,11 +282,7 @@ "ClientsSupportedPerFabric", "MaximumCheckInBackOff" ], - "Occupancy Sensing": [ - "HoldTimeLimits", - "HoldTime", - "FeatureMap" - ], + "Occupancy Sensing": ["HoldTimeLimits", "HoldTime", "FeatureMap"], "Operational Credentials": [ "SupportedFabrics", "CommissionedFabrics", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 4ed7631731d3c9..549e122e475a42 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -280,11 +280,7 @@ "ClientsSupportedPerFabric", "MaximumCheckInBackOff" ], - "Occupancy Sensing": [ - "HoldTimeLimits", - "HoldTime", - "FeatureMap" - ], + "Occupancy Sensing": ["HoldTimeLimits", "HoldTime", "FeatureMap"], "Operational Credentials": [ "SupportedFabrics", "CommissionedFabrics", From a48a08a84519314e0b1207b623b04336cf234e87 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 31 Jul 2024 06:59:42 +0000 Subject: [PATCH 5/8] Restyled by clang-format --- .../all-clusters-common/src/occupancy-sensing-stub.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp index b700f03ac15c84..3523603b9e0363 100644 --- a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp @@ -36,8 +36,7 @@ static constexpr size_t kOccupancySensingClusterTableSize = static_assert(kOccupancySensingClusterTableSize <= kEmberInvalidEndpointIndex, "Occupancy Sensing Cluster table size error"); -static std::unique_ptr - gOccupancySensingClusterInstances[kOccupancySensingClusterTableSize]; +static std::unique_ptr gOccupancySensingClusterInstances[kOccupancySensingClusterTableSize]; } // namespace @@ -50,8 +49,8 @@ void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) { VerifyOrDie(!gOccupancySensingClusterInstances[epIndex]); - gOccupancySensingClusterInstances[epIndex] = - std::make_unique(BitMask(OccupancySensing::Feature::kOther)); + gOccupancySensingClusterInstances[epIndex] = + std::make_unique(BitMask(OccupancySensing::Feature::kOther)); OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { .holdTimeMin = 1, From ff9272d210a1b5a531d69bd44027a8ce6af01f05 Mon Sep 17 00:00:00 2001 From: Oliver Fan Date: Wed, 31 Jul 2024 19:35:14 -0700 Subject: [PATCH 6/8] Add an error print in occupancy-sensing-stub.cpp Signed-off-by: Oliver Fan --- .../all-clusters-common/src/occupancy-sensing-stub.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp index 3523603b9e0363..2720f8fcfbef98 100644 --- a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp @@ -71,5 +71,6 @@ void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) } else { + ChipLogError(AppServer, "Error: invalid/unexpected OccupancySensing Cluster endpoint index."); } } From acd7823b177d7fa97262c6d65a00e5aae347dcee Mon Sep 17 00:00:00 2001 From: Oliver Fan Date: Thu, 1 Aug 2024 00:24:06 -0700 Subject: [PATCH 7/8] Update all-clusters-app.zap for HoldTime and FeatureMap attributes of Occupancy Sensing cluster Signed-off-by: Oliver Fan --- .../all-clusters-common/all-clusters-app.zap | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 31b6a05057dc74..528eae219eae10 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -19004,10 +19004,10 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "10", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -19036,10 +19036,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -25065,10 +25065,10 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "20", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -25097,10 +25097,10 @@ "side": "server", "type": "bitmap32", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -26554,4 +26554,4 @@ "parentEndpointIdentifier": null } ] -} +} \ No newline at end of file From 4695b14459d58ff73d9a34a52ff206fae1a73330 Mon Sep 17 00:00:00 2001 From: Oliver Fan Date: Mon, 5 Aug 2024 19:31:45 -0700 Subject: [PATCH 8/8] Resolve merge conflict in endpoint_config.h Signed-off-by: Oliver Fan --- .../outputs/all-clusters-app/app-templates/endpoint_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index 73b4be701ee97d..bb4e1a77c14f59 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -4200,7 +4200,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 29, 349 }, { ZAP_CLUSTER_INDEX(29), 74, 3521 }, { ZAP_CLUSTER_INDEX(103), 7, 126 }, \ + { ZAP_CLUSTER_INDEX(0), 29, 349 }, { ZAP_CLUSTER_INDEX(29), 74, 3517 }, { ZAP_CLUSTER_INDEX(103), 7, 122 }, \ { ZAP_CLUSTER_INDEX(110), 2, 0 }, \ } @@ -4213,7 +4213,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (36) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (3996) +#define ATTRIBUTE_MAX_SIZE (3988) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4)