From 3562493b00adde00e5768848a78bbb91c05f73ba Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 15 May 2023 21:46:40 -0400 Subject: [PATCH] Add new time types that got addded to the spec. (#26547) * Add new time types that got addded to the spec. * Address review comment. --- .../py_matter_idl/matter_idl/generators/types.py | 3 +++ src/app/util/ember-compatibility-functions.cpp | 14 +++++++++----- src/app/zap-templates/common/override.js | 3 +++ .../zcl/data-model/chip/chip-types.xml | 9 +++++++++ .../app-common/zap-generated/attribute-size.h | 5 +++-- .../app-common/zap-generated/attribute-type.h | 3 +++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/types.py b/scripts/py_matter_idl/matter_idl/generators/types.py index 65e09915703749..b8c9f37b1d179a 100644 --- a/scripts/py_matter_idl/matter_idl/generators/types.py +++ b/scripts/py_matter_idl/matter_idl/generators/types.py @@ -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), @@ -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), diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 7faf6116890300..4bde3b05be8178 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -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::value, "chip::Cluster is expected to be uint32_t, change this when necessary"); static_assert(std::is_same::value, @@ -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::value, "chip::EventNumber is expected to be uint64_t, change this when necessary"); static_assert(std::is_same::value, diff --git a/src/app/zap-templates/common/override.js b/src/app/zap-templates/common/override.js index 9552bf4e113101..97a90a58af4a77 100644 --- a/src/app/zap-templates/common/override.js +++ b/src/app/zap-templates/common/override.js @@ -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'; diff --git a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml index c1bd6043813ff4..464b8bb31848ab 100644 --- a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml +++ b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml @@ -16,6 +16,12 @@ limitations under the License. --> + @@ -55,7 +61,10 @@ limitations under the License. + + + diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-size.h b/zzz_generated/app-common/app-common/zap-generated/attribute-size.h index 8d51c73d95580c..e2f7d4a0d160a9 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-size.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-size.h @@ -27,8 +27,9 @@ ZCL_BOOLEAN_ATTRIBUTE_TYPE, 1, ZCL_BITMAP8_ATTRIBUTE_TYPE, 1, ZCL_BITMAP16_ATTRI ZCL_INT56U_ATTRIBUTE_TYPE, 7, ZCL_INT64U_ATTRIBUTE_TYPE, 8, ZCL_INT8S_ATTRIBUTE_TYPE, 1, ZCL_INT16S_ATTRIBUTE_TYPE, 2, ZCL_INT24S_ATTRIBUTE_TYPE, 3, ZCL_INT32S_ATTRIBUTE_TYPE, 4, ZCL_INT40S_ATTRIBUTE_TYPE, 5, ZCL_INT48S_ATTRIBUTE_TY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common/app-common/zap-generated/attribute-type.h b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h index b53b87637673c2..c7f2f874229d8c 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-type.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h @@ -56,6 +56,9 @@ enum ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE = 0x44, // Long Character String ZCL_ARRAY_ATTRIBUTE_TYPE = 0x48, // List ZCL_STRUCT_ATTRIBUTE_TYPE = 0x4C, // Structure + ZCL_POSIX_MS_ATTRIBUTE_TYPE = 0xD0, // Posix Time Milliseconds + ZCL_SYSTIME_MS_ATTRIBUTE_TYPE = 0xD1, // System Time Milliseconds + ZCL_ELAPSED_S_ATTRIBUTE_TYPE = 0xD2, // Elapsed Time Seconds ZCL_TOD_ATTRIBUTE_TYPE = 0xE0, // Time of day ZCL_DATE_ATTRIBUTE_TYPE = 0xE1, // Date ZCL_EPOCH_US_ATTRIBUTE_TYPE = 0xE3, // Epoch Microseconds