Skip to content

Commit

Permalink
Add xml of refrigerator alarm cluster and zap generated (#26572)
Browse files Browse the repository at this point in the history
* Add refrigerator alarm cluster xml to data-model

* Zap generated for refrigerator alarm cluster

* Changed domain name to Appliences

* Fix Android build.

* Fix Android and Java codegen for bitmaps.

We were casting to the BitMask type, which did implicit conversions to its IntegerType.
And those could fail if the java primitive type ended up wider than IntegerType.

* Try to fix java build by enabling RefrigeratorAlarm in controller-clusters.zap.

* Fix is_bitmap test in java codegen to actually work.

* Fix up jinja codegen for untyped bitmaps. ZAP file codegen still broken

* Fixup encode_value to use strong bitmap checks only for java

---------

Co-authored-by: Boris Zbarsky <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jan 23, 2024
1 parent 1989465 commit 3261182
Show file tree
Hide file tree
Showing 60 changed files with 5,208 additions and 43 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/proxy-valid-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/pump-configuration-and-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/pwm-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml \
src/app/zap-templates/zcl/data-model/chip/relative-humidity-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/scene.xml \
src/app/zap-templates/zcl/data-model/chip/software-diagnostics-cluster.xml \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
{%- endfor -%}
{%- elif encodable.is_enum -%}
{{target}} = static_cast<std::remove_reference_t<decltype({{target}})>>(chip::JniReferences::GetInstance().IntegerToPrimitive({{source}}));
{%- elif encodable.is_bitmap -%}
{%- elif encodable.is_untyped_bitmap -%}
{{target}} = static_cast<std::remove_reference_t<decltype({{target}})>>(chip::JniReferences::GetInstance().{{encodable.boxed_java_type}}ToPrimitive({{source}}));
{%- elif encodable.is_bitmap -%}
{{target}}.SetRaw(static_cast<std::remove_reference_t<decltype({{target}})>::IntegerType>(chip::JniReferences::GetInstance().{{encodable.boxed_java_type}}ToPrimitive({{source}})));
{% else -%}
{{target}} = static_cast<std::remove_reference_t<decltype({{target}})>>(chip::JniReferences::GetInstance().{{encodable.boxed_java_type}}ToPrimitive({{source}}));
{% endif -%}
Expand Down
6 changes: 5 additions & 1 deletion scripts/py_matter_idl/matter_idl/generators/java/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ def is_enum(self):

@property
def is_bitmap(self):
self.context.is_bitmap_type(self.data_type.name)
return self.context.is_bitmap_type(self.data_type.name)

@property
def is_untyped_bitmap(self):
return self.context.is_untyped_bitmap_type(self.data_type.name)

def clone(self):
return EncodableValue(self.context, self.data_type, self.attrs)
Expand Down
6 changes: 5 additions & 1 deletion scripts/py_matter_idl/matter_idl/generators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,18 @@ def is_struct_type(self, name: str):
"""
return any(map(lambda s: s.name == name, self.all_structs))

def is_untyped_bitmap_type(self, name: str):
"""Determine if the given type is a untyped bitmap (just an interger size)."""
return name.lower() in {"bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64"}

def is_bitmap_type(self, name: str):
"""
Determine if the given type name is type that is known to be a bitmap.
Handles both standard/zcl names (like bitmap32) and types defined within
the current lookup context.
"""
if name.lower() in ["bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64"]:
if self.is_untyped_bitmap_type(name):
return True

return any(map(lambda s: s.name == name, self.all_bitmaps))
Expand Down
1 change: 1 addition & 0 deletions scripts/rules.matterlint
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/chip/window-covering.xml";
load "../src/app/zap-templates/zcl/data-model/chip/temperature-control-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml";
load "../src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/draft/electrical-measurement-cluster.xml";
load "../src/app/zap-templates/zcl/data-model/draft/input-output-value-clusters.xml";
Expand Down
1 change: 1 addition & 0 deletions src/app/zap-templates/zcl/data-model/all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<xi:include href="chip/wifi-network-diagnostics-cluster.xml" />
<xi:include href="chip/window-covering.xml" />
<xi:include href="chip/temperature-control-cluster.xml" />
<xi:include href="chip/refrigerator-alarm.xml" />
<xi:include href="chip/matter-devices.xml" />
<xi:include href="draft/barrier-control.xml" />
<xi:include href="draft/electrical-measurement-cluster.xml" />
Expand Down
49 changes: 49 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2023 Project CHIP Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configurator>
<domain name="CHIP"/>
<bitmap name="AlarmMap" type="BITMAP32">
<cluster code="0x0057" />
<field name="DoorOpen" mask="0x01"/>
</bitmap>
<cluster>
<name>Refrigerator Alarm</name>
<domain>Appliances</domain>
<description>Attributes and commands for configuring the Refrigerator alarm.</description>
<code>0x0057</code>
<define>REFRIGERATOR_ALARM</define>
<client tick="false" init="false">true</client>
<server tick="false" init="false">true</server>
<attribute side="server" code="0x0000" define="MASK" type="AlarmMap" default="0" writable="true" optional="false">Mask</attribute>
<attribute side="server" code="0x0001" define="LATCH" type="AlarmMap" default="0" writable="false" optional="false">Latch</attribute>
<attribute side="server" code="0x0002" define="STATE" type="AlarmMap" default="0" writable="false" optional="false">State</attribute>

<command source="client" code="0x00" name="Reset" optional="false">
<description>Reset alarm</description>
<arg name="Alarms" type="AlarmMap" optional="false"/>
<arg name="Mask" type="AlarmMap" optional="true"/>
</command>

<event side="server" code="0x00" priority="info" name="Notify" optional="false">
<description>Notify</description>
<field id="0" name="Active" type="AlarmMap" />
<field id="1" name="Inactive" type="AlarmMap" />
<field id="2" name="State" type="AlarmMap" />
<field id="3" name="Mask" type="AlarmMap" />
</event>
</cluster>
</configurator>
1 change: 1 addition & 0 deletions src/app/zap-templates/zcl/zcl-with-test-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"proxy-valid-cluster.xml",
"pump-configuration-and-control-cluster.xml",
"pwm-cluster.xml",
"refrigerator-alarm.xml",
"relative-humidity-measurement-cluster.xml",
"replacable-monitoring-cluster.xml",
"scene.xml",
Expand Down
1 change: 1 addition & 0 deletions src/app/zap-templates/zcl/zcl.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"proxy-valid-cluster.xml",
"pump-configuration-and-control-cluster.xml",
"pwm-cluster.xml",
"refrigerator-alarm.xml",
"relative-humidity-measurement-cluster.xml",
"replacable-monitoring-cluster.xml",
"scene.xml",
Expand Down
2 changes: 2 additions & 0 deletions src/app/zap_cluster_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"pump-configuration-and-control-client"
],
"PWM_CLUSTER": [],
"REFRIGERATOR_ALARM": [],
"RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER": [],
"SCENES_CLUSTER": [],
"SMOKE_CO_ALARM_CLUSTER": [],
Expand Down Expand Up @@ -177,6 +178,7 @@
"pump-configuration-and-control-server"
],
"PWM_CLUSTER": [],
"REFRIGERATOR_ALARM_CLUSTER": ["refrigerator-alarm-server"],
"RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER": [],
"SCENES_CLUSTER": ["scenes"],
"SMOKE_CO_ALARM_CLUSTER": [],
Expand Down
2 changes: 2 additions & 0 deletions src/controller/data_model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ if (current_os == "android" || build_java_matter_controller) {
"jni/PulseWidthModulationClient-ReadImpl.cpp",
"jni/PumpConfigurationAndControlClient-InvokeSubscribeImpl.cpp",
"jni/PumpConfigurationAndControlClient-ReadImpl.cpp",
"jni/RefrigeratorAlarmClient-InvokeSubscribeImpl.cpp",
"jni/RefrigeratorAlarmClient-ReadImpl.cpp",
"jni/RelativeHumidityMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/RelativeHumidityMeasurementClient-ReadImpl.cpp",
"jni/ScenesClient-InvokeSubscribeImpl.cpp",
Expand Down
32 changes: 32 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,38 @@ client cluster TemperatureControl = 86 {
command SetTemperature(SetTemperatureRequest): DefaultSuccess = 0;
}

/** Attributes and commands for configuring the Refrigerator alarm. */
client cluster RefrigeratorAlarm = 87 {
bitmap AlarmMap : BITMAP32 {
kDoorOpen = 0x1;
}

info event Notify = 0 {
AlarmMap active = 0;
AlarmMap inactive = 1;
AlarmMap state = 2;
AlarmMap mask = 3;
}

attribute AlarmMap mask = 0;
readonly attribute AlarmMap latch = 1;
readonly attribute AlarmMap state = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ResetRequest {
AlarmMap alarms = 0;
optional AlarmMap mask = 1;
}

/** Reset alarm */
command Reset(ResetRequest): DefaultSuccess = 0;
}

/** Attributes for reporting air quality classification */
client cluster AirQuality = 91 {
enum AirQualityEnum : ENUM8 {
Expand Down
Loading

0 comments on commit 3261182

Please sign in to comment.