From 09e830ab4e1f8b730350f9bdc138b8baec108901 Mon Sep 17 00:00:00 2001 From: Jakob Olesen Date: Wed, 15 Feb 2023 10:15:47 +0100 Subject: [PATCH 1/3] Updated Occupancy Cluster XML according to spec --- .../chip/occupancy-sensing-cluster.xml | 26 ++++++++++++-- .../draft/types/occupancy-sensing.xml | 34 ------------------- 2 files changed, 23 insertions(+), 37 deletions(-) delete mode 100644 src/app/zap-templates/zcl/data-model/draft/types/occupancy-sensing.xml diff --git a/src/app/zap-templates/zcl/data-model/chip/occupancy-sensing-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/occupancy-sensing-cluster.xml index 4b0e758e367df8..5b914836672f69 100644 --- a/src/app/zap-templates/zcl/data-model/chip/occupancy-sensing-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/occupancy-sensing-cluster.xml @@ -17,6 +17,26 @@ limitations under the License. + + + + + + + + + + + + + + + + + + + + Occupancy Sensing Measurement & Sensing @@ -29,9 +49,9 @@ limitations under the License. - Occupancy - OccupancySensorType - OccupancySensorTypeBitmap + Occupancy + OccupancySensorType + OccupancySensorTypeBitmap PIROccupiedToUnoccupiedDelay diff --git a/src/app/zap-templates/zcl/data-model/draft/types/occupancy-sensing.xml b/src/app/zap-templates/zcl/data-model/draft/types/occupancy-sensing.xml deleted file mode 100644 index 94478a8d5f96c7..00000000000000 --- a/src/app/zap-templates/zcl/data-model/draft/types/occupancy-sensing.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - From ba3bee941f5089b7c13c55974586fda02b344008 Mon Sep 17 00:00:00 2001 From: Jakob Olesen Date: Wed, 15 Feb 2023 11:07:08 +0100 Subject: [PATCH 2/3] Zap generated files --- .../all-clusters-app.matter | 23 ++- .../all-clusters-minimal-app.matter | 23 ++- ...p_rootnode_dimmablelight_bCwGYSDpoe.matter | 23 ++- .../rootnode_dimmablelight_bCwGYSDpoe.matter | 23 ++- ...rootnode_occupancysensor_iHyVgifZuo.matter | 23 ++- .../rootnode_thermostat_bm3fb8dhYi.matter | 17 +++ .../contact-sensor-app.matter | 23 ++- .../lighting-common/lighting-app.matter | 23 ++- .../placeholder/linux/apps/app1/config.matter | 23 ++- .../placeholder/linux/apps/app2/config.matter | 23 ++- examples/pump-app/pump-common/pump-app.matter | 17 +++ .../data_model/controller-clusters.matter | 23 ++- .../CHIPAttributeTLVValueDecoder.cpp | 6 +- .../python/chip/clusters/Objects.py | 29 +++- .../MTRAttributeTLVValueDecoder.mm | 6 +- .../CHIP/zap-generated/MTRBaseClusters.h | 17 +++ .../CHIP/zap-generated/MTRBaseClusters.mm | 39 ++--- .../CHIP/zap-generated/MTRCallbackBridge.h | 142 ++++++++++++++++++ .../CHIP/zap-generated/MTRCallbackBridge.mm | 96 ++++++++++++ .../zap-generated/attributes/Accessors.cpp | 25 +-- .../zap-generated/attributes/Accessors.h | 16 +- .../zap-generated/cluster-enums-check.h | 15 ++ .../app-common/zap-generated/cluster-enums.h | 31 +++- .../zap-generated/cluster-objects.h | 27 ++-- .../app-common/zap-generated/enums.h | 4 +- .../zap-generated/cluster/Commands.h | 15 +- .../cluster/logging/DataModelLogger.cpp | 6 +- .../chip-tool/zap-generated/test/Commands.h | 16 +- 28 files changed, 644 insertions(+), 110 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 77bdf482b7bd02..821b3302c8761e 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 @@ -3383,9 +3383,26 @@ server cluster RelativeHumidityMeasurement = 1029 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; 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 53df2947052fe9..fa8eb774b57539 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 @@ -2721,9 +2721,26 @@ server cluster RelativeHumidityMeasurement = 1029 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter index 39dac326062d8e..5eebcd1509757c 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter @@ -1378,9 +1378,26 @@ server cluster FixedLabel = 64 { } client cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 76d0a56024b2be..af8655d2ede1bc 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -1244,9 +1244,26 @@ server cluster FixedLabel = 64 { } client cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 2d82830115e825..4b94421c8bc00f 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -1111,9 +1111,26 @@ server cluster FixedLabel = 64 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 5b8e3602c11149..d984f47f0301d6 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -1278,6 +1278,23 @@ client cluster RelativeHumidityMeasurement = 1029 { } client cluster OccupancySensing = 1030 { + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; 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 9543cfeee4783d..844783d83a75e0 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 @@ -1345,9 +1345,26 @@ server cluster BooleanState = 69 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index a1208b971816eb..b350d6881407d0 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -1815,9 +1815,26 @@ server cluster ColorControl = 768 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index ca98aa9c75808f..d1297b2d54d5a5 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -2352,9 +2352,26 @@ server cluster RelativeHumidityMeasurement = 1029 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 16d78286babee9..a3c05f8d0437cd 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -2321,9 +2321,26 @@ server cluster RelativeHumidityMeasurement = 1029 { } server cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index d4db94594ac87f..b24dc3a98b7fdc 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -1280,6 +1280,23 @@ server cluster FlowMeasurement = 1028 { } client cluster OccupancySensing = 1030 { + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index e64cc83db21d9b..a9b594db9971e6 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -3575,9 +3575,26 @@ client cluster RelativeHumidityMeasurement = 1029 { } client cluster OccupancySensing = 1030 { - readonly attribute bitmap8 occupancy = 0; - readonly attribute enum8 occupancySensorType = 1; - readonly attribute bitmap8 occupancySensorTypeBitmap = 2; + enum OccupancySensorTypeEnum : ENUM8 { + kPir = 0; + kUltrasonic = 1; + kPIRAndUltrasonic = 2; + kPhysicalContact = 3; + } + + bitmap OccupancyBitmap : BITMAP8 { + kOccupied = 0x1; + } + + bitmap OccupancySensorTypeBitmap : BITMAP8 { + kPir = 0x1; + kUltrasonic = 0x2; + kPhysicalContact = 0x4; + } + + readonly attribute OccupancyBitmap occupancy = 0; + readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; + readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 79897c40a5f099..c715b5eae0dce5 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -15988,7 +15988,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); + cppValue.Raw(), value); return value; } case Attributes::OccupancySensorType::Id: { @@ -16003,7 +16003,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); + static_cast(cppValue), value); return value; } case Attributes::OccupancySensorTypeBitmap::Id: { @@ -16018,7 +16018,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); + cppValue.Raw(), value); return value; } case Attributes::GeneratedCommandList::Id: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 4ab320dcf7ec65..95420909d786dc 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -23103,7 +23103,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ ClusterObjectFieldDescriptor(Label="occupancy", Tag=0x00000000, Type=uint), - ClusterObjectFieldDescriptor(Label="occupancySensorType", Tag=0x00000001, Type=uint), + ClusterObjectFieldDescriptor(Label="occupancySensorType", Tag=0x00000001, Type=OccupancySensing.Enums.OccupancySensorTypeEnum), ClusterObjectFieldDescriptor(Label="occupancySensorTypeBitmap", Tag=0x00000002, Type=uint), ClusterObjectFieldDescriptor(Label="PIROccupiedToUnoccupiedDelay", Tag=0x00000010, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="PIRUnoccupiedToOccupiedDelay", Tag=0x00000011, Type=typing.Optional[uint]), @@ -23123,7 +23123,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ]) occupancy: 'uint' = None - occupancySensorType: 'uint' = None + occupancySensorType: 'OccupancySensing.Enums.OccupancySensorTypeEnum' = None occupancySensorTypeBitmap: 'uint' = None PIROccupiedToUnoccupiedDelay: 'typing.Optional[uint]' = None PIRUnoccupiedToOccupiedDelay: 'typing.Optional[uint]' = None @@ -23141,6 +23141,27 @@ def descriptor(cls) -> ClusterObjectDescriptor: featureMap: 'uint' = None clusterRevision: 'uint' = None + class Enums: + class OccupancySensorTypeEnum(MatterIntEnum): + kPir = 0x00 + kUltrasonic = 0x01 + kPIRAndUltrasonic = 0x02 + kPhysicalContact = 0x03 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, + + + class Bitmaps: + class OccupancyBitmap(IntFlag): + kOccupied = 0x1 + + class OccupancySensorTypeBitmap(IntFlag): + kPir = 0x1 + kUltrasonic = 0x2 + kPhysicalContact = 0x4 @@ -23174,9 +23195,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=OccupancySensing.Enums.OccupancySensorTypeEnum) - value: 'uint' = 0 + value: 'OccupancySensing.Enums.OccupancySensorTypeEnum' = 0 @dataclass class OccupancySensorTypeBitmap(ClusterAttributeDescriptor): diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index fc061349e30cbc..0ed3d414ea6251 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -13768,7 +13768,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:cppValue.Raw()]; return value; } case Attributes::OccupancySensorType::Id: { @@ -13779,7 +13779,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; return value; } case Attributes::OccupancySensorTypeBitmap::Id: { @@ -13790,7 +13790,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & return nil; } NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + value = [NSNumber numberWithUnsignedChar:cppValue.Raw()]; return value; } case Attributes::PIROccupiedToUnoccupiedDelay::Id: { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c63b75b89ce470..b7730af98b7781 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -21697,6 +21697,23 @@ typedef NS_OPTIONS(uint32_t, MTRPressureMeasurementPressureFeature) { = 0x1, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTROccupancySensingOccupancySensorType) { + MTROccupancySensingOccupancySensorTypePIR MTR_NEWLY_AVAILABLE = 0x00, + MTROccupancySensingOccupancySensorTypeUltrasonic MTR_NEWLY_AVAILABLE = 0x01, + MTROccupancySensingOccupancySensorTypePIRAndUltrasonic MTR_NEWLY_AVAILABLE = 0x02, + MTROccupancySensingOccupancySensorTypePhysicalContact MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; + +typedef NS_OPTIONS(uint8_t, MTROccupancySensingOccupancyBitmap) { + MTROccupancySensingOccupancyBitmapOccupied MTR_NEWLY_AVAILABLE = 0x1, +} MTR_NEWLY_AVAILABLE; + +typedef NS_OPTIONS(uint8_t, MTROccupancySensingOccupancySensorTypeBitmap) { + MTROccupancySensingOccupancySensorTypeBitmapPIR MTR_NEWLY_AVAILABLE = 0x1, + MTROccupancySensingOccupancySensorTypeBitmapUltrasonic MTR_NEWLY_AVAILABLE = 0x2, + MTROccupancySensingOccupancySensorTypeBitmapPhysicalContact MTR_NEWLY_AVAILABLE = 0x4, +} MTR_NEWLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRChannelStatus) { MTRChannelStatusSuccess API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, MTRChannelStatusMultipleMatches API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 0bee3c5b6fd0a7..7fddd14016d486 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -83228,7 +83228,7 @@ - (void)readAttributeOccupancyWithCompletion:(void (^)(NSNumber * _Nullable valu { MTRReadParams * params = [[MTRReadParams alloc] init]; using TypeInfo = OccupancySensing::Attributes::Occupancy::TypeInfo; - return MTRReadAttribute( + return MTRReadAttribute( params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } @@ -83237,8 +83237,8 @@ - (void)subscribeAttributeOccupancyWithParams:(MTRSubscribeParams * _Nonnull)par reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { using TypeInfo = OccupancySensing::Attributes::Occupancy::TypeInfo; - MTRSubscribeAttribute(params, - subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + MTRSubscribeAttribute( + params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } @@ -83247,9 +83247,9 @@ + (void)readAttributeOccupancyWithClusterStateCache:(MTRClusterStateCacheContain queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { - auto * bridge = new MTRInt8uAttributeCallbackBridge(queue, completion); + auto * bridge = new MTROccupancySensingOccupancyAttributeCallbackBridge(queue, completion); std::move(*bridge).DispatchLocalAction( - clusterStateCacheContainer.baseDevice, ^(Int8uAttributeCallback successCb, MTRErrorCallback failureCb) { + clusterStateCacheContainer.baseDevice, ^(OccupancySensingOccupancyAttributeCallback successCb, MTRErrorCallback failureCb) { if (clusterStateCacheContainer.cppClusterStateCache) { chip::app::ConcreteAttributePath path; using TypeInfo = OccupancySensing::Attributes::Occupancy::TypeInfo; @@ -83271,7 +83271,8 @@ - (void)readAttributeOccupancySensorTypeWithCompletion:(void (^)(NSNumber * _Nul { MTRReadParams * params = [[MTRReadParams alloc] init]; using TypeInfo = OccupancySensing::Attributes::OccupancySensorType::TypeInfo; - return MTRReadAttribute( + return MTRReadAttribute( params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } @@ -83281,9 +83282,9 @@ - (void)subscribeAttributeOccupancySensorTypeWithParams:(MTRSubscribeParams * _N (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { using TypeInfo = OccupancySensing::Attributes::OccupancySensorType::TypeInfo; - MTRSubscribeAttribute(params, - subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), - TypeInfo::GetAttributeId()); + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } + (void)readAttributeOccupancySensorTypeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer @@ -83292,9 +83293,9 @@ + (void)readAttributeOccupancySensorTypeWithClusterStateCache:(MTRClusterStateCa completion: (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { - auto * bridge = new MTRInt8uAttributeCallbackBridge(queue, completion); - std::move(*bridge).DispatchLocalAction( - clusterStateCacheContainer.baseDevice, ^(Int8uAttributeCallback successCb, MTRErrorCallback failureCb) { + auto * bridge = new MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(OccupancySensingClusterOccupancySensorTypeEnumAttributeCallback successCb, MTRErrorCallback failureCb) { if (clusterStateCacheContainer.cppClusterStateCache) { chip::app::ConcreteAttributePath path; using TypeInfo = OccupancySensing::Attributes::OccupancySensorType::TypeInfo; @@ -83317,7 +83318,7 @@ - (void)readAttributeOccupancySensorTypeBitmapWithCompletion:(void (^)( { MTRReadParams * params = [[MTRReadParams alloc] init]; using TypeInfo = OccupancySensing::Attributes::OccupancySensorTypeBitmap::TypeInfo; - return MTRReadAttribute( + return MTRReadAttribute( params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } @@ -83327,9 +83328,9 @@ - (void)subscribeAttributeOccupancySensorTypeBitmapWithParams:(MTRSubscribeParam (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { using TypeInfo = OccupancySensing::Attributes::OccupancySensorTypeBitmap::TypeInfo; - MTRSubscribeAttribute(params, - subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), - TypeInfo::GetAttributeId()); + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); } + (void)readAttributeOccupancySensorTypeBitmapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer @@ -83338,9 +83339,9 @@ + (void)readAttributeOccupancySensorTypeBitmapWithClusterStateCache:(MTRClusterS completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { - auto * bridge = new MTRInt8uAttributeCallbackBridge(queue, completion); - std::move(*bridge).DispatchLocalAction( - clusterStateCacheContainer.baseDevice, ^(Int8uAttributeCallback successCb, MTRErrorCallback failureCb) { + auto * bridge = new MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(OccupancySensingOccupancySensorTypeBitmapAttributeCallback successCb, MTRErrorCallback failureCb) { if (clusterStateCacheContainer.cppClusterStateCache) { chip::app::ConcreteAttributePath path; using TypeInfo = OccupancySensing::Attributes::OccupancySensorTypeBitmap::TypeInfo; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h index f690adeb7b8b24..d29c25961b81f9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h @@ -478,6 +478,10 @@ typedef void (*IlluminanceMeasurementClusterLightSensorTypeAttributeCallback)( void *, chip::app::Clusters::IlluminanceMeasurement::LightSensorType); typedef void (*NullableIlluminanceMeasurementClusterLightSensorTypeAttributeCallback)( void *, const chip::app::DataModel::Nullable &); +typedef void (*OccupancySensingClusterOccupancySensorTypeEnumAttributeCallback)( + void *, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum); +typedef void (*NullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); typedef void (*ChannelClusterChannelStatusEnumAttributeCallback)(void *, chip::app::Clusters::Channel::ChannelStatusEnum); typedef void (*NullableChannelClusterChannelStatusEnumAttributeCallback)( void *, const chip::app::DataModel::Nullable &); @@ -1060,6 +1064,10 @@ typedef void (*RelativeHumidityMeasurementEventListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*RelativeHumidityMeasurementAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*OccupancySensingOccupancyAttributeCallback)(void *, + chip::BitMask); +typedef void (*OccupancySensingOccupancySensorTypeBitmapAttributeCallback)( + void *, chip::BitMask); typedef void (*OccupancySensingGeneratedCommandListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*OccupancySensingAcceptedCommandListListAttributeCallback)( @@ -10182,6 +10190,69 @@ class MTRRelativeHumidityMeasurementAttributeListListAttributeCallbackSubscripti MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTROccupancySensingOccupancyAttributeCallbackBridge : public MTRCallbackBridge +{ +public: + MTROccupancySensingOccupancyAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTROccupancySensingOccupancyAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::BitMask value); +}; + +class MTROccupancySensingOccupancyAttributeCallbackSubscriptionBridge : public MTROccupancySensingOccupancyAttributeCallbackBridge +{ +public: + MTROccupancySensingOccupancyAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTROccupancySensingOccupancyAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTROccupancySensingOccupancyAttributeCallbackBridge::KeepAliveOnCallback; + using MTROccupancySensingOccupancyAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::BitMask value); +}; + +class MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackSubscriptionBridge + : public MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge +{ +public: + MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge::KeepAliveOnCallback; + using MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTROccupancySensingGeneratedCommandListListAttributeCallbackBridge : public MTRCallbackBridge { @@ -20462,6 +20533,77 @@ class MTRNullableIlluminanceMeasurementClusterLightSensorTypeAttributeCallbackSu MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value); +}; + +class MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge + : public MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge +{ +public: + MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void + OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge + : public MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge +{ +public: + MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRChannelClusterChannelStatusEnumAttributeCallbackBridge : public MTRCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm index e9111179e36b93..c059ee3a199a6c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm @@ -10219,6 +10219,52 @@ } } +void MTROccupancySensingOccupancyAttributeCallbackBridge::OnSuccessFn( + void * context, chip::BitMask value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:value.Raw()]; + DispatchSuccess(context, objCValue); +}; + +void MTROccupancySensingOccupancyAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackBridge::OnSuccessFn( + void * context, chip::BitMask value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:value.Raw()]; + DispatchSuccess(context, objCValue); +}; + +void MTROccupancySensingOccupancySensorTypeBitmapAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTROccupancySensingGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -20398,6 +20444,56 @@ } } +void MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTROccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableOccupancySensingClusterOccupancySensorTypeEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRChannelClusterChannelStatusEnumAttributeCallbackBridge::OnSuccessFn( void * context, chip::app::Clusters::Channel::ChannelStatusEnum value) { 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 99d96d131f817e..df3fd75a163dba 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 @@ -21715,9 +21715,9 @@ namespace Attributes { namespace Occupancy { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::BitMask * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OccupancySensing::Id, Id, readable, sizeof(temp)); @@ -21729,9 +21729,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -21746,9 +21746,9 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) namespace OccupancySensorType { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OccupancySensing::Id, Id, readable, sizeof(temp)); @@ -21760,9 +21760,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -21777,9 +21777,10 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) namespace OccupancySensorTypeBitmap { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, + chip::BitMask * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::OccupancySensing::Id, Id, readable, sizeof(temp)); @@ -21791,9 +21792,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits>; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; 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 2972b385472eb9..a7a5778ee7d27f 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 @@ -3639,18 +3639,22 @@ namespace OccupancySensing { namespace Attributes { namespace Occupancy { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // bitmap8 -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus Get(chip::EndpointId endpoint, + chip::BitMask * value); // OccupancyBitmap +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value); } // namespace Occupancy namespace OccupancySensorType { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // enum8 -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus Get(chip::EndpointId endpoint, + chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum * value); // OccupancySensorTypeEnum +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value); } // namespace OccupancySensorType namespace OccupancySensorTypeBitmap { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // bitmap8 -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus +Get(chip::EndpointId endpoint, + chip::BitMask * value); // OccupancySensorTypeBitmap +EmberAfStatus Set(chip::EndpointId endpoint, chip::BitMask value); } // namespace OccupancySensorTypeBitmap namespace PIROccupiedToUnoccupiedDelay { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index fab0511dba1cb6..9d53aacf46f0c9 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1771,6 +1771,21 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(IlluminanceMeasurement: } } +static auto __attribute__((unused)) EnsureKnownEnumValue(OccupancySensing::OccupancySensorTypeEnum val) +{ + using EnumType = OccupancySensing::OccupancySensorTypeEnum; + switch (val) + { + case EnumType::kPir: + case EnumType::kUltrasonic: + case EnumType::kPIRAndUltrasonic: + case EnumType::kPhysicalContact: + return val; + default: + return static_cast(4); + } +} + static auto __attribute__((unused)) EnsureKnownEnumValue(Channel::ChannelStatusEnum val) { using EnumType = Channel::ChannelStatusEnum; 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 860303349d758a..7e8f252038a7e2 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 @@ -2335,7 +2335,36 @@ namespace FlowMeasurement {} // namespace FlowMeasurement namespace RelativeHumidityMeasurement {} // namespace RelativeHumidityMeasurement -namespace OccupancySensing {} // namespace OccupancySensing +namespace OccupancySensing { + +// Enum for OccupancySensorTypeEnum +enum class OccupancySensorTypeEnum : uint8_t +{ + kPir = 0x00, + kUltrasonic = 0x01, + kPIRAndUltrasonic = 0x02, + kPhysicalContact = 0x03, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, +}; + +// Bitmap for OccupancyBitmap +enum class OccupancyBitmap : uint8_t +{ + kOccupied = 0x1, +}; + +// Bitmap for OccupancySensorTypeBitmap +enum class OccupancySensorTypeBitmap : uint8_t +{ + kPir = 0x1, + kUltrasonic = 0x2, + kPhysicalContact = 0x4, +}; +} // namespace OccupancySensing namespace WakeOnLan {} // namespace WakeOnLan 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 f6a10eb4083e4c..5ee93ffd9987e6 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 @@ -20691,9 +20691,9 @@ namespace Attributes { namespace Occupancy { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::BitMask; + using DecodableType = chip::BitMask; + using DecodableArgType = chip::BitMask; static constexpr ClusterId GetClusterId() { return Clusters::OccupancySensing::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::Occupancy::Id; } @@ -20703,9 +20703,9 @@ struct TypeInfo namespace OccupancySensorType { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum; + using DecodableType = chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum; + using DecodableArgType = chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum; static constexpr ClusterId GetClusterId() { return Clusters::OccupancySensing::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::OccupancySensorType::Id; } @@ -20715,9 +20715,9 @@ struct TypeInfo namespace OccupancySensorTypeBitmap { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::BitMask; + using DecodableType = chip::BitMask; + using DecodableArgType = chip::BitMask; static constexpr ClusterId GetClusterId() { return Clusters::OccupancySensing::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::OccupancySensorTypeBitmap::Id; } @@ -20877,9 +20877,12 @@ struct TypeInfo CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); - Attributes::Occupancy::TypeInfo::DecodableType occupancy = static_cast(0); - Attributes::OccupancySensorType::TypeInfo::DecodableType occupancySensorType = static_cast(0); - Attributes::OccupancySensorTypeBitmap::TypeInfo::DecodableType occupancySensorTypeBitmap = static_cast(0); + Attributes::Occupancy::TypeInfo::DecodableType occupancy = + static_cast>(0); + Attributes::OccupancySensorType::TypeInfo::DecodableType occupancySensorType = + static_cast(0); + Attributes::OccupancySensorTypeBitmap::TypeInfo::DecodableType occupancySensorTypeBitmap = + static_cast>(0); Attributes::PIROccupiedToUnoccupiedDelay::TypeInfo::DecodableType PIROccupiedToUnoccupiedDelay = static_cast(0); Attributes::PIRUnoccupiedToOccupiedDelay::TypeInfo::DecodableType PIRUnoccupiedToOccupiedDelay = static_cast(0); Attributes::PIRUnoccupiedToOccupiedThreshold::TypeInfo::DecodableType PIRUnoccupiedToOccupiedThreshold = 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 1bd963a9862ab3..bc795046b1bb19 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -675,8 +675,8 @@ enum EmberAfTemperatureDisplayMode : uint8_t #define EMBER_AF_NETWORK_COMMISSIONING_FEATURE_THREAD_NETWORK_INTERFACE_OFFSET (1) #define EMBER_AF_NETWORK_COMMISSIONING_FEATURE_ETHERNET_NETWORK_INTERFACE (4) #define EMBER_AF_NETWORK_COMMISSIONING_FEATURE_ETHERNET_NETWORK_INTERFACE_OFFSET (2) -#define EMBER_AF_OCCUPANCY_OCCUPIED (1) -#define EMBER_AF_OCCUPANCY_OCCUPIED_OFFSET (0) +#define EMBER_AF_OCCUPANCY_BITMAP_OCCUPIED (1) +#define EMBER_AF_OCCUPANCY_BITMAP_OCCUPIED_OFFSET (0) #define EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR (1) #define EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR_OFFSET (0) #define EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_ULTRASONIC (2) diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 5d743f4ebcbeea..48f456892a7f81 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -13964,13 +13964,14 @@ void registerClusterOccupancySensing(Commands & commands, CredentialIssuerComman make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // make_unique>(Id, credsIssuerConfig), // - make_unique>(Id, "occupancy", 0, UINT8_MAX, Attributes::Occupancy::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "occupancy-sensor-type", 0, UINT8_MAX, Attributes::OccupancySensorType::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "occupancy-sensor-type-bitmap", 0, UINT8_MAX, - Attributes::OccupancySensorTypeBitmap::Id, WriteCommandType::kForceWrite, - credsIssuerConfig), // + make_unique>>( + Id, "occupancy", 0, UINT8_MAX, Attributes::Occupancy::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "occupancy-sensor-type", 0, UINT8_MAX, Attributes::OccupancySensorType::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>>( + Id, "occupancy-sensor-type-bitmap", 0, UINT8_MAX, Attributes::OccupancySensorTypeBitmap::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "piroccupied-to-unoccupied-delay", 0, UINT16_MAX, Attributes::PIROccupiedToUnoccupiedDelay::Id, WriteCommandType::kWrite, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index bbebf782267a3e..960010e828274d 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -8634,17 +8634,17 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP switch (path.mAttributeId) { case OccupancySensing::Attributes::Occupancy::Id: { - uint8_t value; + chip::BitMask value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("Occupancy", 1, value); } case OccupancySensing::Attributes::OccupancySensorType::Id: { - uint8_t value; + chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("OccupancySensorType", 1, value); } case OccupancySensing::Attributes::OccupancySensorTypeBitmap::Id: { - uint8_t value; + chip::BitMask value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("OccupancySensorTypeBitmap", 1, value); } diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index d87d2612f627e9..5e651950aaf53c 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -36399,7 +36399,7 @@ class Test_TC_OCC_2_1Suite : public TestCommand case 1: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::BitMask value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "bitmap8", "bitmap8")); VerifyOrReturn(CheckConstraintMinValue("value", value, 0U)); @@ -36409,7 +36409,7 @@ class Test_TC_OCC_2_1Suite : public TestCommand case 2: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "enum8", "enum8")); VerifyOrReturn(CheckConstraintMinValue("value", value, 0U)); @@ -36419,7 +36419,7 @@ class Test_TC_OCC_2_1Suite : public TestCommand case 3: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::BitMask value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "bitmap8", "bitmap8")); VerifyOrReturn(CheckConstraintMinValue("value", value, 1U)); @@ -36662,7 +36662,7 @@ class Test_TC_OCC_2_3Suite : public TestCommand case 1: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OccupancySensing::OccupancySensorTypeEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "enum8", "enum8")); VerifyOrReturn(CheckConstraintMinValue("value", value, 0U)); @@ -36672,7 +36672,7 @@ class Test_TC_OCC_2_3Suite : public TestCommand case 2: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::BitMask value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintType("value", "bitmap8", "bitmap8")); VerifyOrReturn(CheckConstraintMinValue("value", value, 1U)); @@ -104545,7 +104545,7 @@ class Test_TC_OCC_3_1Suite : public TestCommand chip::Optional mEndpoint; chip::Optional mTimeout; - uint8_t OccupancyValue; + chip::BitMask OccupancyValue; chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } @@ -104566,7 +104566,7 @@ class Test_TC_OCC_3_1Suite : public TestCommand case 1: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::BitMask value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); OccupancyValue = value; } @@ -104578,7 +104578,7 @@ class Test_TC_OCC_3_1Suite : public TestCommand case 3: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::BitMask value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckConstraintNotValue("value", value, OccupancyValue)); } From 37efbde35098c6eacbf40a5a0669830ab15a144c Mon Sep 17 00:00:00 2001 From: Jakob Olesen Date: Fri, 13 Jan 2023 13:00:23 +0100 Subject: [PATCH 3/3] Updated code to comply with changes Updated occupancy-sensor-server code to comply with changes Updated examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp --- .../infineon/cyw30739/src/ButtonHandler.cpp | 8 +++++--- .../occupancy-sensor-server.cpp | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp b/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp index c8665dfe492797..ebb6b74fc903d0 100644 --- a/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/ButtonHandler.cpp @@ -75,7 +75,7 @@ wiced_result_t app_button_init(void) void app_button_event_handler(const button_manager_button_t * button_mgr, button_manager_event_t event, button_manager_button_state_t state) { - uint8_t attributeValue; + chip::BitMask attributeValue; if (button_mgr[0].configuration->button == PLATFORM_BUTTON_1 && event == BUTTON_CLICK_EVENT && state == BUTTON_STATE_RELEASED) { if (LightMgr().IsLightOn()) @@ -93,7 +93,9 @@ void app_button_event_handler(const button_manager_button_t * button_mgr, button { // update the current occupancy here for hardcoded endpoint 1 OccupancySensing::Attributes::Occupancy::Get(1, &attributeValue); - printf("Button Holding Toggle: %d -> %d\n", attributeValue, !attributeValue); - OccupancySensing::Attributes::Occupancy::Set(1, !attributeValue); + uint8_t bitValue = attributeValue.Raw(); + printf("Button Holding Toggle: %d -> %d\n", bitValue, !bitValue); + attributeValue.SetRaw(!bitValue); + OccupancySensing::Attributes::Occupancy::Set(1, attributeValue); } } 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 0f9b435e49b5a9..b42949eadbb298 100644 --- a/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp +++ b/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp @@ -33,25 +33,29 @@ using namespace chip::app::Clusters::OccupancySensing; void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint) { auto deviceType = halOccupancyGetSensorType(endpoint); - Attributes::OccupancySensorType::Set(endpoint, deviceType); - uint8_t deviceTypeBitmap = 0; + chip::BitMask deviceTypeBitmap = 0; switch (deviceType) { case HAL_OCCUPANCY_SENSOR_TYPE_PIR: - deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR; + deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPir); + Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPir); break; case HAL_OCCUPANCY_SENSOR_TYPE_ULTRASONIC: - deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_ULTRASONIC; + deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kUltrasonic); + Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kUltrasonic); break; case HAL_OCCUPANCY_SENSOR_TYPE_PIR_AND_ULTRASONIC: - deviceTypeBitmap = (EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PIR | EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_ULTRASONIC); + deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPir); + deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kUltrasonic); + Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPIRAndUltrasonic); break; case HAL_OCCUPANCY_SENSOR_TYPE_PHYSICAL: - deviceTypeBitmap = EMBER_AF_OCCUPANCY_SENSOR_TYPE_BITMAP_PHYSICAL_CONTACT; + deviceTypeBitmap.Set(OccupancySensorTypeBitmap::kPhysicalContact); + Attributes::OccupancySensorType::Set(endpoint, OccupancySensorTypeEnum::kPhysicalContact); break; default: @@ -67,8 +71,10 @@ void emberAfOccupancySensingClusterServerInitCallback(EndpointId endpoint) //****************************************************************************** void halOccupancyStateChangedCallback(EndpointId endpoint, HalOccupancyState occupancyState) { - if (occupancyState == HAL_OCCUPANCY_STATE_OCCUPIED) + chip::BitMask mappedOccupancyState; + if (occupancyState & HAL_OCCUPANCY_STATE_OCCUPIED) { + mappedOccupancyState.Set(OccupancyBitmap::kOccupied); emberAfOccupancySensingClusterPrintln("Occupancy detected"); } else