Skip to content

Commit

Permalink
Add new time types that got addded to the spec. (#26547)
Browse files Browse the repository at this point in the history
* Add new time types that got addded to the spec.

* Address review comment.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jun 18, 2023
1 parent f014914 commit 3562493
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
3 changes: 3 additions & 0 deletions scripts/py_matter_idl/matter_idl/generators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def is_struct(self) -> bool:
"endpoint_no": BasicInteger(idl_name="endpoint_no", 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),
Expand All @@ -208,8 +209,10 @@ def is_struct(self) -> bool:
"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),
"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),
"tod": BasicInteger(idl_name="tod", byte_count=4, is_signed=False),
"trans_id": BasicInteger(idl_name="trans_id", byte_count=4, is_signed=False),
"vendor_id": BasicInteger(idl_name="vendor_id", byte_count=2, is_signed=False),
Expand Down
14 changes: 9 additions & 5 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type)
case ZCL_DATA_VER_ATTRIBUTE_TYPE: // Data Version
case ZCL_BITMAP32_ATTRIBUTE_TYPE: // 32-bit bitmap
case ZCL_EPOCH_S_ATTRIBUTE_TYPE: // Epoch Seconds
case ZCL_ELAPSED_S_ATTRIBUTE_TYPE: // Elapsed Seconds
static_assert(std::is_same<chip::ClusterId, uint32_t>::value,
"chip::Cluster is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::AttributeId, uint32_t>::value,
Expand All @@ -121,11 +122,14 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type)
"chip::DataVersion is expected to be uint32_t, change this when necessary");
return ZCL_INT32U_ATTRIBUTE_TYPE;

case ZCL_EVENT_NO_ATTRIBUTE_TYPE: // Event Number
case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id
case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id
case ZCL_BITMAP64_ATTRIBUTE_TYPE: // 64-bit bitmap
case ZCL_EPOCH_US_ATTRIBUTE_TYPE: // Epoch Microseconds
case ZCL_EVENT_NO_ATTRIBUTE_TYPE: // Event Number
case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id
case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id
case ZCL_BITMAP64_ATTRIBUTE_TYPE: // 64-bit bitmap
case ZCL_EPOCH_US_ATTRIBUTE_TYPE: // Epoch Microseconds
case ZCL_POSIX_MS_ATTRIBUTE_TYPE: // POSIX Milliseconds
case ZCL_SYSTIME_MS_ATTRIBUTE_TYPE: // System time Milliseconds
case ZCL_SYSTIME_US_ATTRIBUTE_TYPE: // System time Microseconds
static_assert(std::is_same<chip::EventNumber, uint64_t>::value,
"chip::EventNumber is expected to be uint64_t, change this when necessary");
static_assert(std::is_same<chip::FabricId, uint64_t>::value,
Expand Down
3 changes: 3 additions & 0 deletions src/app/zap-templates/common/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ function atomicType(arg)
return 'chip::Percent100ths';
case 'epoch_us':
case 'systime_us':
case 'posix_ms':
case 'systime_ms':
return 'uint64_t';
case 'epoch_s':
case 'utc':
case 'elapsed_s':
return 'uint32_t';
default:
throw 'not overriding';
Expand Down
9 changes: 9 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/chip-types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ limitations under the License.
-->
<configurator>
<atomic>
<!--
The IDs here do not match the spec, but:
(1) They don't really have to (thought it would be nice)
(2) The spec is broken and has the same id for different types (so we
can't match it even if we wanted to).
-->
<type id="0x00" description="No data" name="no_data" size="0" />
<!-- Base Data Types -->
<type id="0x10" description="Boolean" name="boolean" size="1" discrete="true" />
Expand Down Expand Up @@ -55,7 +61,10 @@ limitations under the License.
<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="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="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="0xE8" description="Cluster ID" name="cluster_id" size="4" discrete="true" />
Expand Down

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

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

0 comments on commit 3562493

Please sign in to comment.