Skip to content

Commit

Permalink
Aligned chip-types.xml with the latest Matter spec (#28978)
Browse files Browse the repository at this point in the history
* Aligned chip-types.xml with the latest Matter spec

* reordered the XML to use the same order as the spec; this should make
  maintenance a bit more sane
* renumbered types to avoid duplication and conflicts and to align with
  the spec

Fixes #28976

* Regen ZAP

* Reflect the type changes in the Python codegen per code review comment

* Add XSD validation for unique IDs

* Add a unique constraint on the `id` element in `<type/>` sequence
* Add chip-types.xml to the validator script
  • Loading branch information
robszewczyk authored Sep 5, 2023
1 parent 54038c0 commit eb019b0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 54 deletions.
8 changes: 6 additions & 2 deletions scripts/py_matter_idl/matter_idl/generators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,27 @@ def is_struct(self) -> bool:
"data_ver": BasicInteger(idl_name="data_ver", byte_count=4, is_signed=False),
"date": BasicInteger(idl_name="date", byte_count=4, is_signed=False),
"devtype_id": BasicInteger(idl_name="devtype_id", byte_count=4, is_signed=False),
"elapsed_s": BasicInteger(idl_name="elapsed_s", byte_count=4, is_signed=False),
"endpoint_no": BasicInteger(idl_name="endpoint_no", byte_count=2, is_signed=False),
"entry_idx": BasicInteger(idl_name="entry_idx", byte_count=2, is_signed=False),
"epoch_s": BasicInteger(idl_name="epoch_s", byte_count=4, is_signed=False),
"epoch_us": BasicInteger(idl_name="epoch_us", byte_count=8, is_signed=False),
"elapsed_s": BasicInteger(idl_name="elapsed_s", byte_count=4, is_signed=False),
"event_id": BasicInteger(idl_name="event_id", byte_count=4, is_signed=False),
"event_no": BasicInteger(idl_name="event_no", byte_count=8, is_signed=False),
"fabric_id": BasicInteger(idl_name="fabric_id", byte_count=8, is_signed=False),
"fabric_idx": BasicInteger(idl_name="fabric_idx", byte_count=1, is_signed=False),
"field_id": BasicInteger(idl_name="field_id", byte_count=4, is_signed=False),
"group_id": BasicInteger(idl_name="group_id", byte_count=2, is_signed=False),
"namespace": BasicInteger(idl_name="namespace", byte_count=1, is_signed=False),
"node_id": BasicInteger(idl_name="node_id", byte_count=8, is_signed=False),
"percent": BasicInteger(idl_name="percent", byte_count=1, is_signed=False),
"percent100ths": BasicInteger(idl_name="percent100ths", byte_count=2, is_signed=False),
"posix_ms": BasicInteger(idl_name="posix_ms", byte_count=8, is_signed=False),
"priority": BasicInteger(idl_name="priority", byte_count=1, is_signed=False),
"status": BasicInteger(idl_name="status", byte_count=2, is_signed=False),
"systime_us": BasicInteger(idl_name="systime_us", byte_count=8, is_signed=False),
"systime_ms": BasicInteger(idl_name="systime_ms", byte_count=8, is_signed=False),
"systime_us": BasicInteger(idl_name="systime_us", byte_count=8, is_signed=False),
"tag": BasicInteger(idl_name="tag", byte_count=1, is_signed=False),
"temperature": BasicInteger(idl_name="temperature", byte_count=2, is_signed=True),
"tod": BasicInteger(idl_name="tod", byte_count=4, is_signed=False),
"trans_id": BasicInteger(idl_name="trans_id", byte_count=4, is_signed=False),
Expand Down
66 changes: 41 additions & 25 deletions src/app/zap-templates/zcl/data-model/chip/chip-types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ limitations under the License.
<type id="0x2D" description="Signed 48-bit integer" name="int48s" size="6" analog="true" />
<type id="0x2E" description="Signed 56-bit integer" name="int56s" size="7" analog="true" />
<type id="0x2F" description="Signed 64-bit integer" name="int64s" size="8" analog="true" />
<type id="0x30" description="8-bit enumeration" name="enum8" size="1" discrete="true" />
<type id="0x31" description="16-bit enumeration" name="enum16" size="2" discrete="true" />
<type id="0x39" description="Single precision" name="single" size="4" analog="true" />
<type id="0x3A" description="Double precision" name="double" size="8" analog="true" />
<type id="0x41" description="Octet String" name="octet_string" composite="true"/>
Expand All @@ -57,39 +55,57 @@ limitations under the License.
<!-- Derived Data Types -->
<type id="0x42" description="Character String" name="char_string" composite="true"/>
<type id="0x44" description="Long Character String" name="long_char_string" composite="true"/>

<type id="0xE6" description="Percentage units 1%" name="percent" size="1" analog="true" />
<type id="0xE7" description="Percentage units 0.01%" name="percent100ths" size="2" analog="true" />

<type id="0xE0" description="Time of day" name="tod" size="4" analog="true" />
<type id="0xE1" description="Date" name="date" size="4" analog="true" />
<type id="0xE3" description="Epoch Microseconds" name="epoch_us" size="8" analog="true" />
<type id="0xE4" description="Epoch Seconds" name="epoch_s" size="4" analog="true" />
<type id="0xD0" description="Posix Time Milliseconds" name="posix_ms" size="8" analog="true" />
<type id="0xE5" description="System Time Microseconds" name="systime_us" size="8" analog="true" />
<type id="0xE5" description="Posix Time Milliseconds" name="posix_ms" size="8" analog="true" />

<type id="0xD0" description="System Time Microseconds" name="systime_us" size="8" analog="true" />
<type id="0xD1" description="System Time Milliseconds" name="systime_ms" size="8" analog="true" />
<type id="0xD2" description="Elapsed Time Seconds" name="elapsed_s" size="4" analog="true" />
<type id="0xDB" description="Temperature" name="temperature" size="2" analog="true" signed="true" />
<type id="0xE6" description="Percentage units 1%" name="percent" size="1" analog="true" />
<type id="0xE7" description="Percentage units 0.01%" name="percent100ths" size="2" analog="true" />

<type id="0xD8" description="Temperature" name="temperature" size="2" analog="true" signed="true" />

<type id="0x30" description="8-bit enumeration" name="enum8" size="1" discrete="true" />
<type id="0x31" description="16-bit enumeration" name="enum16" size="2" discrete="true" />
<type id="0x32" description="Priority" name="priority" size="1" discrete="true" />
<type id="0x33" description="Status Code" name="status" size="1" discrete="true" />

<type id="0xC0" description="Group ID" name="group_id" size="2" discrete="true" />
<type id="0xC1" description="Endpoint Number" name="endpoint_no" size="2" discrete="true" />
<type id="0xC2" description="Vendor ID" name="vendor_id" size="2" discrete="true" />
<type id="0xC3" description="Device Type ID" name="devtype_id" size="4" discrete="true" />
<type id="0xC4" description="Fabric ID" name="fabric_id" size="8" discrete="true" />
<type id="0xC5" description="Fabric Index" name="fabric_idx" size="1" discrete="true" />

<type id="0xE8" description="Cluster ID" name="cluster_id" size="4" discrete="true" />
<type id="0xE9" description="Attribute ID" name="attrib_id" size="4" discrete="true" />
<type id="0xEA" description="Field ID" name="field_id" size="4" discrete="true" />
<type id="0xEB" description="Event ID" name="event_id" size="4" discrete="true" />
<type id="0xEC" description="Command ID" name="command_id" size="4" discrete="true" />
<type id="0xED" description="Action ID" name="action_id" size="1" discrete="true" />
<type id="0xEB" description="Field ID" name="field_id" size="4" discrete="true" />
<type id="0xEC" description="Event ID" name="event_id" size="4" discrete="true" />
<type id="0xED" description="Command ID" name="command_id" size="4" discrete="true" />
<type id="0xEE" description="Action ID" name="action_id" size="1" discrete="true" />
<type id="0xEF" description="Transaction ID" name="trans_id" size="4" discrete="true" />
<type id="0xF0" description="Node ID" name="node_id" size="8" discrete="true" />
<type id="0xF1" description="Vendor ID" name="vendor_id" size="2" discrete="true" />
<type id="0xF2" description="Device Type ID" name="devtype_id" size="4" discrete="true" />
<type id="0xF3" description="Fabric ID" name="fabric_id" size="8" discrete="true" />
<type id="0xF4" description="Group ID" name="group_id" size="2" discrete="true" />
<type id="0xF5" description="Status Code" name="status" size="1" discrete="true" />
<type id="0xF6" description="Data Version" name="data_ver" size="4" discrete="true" />
<type id="0xF7" description="Event Number" name="event_no" size="8" discrete="true" />
<type id="0xF8" description="Endpoint Number" name="endpoint_no" size="2" discrete="true" />
<type id="0xF9" description="Fabric Index" name="fabric_idx" size="1" discrete="true" />
<type id="0xFA" description="IP Address" name="ipadr" composite="true"/>
<type id="0xFB" description="IPv4 Address" name="ipv4adr" size="4" composite="true"/>
<type id="0xFC" description="IPv6 Address" name="ipv6adr" size="16" composite="true"/>
<type id="0xFD" description="IPv6 Prefix" name="ipv6pre" composite="true"/>
<type id="0xFE" description="Hardware Address" name="hwadr" composite="true"/>

<type id="0xC6" description="Entry Index" name="entry_idx" size="2" discrete="true" />
<type id="0xC7" description="Data Version" name="data_ver" size="4" discrete="true" />
<type id="0xC8" description="Event Number" name="event_no" size="8" discrete="true" />

<type id="0xF2" description="IP Address" name="ipadr" composite="true"/>
<type id="0xF3" description="IPv4 Address" name="ipv4adr" size="4" composite="true"/>
<type id="0xF4" description="IPv6 Address" name="ipv6adr" size="16" composite="true"/>
<type id="0xF5" description="IPv6 Prefix" name="ipv6pre" composite="true"/>
<type id="0xF6" description="Hardware Address" name="hwadr" composite="true"/>

<type id="0xC9" description="Semantic Tag" name="semtag" size="4" discrete="true" />
<type id="0xCA" description="Namespace" name="namespace" size="1" discrete="true" />
<type id="0xCB" description="Tag" name="tag" size="1" discrete="true" />

<type id="0xFF" description="Unknown" name="unknown" size="0" />
</atomic>
</configurator>
1 change: 1 addition & 0 deletions src/app/zap-templates/zcl/validate.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
xmllint --noout --schema zcl.xsd data-model/chip/matter-devices.xml
xmllint --noout --schema zcl.xsd data-model/chip/chip-types.xml
6 changes: 6 additions & 0 deletions src/app/zap-templates/zcl/zcl.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ This schema describes the format of the XML files, that describe the ZCL specifi
<xs:element maxOccurs="unbounded" ref="type"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="UniqueTypeId">
<xs:selector xpath="type"/>
<xs:field xpath="@id"/>
</xs:unique>
</xs:element>
<xs:element name="type">
<xs:complexType>
Expand All @@ -233,6 +237,8 @@ This schema describes the format of the XML files, that describe the ZCL specifi
<xs:attribute name="string" type="xs:boolean"/>
<xs:attribute name="char" type="xs:boolean"/>
<xs:attribute name="long" type="xs:boolean"/>
<xs:attribute name="analog" type="xs:boolean"/>
<xs:attribute name="composite" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="bitmap">
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 26 additions & 21 deletions zzz_generated/app-common/app-common/zap-generated/attribute-type.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eb019b0

Please sign in to comment.