From 1367a2fda3bae99deadabd9d7caab5c8678d50a3 Mon Sep 17 00:00:00 2001 From: Fesseha Date: Wed, 22 Mar 2023 17:40:32 +0100 Subject: [PATCH] updated time-synchronization cluster definition based on PR #6352 add Time Synchronization cluster in all-clusters-app, controller-app and light-switch-app zap and regenerate all remove constraint from a single element attribute first code commit initialize timezone and trustedtimesource to 0 and null added statuscode and changed to fabricIndex regenerate zap use time sync server code set default zap setting to external for complex time sync attributes add endpoint to trustedtimesourcestruct and set command for it regenerate using updated trustedtimesourcestruct update time sync xml definition update zap files regenerate added persistent data provider for time sync cluster added new commands based on PR #6353 added test template for TimeSyncDataProvider changed command arguments to list type regenerate update SetTrustedTimeSource definition regenerate use consistent data types of attributes user CHIP_CONFIG to set size of lists clean up read handler adde TSC feature and change attribute ids include time sync related resource for build regenerate after changing attribute ids and adding time sync client feature reorganize code and implement defaultNTP handlers handle span data the right way improved overall implementation change default time zone list size to 1 made settrustedtimesource command to be fabric scoped update time sync cluster definition based on latest PR merges regenerate and changes related to attribute names and access setdefaultntp parameter is nullable implemented setdefaultntp changed the id of settimezoneresponse command to the current in spec removed curly brace that sneaked in to previous commits ValidUntil of DSTOffsetStruct is nullable added basic rules of operation in comment/psuedo-code added DSTOffsetActive predicate for DSTStatus event fixed clang compiler errors added skeleton delegate implementation for time sync use delegate placeholder and implemented events clean up usage of namespaces seems like unused code skleton verifiers for NTP address moved init from header removed conflicting generated files regenerate all enum now starts at 0, name field is optional in timezonestatus event force external storage for UTCTime and LocalTime attributes moved time sync cluster code to cpp file added mechanism to track real size of list data removed custom encoder for TimeZone attribute changed TimeZone list size to 2 for better testing behavior addressed multiple PR comments improved defaultNTP implementation and storage usage cleaned up return usage changed time logic to be able to set older time but not old than default LastKnownTime ignore attribute storage values for sizes with F quality resolve rebase conflicts some random generated code that needs to be there use consistent data types changes based on CI failures TrustedTimeSource is not a list fixed response behavior of setttimezone command missed generated code --- .../all-clusters-app.matter | 164 ++++ .../all-clusters-common/all-clusters-app.zap | 429 +++++++++++ .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../light-switch-app.matter | 164 ++++ .../light-switch-common/light-switch-app.zap | 434 ++++++++++- src/app/chip_data_model.gni | 6 + .../TimeSyncDataProvider.cpp | 221 ++++++ .../TimeSyncDataProvider.h | 69 ++ .../TimeSyncManager.cpp | 55 ++ .../TimeSyncManager.h | 49 ++ .../time-synchronization-delegate.h | 57 ++ .../time-synchronization-server.cpp | 674 +++++++++++++++++ .../time-synchronization-server.h | 105 +++ src/app/tests/BUILD.gn | 1 + src/app/tests/TestTimeSyncDataProvider.cpp | 93 +++ src/app/util/util.cpp | 1 - src/app/zap_cluster_list.json | 2 +- src/controller/data_model/BUILD.gn | 2 + .../data_model/controller-clusters.matter | 147 ++++ .../data_model/controller-clusters.zap | 439 ++++++++++- .../devicecontroller/ClusterReadMapping.java | 265 +++++++ .../devicecontroller/ClusterWriteMapping.java | 2 + .../CHIPAttributeTLVValueDecoder.cpp | 487 ++++++++++++ .../CHIPEventTLVValueDecoder.cpp | 171 +++++ .../zap-generated/CHIPInvokeCallbacks.cpp | 62 ++ .../java/zap-generated/CHIPInvokeCallbacks.h | 15 + .../java/zap-generated/CHIPReadCallbacks.cpp | 705 ++++++++++++++++++ .../chip/devicecontroller/ChipClusters.java | 474 ++++++++++++ .../devicecontroller/ChipEventStructs.java | 82 ++ .../chip/devicecontroller/ChipIdLookup.java | 81 ++ .../chip/devicecontroller/ChipStructs.java | 115 +++ .../devicecontroller/ClusterInfoMapping.java | 350 +++++++++ .../python/chip/clusters/CHIPClusters.py | 166 +++++ src/include/platform/PlatformManager.h | 2 - src/lib/core/CHIPConfig.h | 18 + src/lib/support/DefaultStorageKeyAllocator.h | 6 + .../cluster/logging/DataModelLogger.cpp | 155 ++++ .../cluster/logging/DataModelLogger.h | 2 + .../zap-generated/CHIPClientCallbacks.h | 16 + .../zap-generated/CHIPClusters.h | 9 + .../zap-generated/endpoint_config.h | 17 +- .../zap-generated/gen_config.h | 5 + 43 files changed, 6306 insertions(+), 13 deletions(-) create mode 100644 src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp create mode 100644 src/app/clusters/time-synchronization-server/TimeSyncDataProvider.h create mode 100644 src/app/clusters/time-synchronization-server/TimeSyncManager.cpp create mode 100644 src/app/clusters/time-synchronization-server/TimeSyncManager.h create mode 100644 src/app/clusters/time-synchronization-server/time-synchronization-delegate.h create mode 100644 src/app/clusters/time-synchronization-server/time-synchronization-server.cpp create mode 100644 src/app/clusters/time-synchronization-server/time-synchronization-server.h create mode 100644 src/app/tests/TestTimeSyncDataProvider.cpp 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 651bb1bfb52b90..2e48a87656f927 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 @@ -1909,6 +1909,145 @@ server cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } +/** Accurate time is required for a number of reasons, including scheduling, display and validating security materials. */ +server cluster TimeSynchronization = 56 { + enum GranularityEnum : ENUM8 { + kNoTimeGranularity = 0; + kMinutesGranularity = 1; + kSecondsGranularity = 2; + kMillisecondsGranularity = 3; + kMicrosecondsGranularity = 4; + } + + enum StatusCode : ENUM8 { + kTimeNotAccepted = 2; + } + + enum TimeSourceEnum : ENUM8 { + kNone = 0; + kUnknown = 1; + kAdmin = 2; + kNodeTimeCluster = 3; + kNonMatterSNTP = 4; + kNonMatterNTP = 5; + kMatterSNTP = 6; + kMatterNTP = 7; + kMixedNTP = 8; + kNonMatterSNTPNTS = 9; + kNonMatterNTPNTS = 10; + kMatterSNTPNTS = 11; + kMatterNTPNTS = 12; + kMixedNTPNTS = 13; + kCloudSource = 14; + kPtp = 15; + kGnss = 16; + } + + enum TimeZoneDatabaseEnum : ENUM8 { + kFull = 0; + kPartial = 1; + kNone = 2; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + optional CHAR_STRING name = 1; + } + + info event TimeFailure = 3 { + } + + info event MissingTrustedTimeSource = 4 { + } + + readonly attribute nullable epoch_us UTCTime = 0; + readonly attribute GranularityEnum granularity = 1; + readonly attribute TimeSourceEnum timeSource = 2; + readonly attribute nullable TrustedTimeSourceStruct trustedTimeSource = 3; + readonly attribute nullable char_string<128> defaultNTP = 4; + readonly attribute TimeZoneStruct timeZone[] = 5; + readonly attribute DSTOffsetStruct DSTOffset[] = 6; + readonly attribute nullable epoch_us localTime = 7; + readonly attribute TimeZoneDatabaseEnum timeZoneDatabase = 8; + readonly attribute int8u timeZoneListMaxSize = 10; + readonly attribute int8u DSTOffsetListMaxSize = 11; + 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 SetUTCTimeRequest { + epoch_us UTCTime = 0; + GranularityEnum granularity = 1; + optional TimeSourceEnum timeSource = 2; + } + + request struct SetTrustedTimeSourceRequest { + nullable FabricScopedTrustedTimeSourceStruct trustedTimeSource = 0; + } + + request struct SetTimeZoneRequest { + TimeZoneStruct timeZone[] = 0; + } + + request struct SetDSTOffsetRequest { + DSTOffsetStruct DSTOffset[] = 0; + } + + request struct SetDefaultNTPRequest { + nullable CHAR_STRING<128> defaultNTP = 0; + } + + response struct SetTimeZoneResponse = 3 { + boolean DSTOffsetRequired = 0; + } + + command access(invoke: administer) SetUTCTime(SetUTCTimeRequest): DefaultSuccess = 0; + fabric command access(invoke: administer) SetTrustedTimeSource(SetTrustedTimeSourceRequest): DefaultSuccess = 1; + command access(invoke: manage) SetTimeZone(SetTimeZoneRequest): SetTimeZoneResponse = 2; + command access(invoke: manage) SetDSTOffset(SetDSTOffsetRequest): DefaultSuccess = 4; + command access(invoke: administer) SetDefaultNTP(SetDefaultNTPRequest): DefaultSuccess = 5; +} + /** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. Two types of switch devices are supported: latching switch (e.g. rocker switch) and momentary switch (e.g. push button), distinguished with their feature flags. Interactions with the switch device are exposed as attributes (for the latching switch) and as events (for both types of switches). An interested party MAY subscribe to these attributes/events and thus be informed of the interactions, and can perform actions based on this, for example by sending commands to perform an action such as controlling a light or a window shade. */ @@ -4870,6 +5009,31 @@ endpoint 0 { ram attribute clusterRevision default = 1; } + server cluster TimeSynchronization { + emits event DSTTableEmpty; + emits event DSTStatus; + emits event TimeZoneStatus; + emits event TimeFailure; + emits event MissingTrustedTimeSource; + callback attribute UTCTime; + ram attribute granularity default = 0x00; + ram attribute timeSource default = 0x00; + callback attribute trustedTimeSource; + callback attribute defaultNTP; + callback attribute timeZone default = 1; + callback attribute DSTOffset; + callback attribute localTime default = 1; + ram attribute timeZoneDatabase default = 0; + ram attribute timeZoneListMaxSize default = 3; + ram attribute DSTOffsetListMaxSize; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + } + server cluster AdministratorCommissioning { callback attribute windowStatus default = 0; callback attribute adminFabricIndex default = 1; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 399ac119c1f433..a9d38148c2ca78 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -5434,6 +5434,435 @@ } ] }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "SetUTCTime", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTrustedTimeSource", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTimeZone", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "SetDSTOffset", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "SetDefaultNTP", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SetTimeZoneResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "UTCTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Granularity", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "GranularityEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSource", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "TimeSourceEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TrustedTimeSource", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "TrustedTimeSourceStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultNTP", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZone", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffset", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocalTime", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneDatabase", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "TimeZoneDatabaseEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NTPServerAvailable", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneListMaxSize", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffsetListMaxSize", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "DSTTableEmpty", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DSTStatus", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeZoneStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeFailure", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MissingTrustedTimeSource", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Switch", "code": 59, diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index c004e3f5dffb42..c2c34e48af73f1 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -91,6 +91,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src" ) diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt index 540b8d5794d4a8..37a97c711e6cf6 100644 --- a/examples/light-switch-app/esp32/main/CMakeLists.txt +++ b/examples/light-switch-app/esp32/main/CMakeLists.txt @@ -57,6 +57,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server" PRIV_REQUIRES chip QRCode bt app_update driver nvs_flash spi_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index f480bbe17114a9..1198a785ddba9c 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -1466,6 +1466,145 @@ server cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } +/** Accurate time is required for a number of reasons, including scheduling, display and validating security materials. */ +server cluster TimeSynchronization = 56 { + enum GranularityEnum : ENUM8 { + kNoTimeGranularity = 0; + kMinutesGranularity = 1; + kSecondsGranularity = 2; + kMillisecondsGranularity = 3; + kMicrosecondsGranularity = 4; + } + + enum StatusCode : ENUM8 { + kTimeNotAccepted = 2; + } + + enum TimeSourceEnum : ENUM8 { + kNone = 0; + kUnknown = 1; + kAdmin = 2; + kNodeTimeCluster = 3; + kNonMatterSNTP = 4; + kNonMatterNTP = 5; + kMatterSNTP = 6; + kMatterNTP = 7; + kMixedNTP = 8; + kNonMatterSNTPNTS = 9; + kNonMatterNTPNTS = 10; + kMatterSNTPNTS = 11; + kMatterNTPNTS = 12; + kMixedNTPNTS = 13; + kCloudSource = 14; + kPtp = 15; + kGnss = 16; + } + + enum TimeZoneDatabaseEnum : ENUM8 { + kFull = 0; + kPartial = 1; + kNone = 2; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + optional CHAR_STRING name = 1; + } + + info event TimeFailure = 3 { + } + + info event MissingTrustedTimeSource = 4 { + } + + readonly attribute nullable epoch_us UTCTime = 0; + readonly attribute GranularityEnum granularity = 1; + readonly attribute TimeSourceEnum timeSource = 2; + readonly attribute nullable TrustedTimeSourceStruct trustedTimeSource = 3; + readonly attribute nullable char_string<128> defaultNTP = 4; + readonly attribute TimeZoneStruct timeZone[] = 5; + readonly attribute DSTOffsetStruct DSTOffset[] = 6; + readonly attribute nullable epoch_us localTime = 7; + readonly attribute TimeZoneDatabaseEnum timeZoneDatabase = 8; + readonly attribute int8u timeZoneListMaxSize = 10; + readonly attribute int8u DSTOffsetListMaxSize = 11; + 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 SetUTCTimeRequest { + epoch_us UTCTime = 0; + GranularityEnum granularity = 1; + optional TimeSourceEnum timeSource = 2; + } + + request struct SetTrustedTimeSourceRequest { + nullable FabricScopedTrustedTimeSourceStruct trustedTimeSource = 0; + } + + request struct SetTimeZoneRequest { + TimeZoneStruct timeZone[] = 0; + } + + request struct SetDSTOffsetRequest { + DSTOffsetStruct DSTOffset[] = 0; + } + + request struct SetDefaultNTPRequest { + nullable CHAR_STRING<128> defaultNTP = 0; + } + + response struct SetTimeZoneResponse = 3 { + boolean DSTOffsetRequired = 0; + } + + command access(invoke: administer) SetUTCTime(SetUTCTimeRequest): DefaultSuccess = 0; + fabric command access(invoke: administer) SetTrustedTimeSource(SetTrustedTimeSourceRequest): DefaultSuccess = 1; + command access(invoke: manage) SetTimeZone(SetTimeZoneRequest): SetTimeZoneResponse = 2; + command access(invoke: manage) SetDSTOffset(SetDSTOffsetRequest): DefaultSuccess = 4; + command access(invoke: administer) SetDefaultNTP(SetDefaultNTPRequest): DefaultSuccess = 5; +} + /** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. Two types of switch devices are supported: latching switch (e.g. rocker switch) and momentary switch (e.g. push button), distinguished with their feature flags. Interactions with the switch device are exposed as attributes (for the latching switch) and as events (for both types of switches). An interested party MAY subscribe to these attributes/events and thus be informed of the interactions, and can perform actions based on this, for example by sending commands to perform an action such as controlling a light or a window shade. */ @@ -2340,6 +2479,31 @@ endpoint 0 { ram attribute clusterRevision default = 1; } + server cluster TimeSynchronization { + emits event DSTTableEmpty; + emits event DSTStatus; + emits event TimeZoneStatus; + emits event TimeFailure; + emits event MissingTrustedTimeSource; + callback attribute UTCTime; + ram attribute granularity default = 0x00; + ram attribute timeSource default = 0x00; + callback attribute trustedTimeSource; + callback attribute defaultNTP; + callback attribute timeZone default = 1; + callback attribute DSTOffset; + callback attribute localTime; + ram attribute timeZoneDatabase default = 0; + ram attribute timeZoneListMaxSize default = 3; + ram attribute DSTOffsetListMaxSize; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + } + server cluster AdministratorCommissioning { callback attribute windowStatus default = 0; callback attribute adminFabricIndex default = 1; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.zap b/examples/light-switch-app/light-switch-common/light-switch-app.zap index a5c77707454345..c8d578615a79ca 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.zap +++ b/examples/light-switch-app/light-switch-common/light-switch-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -4610,6 +4610,435 @@ } ] }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "SetUTCTime", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTrustedTimeSource", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTimeZone", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "SetDSTOffset", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "SetDefaultNTP", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SetTimeZoneResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "UTCTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Granularity", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "GranularityEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSource", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "TimeSourceEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TrustedTimeSource", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "TrustedTimeSourceStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultNTP", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZone", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffset", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocalTime", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneDatabase", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "TimeZoneDatabaseEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NTPServerAvailable", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneListMaxSize", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffsetListMaxSize", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "DSTTableEmpty", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DSTStatus", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeZoneStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeFailure", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MissingTrustedTimeSource", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Switch", "code": 59, @@ -9334,5 +9763,6 @@ "endpointVersion": 1, "deviceIdentifier": 15 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 8b85c353ec7bc2..f19a6fd0d494b7 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -264,6 +264,12 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/PendingNotificationMap.cpp", "${_app_root}/clusters/${cluster}/PendingNotificationMap.h", ] + } else if (cluster == "time-synchronization-server") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + "${_app_root}/clusters/${cluster}/TimeSyncDataProvider.cpp", + "${_app_root}/clusters/${cluster}/TimeSyncManager.cpp", + ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } diff --git a/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp b/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp new file mode 100644 index 00000000000000..f91855827130fa --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#include "TimeSyncDataProvider.h" + +#include +#include +#include +#include + +#include + +namespace chip { + +// Calculated with Python code: +// w = TLVWriter() +// dict([(0 , 0xff),(1, bytearray([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])), (2, 0xffff), ]) +// w.put(None, s) +// len(w.encoding) +constexpr size_t kTrustedTimeSourceMaxSerializedSize = 23u + 9u; // adding 9 as buffer +constexpr size_t kTimeZoneMaxSerializedSize = 90u + 6u; // adding 6 as buffer +constexpr size_t kDSTOffsetMaxSerializedSize = 34u + 6u; // adding 6 as buffer + +// user TZ feature #if 1 +// Multiply the serialized size by the maximum number of list size and add 2 bytes for the array start and end. +constexpr size_t kTimeZoneListMaxSerializedSize = kTimeZoneMaxSerializedSize * CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE + 2; +constexpr size_t kDSTOffsetListMaxSerializedSize = kDSTOffsetMaxSerializedSize * CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE + 2; + +CHIP_ERROR TimeSyncDataProvider::StoreTrustedTimeSource(const TrustedTimeSource & timeSource) +{ + uint8_t buffer[kTrustedTimeSourceMaxSerializedSize]; + TLV::TLVWriter writer; + + writer.Init(buffer); + ReturnErrorOnFailure(timeSource.Encode(writer, TLV::AnonymousTag())); + + return mPersistentStorage->SyncSetKeyValue(DefaultStorageKeyAllocator::TSTrustedTimeSource().KeyName(), buffer, + static_cast(writer.GetLengthWritten())); +} + +CHIP_ERROR TimeSyncDataProvider::LoadTrustedTimeSource(TrustedTimeSource & timeSource) +{ + uint8_t buffer[kTrustedTimeSourceMaxSerializedSize]; + MutableByteSpan bufferSpan(buffer); + + ReturnErrorOnFailure(Load(DefaultStorageKeyAllocator::TSTrustedTimeSource().KeyName(), bufferSpan)); + + TLV::TLVReader reader; + + reader.Init(bufferSpan.data(), bufferSpan.size()); + ReturnErrorOnFailure(reader.Next(TLV::AnonymousTag())); + ReturnErrorOnFailure(timeSource.Decode(reader)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR TimeSyncDataProvider::ClearTrustedTimeSource() +{ + return mPersistentStorage->SyncDeleteKeyValue(DefaultStorageKeyAllocator::TSTrustedTimeSource().KeyName()); +} + +CHIP_ERROR TimeSyncDataProvider::StoreDefaultNtp(const CharSpan & defaultNtp) +{ + return mPersistentStorage->SyncSetKeyValue(DefaultStorageKeyAllocator::TSDefaultNTP().KeyName(), defaultNtp.data(), + static_cast(defaultNtp.size())); +} + +CHIP_ERROR TimeSyncDataProvider::LoadDefaultNtp(MutableByteSpan & defaultNtp) +{ + return Load(DefaultStorageKeyAllocator::TSDefaultNTP().KeyName(), defaultNtp); +} + +CHIP_ERROR TimeSyncDataProvider::ClearDefaultNtp() +{ + return mPersistentStorage->SyncDeleteKeyValue(DefaultStorageKeyAllocator::TSDefaultNTP().KeyName()); +} + +CHIP_ERROR TimeSyncDataProvider::StoreTimeZone(const TimeZone & timeZoneList) +{ + uint8_t buffer[kTimeZoneListMaxSerializedSize]; + TLV::TLVWriter writer; + TLV::TLVType outerType; + + writer.Init(buffer); + ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Array, outerType)); + + for (auto timeZoneIter : timeZoneList) + { + ReturnErrorOnFailure(timeZoneIter.Encode(writer, TLV::AnonymousTag())); + } + + ReturnErrorOnFailure(writer.EndContainer(outerType)); + + return mPersistentStorage->SyncSetKeyValue(DefaultStorageKeyAllocator::TSTimeZone().KeyName(), buffer, + static_cast(writer.GetLengthWritten())); +} +CHIP_ERROR TimeSyncDataProvider::LoadTimeZone(TimeZone & timeZoneList, uint8_t & size) +{ + uint8_t buffer[kTimeZoneListMaxSerializedSize]; + MutableByteSpan bufferSpan(buffer); + size = 0; + + ReturnErrorOnFailure(Load(DefaultStorageKeyAllocator::TSTimeZone().KeyName(), bufferSpan)); + + TLV::TLVReader reader; + TLV::TLVType outerType; + + reader.Init(bufferSpan.data(), bufferSpan.size()); + ReturnErrorOnFailure(reader.Next(TLV::TLVType::kTLVType_Array, TLV::AnonymousTag())); + ReturnErrorOnFailure(reader.EnterContainer(outerType)); + auto tz = timeZoneList.begin(); + uint8_t i = 0; + + while (reader.Next() != CHIP_ERROR_END_OF_TLV && i < timeZoneList.size()) + { + app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type timeZone; + ReturnErrorOnFailure(timeZone.Decode(reader)); + tz[i].offset = timeZone.offset; + tz[i].validAt = timeZone.validAt; + if (timeZone.name.HasValue()) + { + char * dest = const_cast(tz[i].name.Value().data()); + size_t len = timeZone.name.Value().size(); + Platform::CopyString(dest, len, timeZone.name.Value().data()); + } + i++; + } + + ReturnErrorOnFailure(reader.ExitContainer(outerType)); + size = i; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR TimeSyncDataProvider::ClearTimeZone() +{ + return mPersistentStorage->SyncDeleteKeyValue(DefaultStorageKeyAllocator::TSTimeZone().KeyName()); +} + +CHIP_ERROR TimeSyncDataProvider::StoreDSTOffset(const DSTOffset & dstOffsetList) +{ + uint8_t buffer[kDSTOffsetListMaxSerializedSize]; + TLV::TLVWriter writer; + TLV::TLVType outerType; + + writer.Init(buffer); + ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag(), TLV::kTLVType_Array, outerType)); + + for (auto dstIter = dstOffsetList.begin(); dstIter != dstOffsetList.end(); dstIter++) + { + ReturnErrorOnFailure(dstIter->Encode(writer, TLV::AnonymousTag())); + } + + ReturnErrorOnFailure(writer.EndContainer(outerType)); + + return mPersistentStorage->SyncSetKeyValue(DefaultStorageKeyAllocator::TSDSTOffset().KeyName(), buffer, + static_cast(writer.GetLengthWritten())); + return CHIP_NO_ERROR; +} + +CHIP_ERROR TimeSyncDataProvider::LoadDSTOffset(DSTOffset & dstOffsetList, uint8_t & size) +{ + uint8_t buffer[kDSTOffsetListMaxSerializedSize]; + MutableByteSpan bufferSpan(buffer); + size = 0; + + ReturnErrorOnFailure(Load(DefaultStorageKeyAllocator::TSDSTOffset().KeyName(), bufferSpan)); + + TLV::TLVReader reader; + TLV::TLVType outerType; + + reader.Init(bufferSpan.data(), bufferSpan.size()); + ReturnErrorOnFailure(reader.Next(TLV::TLVType::kTLVType_Array, TLV::AnonymousTag())); + ReturnErrorOnFailure(reader.EnterContainer(outerType)); + auto dst = dstOffsetList.begin(); + uint8_t i = 0; + + while (reader.Next() != CHIP_ERROR_END_OF_TLV && i < dstOffsetList.size()) + { + app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type dstOffset; + ReturnErrorOnFailure(dstOffset.Decode(reader)); + dst[i] = dstOffset; + i++; + } + + ReturnErrorOnFailure(reader.ExitContainer(outerType)); + size = i; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR TimeSyncDataProvider::ClearDSTOffset() +{ + return mPersistentStorage->SyncDeleteKeyValue(DefaultStorageKeyAllocator::TSDSTOffset().KeyName()); +} + +CHIP_ERROR TimeSyncDataProvider::Load(const char * key, MutableByteSpan & buffer) +{ + uint16_t size = static_cast(buffer.size()); + ReturnErrorOnFailure(mPersistentStorage->SyncGetKeyValue(key, buffer.data(), size)); + + buffer = MutableByteSpan(buffer.data(), size); + return CHIP_NO_ERROR; +} + +} // namespace chip diff --git a/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.h b/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.h new file mode 100644 index 00000000000000..cbdb7a7cb40a88 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.h @@ -0,0 +1,69 @@ +/** + * + * 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. + */ + +/** + * @file API declarations for time sync cluster. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +namespace chip { + +class TimeSyncDataProvider +{ + +public: + using TrustedTimeSource = app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::Type; + using DefaultNtp = app::Clusters::TimeSynchronization::Attributes::DefaultNTP::TypeInfo::Type; + using TimeZone = app::DataModel::List; + using DSTOffset = app::DataModel::List; + + ~TimeSyncDataProvider() {} + + void Init(PersistentStorageDelegate & persistentStorage) { mPersistentStorage = &persistentStorage; } + + CHIP_ERROR StoreTrustedTimeSource(const TrustedTimeSource & timeSource); + CHIP_ERROR LoadTrustedTimeSource(TrustedTimeSource & timeSource); + CHIP_ERROR ClearTrustedTimeSource(); + + CHIP_ERROR StoreDefaultNtp(const CharSpan & defaultNtp); + CHIP_ERROR LoadDefaultNtp(MutableByteSpan & defaultNtp); + CHIP_ERROR ClearDefaultNtp(); + + CHIP_ERROR StoreTimeZone(const TimeZone & timeZoneList); + CHIP_ERROR LoadTimeZone(TimeZone & timeZoneList, uint8_t & size); + CHIP_ERROR ClearTimeZone(); + + CHIP_ERROR StoreDSTOffset(const DSTOffset & dstOffsetList); + CHIP_ERROR LoadDSTOffset(DSTOffset & dstOffsetList, uint8_t & size); + CHIP_ERROR ClearDSTOffset(); + +private: + CHIP_ERROR Load(const char * key, MutableByteSpan & buffer); + PersistentStorageDelegate * mPersistentStorage = nullptr; +}; + +} // namespace chip diff --git a/src/app/clusters/time-synchronization-server/TimeSyncManager.cpp b/src/app/clusters/time-synchronization-server/TimeSyncManager.cpp new file mode 100644 index 00000000000000..723edbc920f234 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncManager.cpp @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#include "TimeSyncManager.h" + +using namespace chip::app::Clusters::TimeSynchronization; + +void TimeSyncManager::HandleTimeZoneChanged(TimeZoneList timeZoneList) +{ + // do nothing + ChipLogProgress(Zcl, "%s", __FUNCTION__); +} + +CHIP_ERROR TimeSyncManager::HandleDstoffsetlookup() +{ + ChipLogProgress(Zcl, "%s", __FUNCTION__); + return CHIP_NO_ERROR; +} + +bool TimeSyncManager::HandleDstoffsetavailable(chip::CharSpan name) +{ + ChipLogProgress(Zcl, "%s", __FUNCTION__); + return false; +} + +CHIP_ERROR TimeSyncManager::HandleGetdstoffset() +{ + ChipLogProgress(Zcl, "%s", __FUNCTION__); + return CHIP_NO_ERROR; +} + +bool TimeSyncManager::isNTPAddressValid(chip::CharSpan ntp) +{ + return true; +} + +bool TimeSyncManager::isNTPAddressDomain(chip::CharSpan ntp) +{ + return false; +} diff --git a/src/app/clusters/time-synchronization-server/TimeSyncManager.h b/src/app/clusters/time-synchronization-server/TimeSyncManager.h new file mode 100644 index 00000000000000..e2c728d1669ec9 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncManager.h @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include "time-synchronization-delegate.h" + +namespace chip { +namespace app { +namespace Clusters { +namespace TimeSynchronization { + +using namespace chip::app; +using chip::app::Clusters::TimeSynchronization::Delegate; + +class TimeSyncManager : public Delegate +{ + +public: + using TimeZoneList = DataModel::List; + + TimeSyncManager() : Delegate(){}; + void HandleTimeZoneChanged(TimeZoneList timeZoneList) override; + CHIP_ERROR HandleDstoffsetlookup() override; + bool HandleDstoffsetavailable(chip::CharSpan name) override; + CHIP_ERROR HandleGetdstoffset() override; + bool isNTPAddressValid(chip::CharSpan ntp) override; + bool isNTPAddressDomain(chip::CharSpan ntp) override; +}; + +} // namespace TimeSynchronization +} // namespace Clusters +} // namespace app +} // namespace chip \ No newline at end of file diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-delegate.h b/src/app/clusters/time-synchronization-server/time-synchronization-delegate.h new file mode 100644 index 00000000000000..b41367114978e3 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-delegate.h @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace TimeSynchronization { + +using namespace chip::app::Clusters::TimeSynchronization; +using TimeZoneList = DataModel::List; + +/** @brief + * Defines methods for implementing application-specific logic for the Time Synchronization Cluster. + */ +class Delegate +{ +public: + inline bool HasFeature(chip::EndpointId ep, TimeSynchronizationFeature feature) + { + uint32_t map; + bool success = (Attributes::FeatureMap::Get(ep, &map) == EMBER_ZCL_STATUS_SUCCESS); + return success ? (map & to_underlying(feature)) : false; + } + + virtual void HandleTimeZoneChanged(TimeZoneList timeZoneList) = 0; + virtual CHIP_ERROR HandleDstoffsetlookup() = 0; + virtual bool HandleDstoffsetavailable(chip::CharSpan name) = 0; + virtual CHIP_ERROR HandleGetdstoffset() = 0; + virtual bool isNTPAddressValid(chip::CharSpan ntp) = 0; + virtual bool isNTPAddressDomain(chip::CharSpan ntp) = 0; + + virtual ~Delegate() = default; +}; + +} // namespace TimeSynchronization +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp new file mode 100644 index 00000000000000..79b24a6e110797 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -0,0 +1,674 @@ +/* + * 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. + */ + +#include "time-synchronization-server.h" +#include "TimeSyncManager.h" +#include "time-synchronization-delegate.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +using namespace chip; +using namespace chip::DeviceLayer; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::TimeSynchronization; +using namespace chip::app::Clusters::TimeSynchronization::Attributes; +using chip::TimeSyncDataProvider; +using chip::Protocols::InteractionModel::Status; + +// ----------------------------------------------------------------------------- +// Delegate Implementation + +using chip::app::Clusters::TimeSynchronization::Delegate; + +namespace { + +Delegate * gDelegate = nullptr; + +Delegate * GetDelegate() +{ + if (gDelegate == nullptr) + { + static TimeSyncManager dg; + gDelegate = &dg; + } + return gDelegate; +} +} // namespace + +namespace chip { +namespace app { +namespace Clusters { +namespace TimeSynchronization { + +void SetDefaultDelegate(Delegate * delegate) +{ + gDelegate = delegate; +} + +Delegate * GetDefaultDelegate(void) +{ + return GetDelegate(); +} + +} // namespace TimeSynchronization +} // namespace Clusters +} // namespace app +} // namespace chip + +TimeSynchronizationServer TimeSynchronizationServer::mTimeSyncInstance; + +TimeSynchronizationServer & TimeSynchronizationServer::Instance(void) +{ + return mTimeSyncInstance; +} + +void TimeSynchronizationServer::Init() +{ + mTimeSyncDataProvider.Init(Server::GetInstance().GetPersistentStorage()); + + TimeSynchronization::Structs::TrustedTimeSourceStruct::Type tts; + (CHIP_NO_ERROR == mTimeSyncDataProvider.LoadTrustedTimeSource(tts)) ? (void) mTrustedTimeSource.SetNonNull(tts) + : mTrustedTimeSource.SetNull(); + auto tz = mTimeZoneList.begin(); + for (size_t i = 0; i < mTimeZoneList.size(); i++) + { + memset(mNames[i].name, 0, sizeof(mNames[i].name)); + const char * buf = reinterpret_cast(mNames[i].name); + tz[i].name.SetValue(chip::CharSpan(buf, sizeof(mNames[i].name))); + } + mTimeSyncDataProvider.LoadTimeZone(mTimeZoneList, mTimeZoneListSize); + mTimeSyncDataProvider.LoadDSTOffset(mDstOffsetList, mDstOffsetListSize); + // TODO if trusted time source is available schedule a time read + if (!mTrustedTimeSource.IsNull()) + { + } +} + +CHIP_ERROR TimeSynchronizationServer::SetTrustedTimeSource( + DataModel::Nullable tts) +{ + mTrustedTimeSource = tts; + if (!mTrustedTimeSource.IsNull()) + { + return mTimeSyncDataProvider.StoreTrustedTimeSource(mTrustedTimeSource.Value()); + } + else + { + return mTimeSyncDataProvider.ClearTrustedTimeSource(); + } +} + +CHIP_ERROR TimeSynchronizationServer::SetDefaultNtp(DataModel::Nullable & dntp) +{ + if (!dntp.IsNull()) + { + return mTimeSyncDataProvider.StoreDefaultNtp(dntp.Value()); + } + else + { + return mTimeSyncDataProvider.ClearDefaultNtp(); + } +} + +CHIP_ERROR TimeSynchronizationServer::SetTimeZone(DataModel::DecodableList tz) +{ + auto tzL = mTimeZoneList.begin(); + auto newTzL = tz.begin(); + uint8_t i = 0; + + while (newTzL.Next() && i < CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE) + { + tzL[i].offset = newTzL.GetValue().offset; + tzL[i].validAt = newTzL.GetValue().validAt; + if (newTzL.GetValue().name.HasValue()) + { + const char * buf = newTzL.GetValue().name.Value().data(); + size_t len = newTzL.GetValue().name.Value().size(); + memset(mNames[i].name, 0, sizeof(mNames[i].name)); + memcpy(mNames[i].name, buf, len); + } + i++; + } + ReturnErrorOnFailure(newTzL.GetStatus()); + mTimeZoneListSize = i; + + return mTimeSyncDataProvider.StoreTimeZone(TimeSynchronizationServer::Instance().GetTimeZone()); +} + +CHIP_ERROR +TimeSynchronizationServer::SetDSTOffset(DataModel::DecodableList dst) +{ + auto dstL = mDstOffsetList.begin(); + auto newDstL = dst.begin(); + uint8_t i = 0; + + while (newDstL.Next() && i < CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE) + { + dstL[i] = newDstL.GetValue(); + i++; + } + ReturnErrorOnFailure(newDstL.GetStatus()); + mDstOffsetListSize = i; + + return mTimeSyncDataProvider.StoreDSTOffset(TimeSynchronizationServer::Instance().GetDSTOffset()); +} + +CHIP_ERROR TimeSynchronizationServer::ClearDSTOffset() +{ + mDstOffsetListSize = 0; + memset((void *) mDst, 0, sizeof(mDst) * CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE); + + return mTimeSyncDataProvider.ClearDSTOffset(); +} + +DataModel::Nullable & +TimeSynchronizationServer::GetTrustedTimeSource(void) +{ + return mTrustedTimeSource; +} + +CHIP_ERROR TimeSynchronizationServer::GetDefaultNtp(MutableByteSpan & dntp) +{ + return mTimeSyncDataProvider.LoadDefaultNtp(dntp); +} + +DataModel::List & TimeSynchronizationServer::GetTimeZone(void) +{ + mTimeZoneList = DataModel::List(mTz, mTimeZoneListSize); + return mTimeZoneList; +} + +DataModel::List & TimeSynchronizationServer::GetDSTOffset(void) +{ + mDstOffsetList = DataModel::List(mDst, mDstOffsetListSize); + return mDstOffsetList; +} + +void TimeSynchronizationServer::ScheduleDelayedAction(System::Clock::Seconds32 delay, System::TimerCompleteCallback action, + void * aAppState) +{ + VerifyOrDie(SystemLayer().StartTimer(std::chrono::duration_cast(delay), action, aAppState) == + CHIP_NO_ERROR); +} + +namespace { + +static bool computeLocalTime(chip::EndpointId ep, uint64_t & localTime) +{ + int32_t timeZoneOffset = 0, dstOffset = 0; + System::Clock::Microseconds64 utcTime; + VerifyOrReturnValue(System::SystemClock().GetClock_RealTime(utcTime) == CHIP_NO_ERROR, false); + auto tz = TimeSynchronizationServer::Instance().GetTimeZone().begin(); + auto dst = TimeSynchronizationServer::Instance().GetDSTOffset().begin(); + if (tz->validAt <= utcTime.count()) + { + timeZoneOffset = tz->offset; + } + if (dst->validStarting <= utcTime.count()) + { + dstOffset = dst->offset; + } + localTime = (utcTime.count() + static_cast(timeZoneOffset) + static_cast(dstOffset)); + return true; +} + +class TimeSynchronizationAttrAccess : public AttributeAccessInterface +{ +public: + // Register for the TimeSync cluster on all endpoints + TimeSynchronizationAttrAccess() : AttributeAccessInterface(Optional::Missing(), TimeSynchronization::Id) {} + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + +private: + CHIP_ERROR ReadTrustedTimeSource(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadDefaultNtp(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadTimeZone(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadDSTOffset(EndpointId endpoint, AttributeValueEncoder & aEncoder); +}; + +TimeSynchronizationAttrAccess gAttrAccess; + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadTrustedTimeSource(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + auto tts = TimeSynchronizationServer::Instance().GetTrustedTimeSource(); + return aEncoder.Encode(tts); +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadDefaultNtp(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + uint8_t buffer[DefaultNTP::TypeInfo::MaxLength()]; + MutableByteSpan dntp(buffer); + if (TimeSynchronizationServer::Instance().GetDefaultNtp(dntp) == CHIP_NO_ERROR && dntp.size() != 0) + { + const char * charBuf = reinterpret_cast(buffer); + return aEncoder.Encode(chip::CharSpan(charBuf, dntp.size())); + } + else + { + return aEncoder.EncodeNull(); + } +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadTimeZone(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { + TimeZone::TypeInfo::Type tzList = TimeSynchronizationServer::Instance().GetTimeZone(); + for (const auto & timeZone : tzList) + { + ReturnErrorOnFailure(encoder.Encode(timeZone)); + } + + return CHIP_NO_ERROR; + }); + + return err; +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadDSTOffset(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { + DSTOffset::TypeInfo::Type dstList = TimeSynchronizationServer::Instance().GetDSTOffset(); + for (const auto & dstOffset : dstList) + { + ReturnErrorOnFailure(encoder.Encode(dstOffset)); + } + + return CHIP_NO_ERROR; + }); + + return err; +} + +CHIP_ERROR TimeSynchronizationAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + if (aPath.mClusterId != TimeSynchronization::Id) + { + return CHIP_ERROR_INVALID_PATH_LIST; + } + + switch (aPath.mAttributeId) + { + case UTCTime::Id: { + System::Clock::Microseconds64 utcTime; + VerifyOrReturnError(System::SystemClock().GetClock_RealTime(utcTime) == CHIP_NO_ERROR, aEncoder.EncodeNull()); + return aEncoder.Encode(utcTime.count()); + } + case TrustedTimeSource::Id: { + return ReadTrustedTimeSource(aPath.mEndpointId, aEncoder); + } + case DefaultNTP::Id: { + return ReadDefaultNtp(aPath.mEndpointId, aEncoder); + } + case TimeZone::Id: { + return ReadTimeZone(aPath.mEndpointId, aEncoder); + } + case DSTOffset::Id: { + return ReadDSTOffset(aPath.mEndpointId, aEncoder); + } + case TimeZoneListMaxSize::Id: { // can't find a way to initialize default value for F quality + uint8_t max = CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE; + return aEncoder.Encode(max); + } + case DSTOffsetListMaxSize::Id: { + uint8_t max = CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE; + return aEncoder.Encode(max); + } + case LocalTime::Id: { + uint64_t localTime = 0; + VerifyOrReturnError(computeLocalTime(aPath.mEndpointId, localTime), aEncoder.EncodeNull()); + return aEncoder.Encode(localTime); + } + default: { + break; + } + } + + return err; +} +} // anonymous namespace + +static bool sendDSTTableEmpty(chip::EndpointId endpointId) +{ + Events::DSTTableEmpty::Type event; + EventNumber eventNumber; + + CHIP_ERROR error = LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "Unable to send DSTTableEmpty event [endpointId=%d]", endpointId); + return false; + } + ChipLogProgress(Zcl, "Emit DSTTableEmpty event [endpointId=%d]", endpointId); + + // re-schedule event for after min 1hr + // delegate->scheduleDSTTableEmptyEvent() + return true; +} + +static bool sendDSTStatus(chip::EndpointId endpointId, bool dstOffsetActive) +{ + Events::DSTStatus::Type event; + event.DSTOffsetActive = dstOffsetActive; + EventNumber eventNumber; + + CHIP_ERROR error = LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "Unable to send sendDSTStatus event [endpointId=%d]", endpointId); + return false; + } + + ChipLogProgress(Zcl, "Emit sendDSTStatus event [endpointId=%d]", endpointId); + return true; +} + +static bool sendTimeZoneStatus(chip::EndpointId endpointId, uint8_t listIndex) +{ + Events::TimeZoneStatus::Type event; + auto tz = TimeSynchronizationServer::Instance().GetTimeZone().begin(); + event.offset = tz[listIndex].offset; + if (tz[listIndex].name.HasValue()) + { + event.name.SetValue(tz[listIndex].name.Value()); + } + EventNumber eventNumber; + + CHIP_ERROR error = LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "Unable to send sendTimeZoneStatus event [endpointId=%d]", endpointId); + return false; + } + + ChipLogProgress(Zcl, "Emit sendTimeZoneStatus event [endpointId=%d]", endpointId); + return true; +} + +static bool sendTimeFailure(chip::EndpointId endpointId) +{ + Events::TimeFailure::Type event; + EventNumber eventNumber; + + CHIP_ERROR error = LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "Unable to send sendTimeFailure event [endpointId=%d]", endpointId); + return false; + } + + // re-schedule event for after min 1hr if no time is still available + ChipLogProgress(Zcl, "Emit sendTimeFailure event [endpointId=%d]", endpointId); + return true; +} + +static bool sendMissingTrustedTimeSource(chip::EndpointId endpointId) +{ + Events::MissingTrustedTimeSource::Type event; + EventNumber eventNumber; + + CHIP_ERROR error = LogEvent(event, endpointId, eventNumber); + + if (CHIP_NO_ERROR != error) + { + ChipLogError(Zcl, "Unable to send sendMissingTrustedTimeSource event [endpointId=%d]", endpointId); + return false; + } + + // re-schedule event for after min 1hr if TTS is null or cannot be reached + ChipLogProgress(Zcl, "Emit sendMissingTrustedTimeSource event [endpointId=%d]", endpointId); + return true; +} + +static bool utcTimeChanged(uint64_t utcTime) +{ + System::Clock::Seconds32 lastKnownGoodChipEpoch; + System::Clock::Microseconds64 realTime; + uint32_t utcTimetoChipEpoch; + + Server::GetInstance().GetFabricTable().GetLastKnownGoodChipEpochTime(lastKnownGoodChipEpoch); + System::SystemClock().GetClock_RealTime(realTime); + chip::UnixEpochToChipEpochTime((uint32_t)(utcTime / chip::kMicrosecondsPerSecond), utcTimetoChipEpoch); + + VerifyOrReturnValue(Server::GetInstance().GetFabricTable().SetLastKnownGoodChipEpochTime( + System::Clock::Seconds32(utcTimetoChipEpoch)) == CHIP_NO_ERROR, + false); + VerifyOrReturnValue(System::SystemClock().SetClock_RealTime(System::Clock::Microseconds64(utcTime)) == CHIP_NO_ERROR, false); + + Server::GetInstance().GetFabricTable().GetLastKnownGoodChipEpochTime(lastKnownGoodChipEpoch); + System::SystemClock().GetClock_RealTime(realTime); + return true; +} + +bool emberAfTimeSynchronizationClusterSetUTCTimeCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetUTCTime::DecodableType & commandData) +{ + const auto & utcTime = commandData.UTCTime; + const auto & granularity = commandData.granularity; + + TimeSynchronization::GranularityEnum currentGranularity; + Granularity::Get(commandPath.mEndpointId, ¤tGranularity); + + if ((currentGranularity == TimeSynchronization::GranularityEnum::kNoTimeGranularity || granularity >= currentGranularity) && + utcTimeChanged(utcTime)) + { + Granularity::Set(commandPath.mEndpointId, granularity); + TimeSource::Set(commandPath.mEndpointId, TimeSynchronization::TimeSourceEnum::kAdmin); + commandObj->AddStatus(commandPath, Status::Success); + return true; + } + else + { + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(TimeSynchronization::StatusCode::kTimeNotAccepted)); + return true; + } +} + +bool emberAfTimeSynchronizationClusterSetTrustedTimeSourceCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::DecodableType & commandData) +{ + const auto & timeSource = commandData.trustedTimeSource; + DataModel::Nullable tts; + + if (!timeSource.IsNull()) + { + + TimeSynchronization::Structs::TrustedTimeSourceStruct::Type ts = { commandObj->GetAccessingFabricIndex(), + timeSource.Value().nodeID, timeSource.Value().endpoint }; + tts.SetNonNull(ts); + // TODO schedule a utctime read from this time source + } + else + { + tts.SetNull(); + sendMissingTrustedTimeSource(commandPath.mEndpointId); + } + + TimeSynchronizationServer::Instance().SetTrustedTimeSource(tts); + commandObj->AddStatus(commandPath, Status::Success); + return true; +} + +bool emberAfTimeSynchronizationClusterSetTimeZoneCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::DecodableType & commandData) +{ + const auto & timeZone = commandData.timeZone; + size_t items; + uint8_t maxSize = 0; + uint64_t localTime; + VerifyOrReturnValue(timeZone.ComputeSize(&items) == CHIP_NO_ERROR, false); + TimeZoneListMaxSize::Get(commandPath.mEndpointId, &maxSize); + + if (items > maxSize || items > CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE) + { + commandObj->AddStatus(commandPath, Status::ResourceExhausted); + return true; + } + // first element shall have validAt entry of 0 + // if second element, it shall have validAt entry of non-0 + + if (CHIP_NO_ERROR != TimeSynchronizationServer::Instance().SetTimeZone(timeZone)) + { + commandObj->AddStatus(commandPath, Status::ConstraintError); + return true; + } + sendTimeZoneStatus(commandPath.mEndpointId, 0); + sendTimeFailure(commandPath.mEndpointId); // TODO remove + GetDelegate()->HandleTimeZoneChanged(TimeSynchronizationServer::Instance().GetTimeZone()); + GetDelegate()->HandleDstoffsetlookup(); + + TimeSynchronization::TimeZoneDatabaseEnum tzDb; + TimeZoneDatabase::Get(commandPath.mEndpointId, &tzDb); + Commands::SetTimeZoneResponse::Type response; + if (GetDelegate()->HasFeature(0, TimeSynchronization::TimeSynchronizationFeature::kTimeZone) && + tzDb != TimeSynchronization::TimeZoneDatabaseEnum::kNone) + { + auto tz = TimeSynchronizationServer::Instance().GetTimeZone().begin(); + if (tz->name.HasValue() && GetDelegate()->HandleDstoffsetavailable(tz->name.Value()) == true) + { + GetDelegate()->HandleGetdstoffset(); + response.DSTOffsetRequired = false; + sendDSTStatus(commandPath.mEndpointId, true); + } + else + { + TimeSynchronizationServer::Instance().ClearDSTOffset(); + sendDSTTableEmpty(commandPath.mEndpointId); + sendDSTStatus(commandPath.mEndpointId, false); + } + } + computeLocalTime(commandPath.mEndpointId, localTime); + response.DSTOffsetRequired = true; + commandObj->AddResponse(commandPath, response); + return true; +} + +bool emberAfTimeSynchronizationClusterSetDSTOffsetCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::DecodableType & commandData) +{ + const auto & dstOffset = commandData.DSTOffset; + size_t items; + uint8_t maxSize = 0; + VerifyOrReturnValue(dstOffset.ComputeSize(&items) == CHIP_NO_ERROR, false); + DSTOffsetListMaxSize::Get(commandPath.mEndpointId, &maxSize); + + if (items > maxSize && items > CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE) + { + commandObj->AddStatus(commandPath, Status::ResourceExhausted); + return true; + } + + // sorted by ValidStarting time + // ValidStartingTime shall not be smaller than ValidUntil time of previous entry + // only 1 validuntil null value and shall be last in the list + // remove entries which are no longer active + // if offset == 0 && ValidUntil == null then no DST is used + if (CHIP_NO_ERROR != TimeSynchronizationServer::Instance().SetDSTOffset(dstOffset)) + { + commandObj->AddStatus(commandPath, Status::ConstraintError); + return true; + } + // if DST state changes, generate DSTStatus event + sendDSTStatus(commandPath.mEndpointId, true); + // if list is empty, generate DSTTableEmpty event + sendDSTTableEmpty(commandPath.mEndpointId); + + commandObj->AddStatus(commandPath, Status::Success); + return true; +} + +bool emberAfTimeSynchronizationClusterSetDefaultNTPCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetDefaultNTP::DecodableType & commandData) +{ + Status status = Status::Success; + auto dNtpChar = commandData.defaultNTP; + + if (!dNtpChar.IsNull()) + { + if (!GetDelegate()->isNTPAddressValid(dNtpChar.Value())) + { + commandObj->AddStatus(commandPath, Status::InvalidCommand); + return true; + } + if (GetDelegate()->isNTPAddressDomain(dNtpChar.Value())) + { + bool dnsResolve; + SupportsDNSResolve::Get(commandPath.mEndpointId, &dnsResolve); + if (!dnsResolve) + { + commandObj->AddStatus(commandPath, Status::InvalidCommand); + return true; + } + } + + size_t len = dNtpChar.Value().size(); + + if (len > DefaultNTP::TypeInfo::MaxLength()) + { + commandObj->AddStatus(commandPath, Status::ConstraintError); + return true; + } + } + + status = + (CHIP_NO_ERROR == TimeSynchronizationServer::Instance().SetDefaultNtp(dNtpChar)) ? Status::Success : Status::InvalidCommand; + + commandObj->AddStatus(commandPath, status); + return true; +} + +void MatterTimeSynchronizationPluginServerInitCallback() +{ + static bool attrAccessRegistered = false; + TimeSynchronizationServer::Instance().Init(); + if (!attrAccessRegistered) + { + attrAccessRegistered = true; + registerAttributeAccessOverride(&gAttrAccess); +#if 0 + TimeSynchronization::GranularityEnum granularity = TimeSynchronization::GranularityEnum::kNoTimeGranularity; + TimeSynchronization::Attributes::Granularity::Set(0, granularity); + // System::SystemClock().SetClock_RealTime(System::Clock::Microseconds64(1679668000000000)); +#endif + } +} diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.h b/src/app/clusters/time-synchronization-server/time-synchronization-server.h new file mode 100644 index 00000000000000..2a0b83da2d62c0 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.h @@ -0,0 +1,105 @@ +/** + * + * 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. + */ + +/** + * @file API declarations for time sync cluster. + */ + +#pragma once + +#include "TimeSyncDataProvider.h" + +#include +#include +#include +#include + +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace TimeSynchronization { + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::TimeSynchronization; +using namespace chip::app::Clusters::TimeSynchronization::Attributes; +using chip::TimeSyncDataProvider; +using chip::Protocols::InteractionModel::Status; + +class TimeSynchronizationServer +{ + struct timeZoneName + { + char name[64]; + }; + +public: + void Init(); + + static TimeSynchronizationServer & Instance(void); + TimeSyncDataProvider GetDataProvider(void) { return mTimeSyncDataProvider; } + + CHIP_ERROR SetTrustedTimeSource(DataModel::Nullable tts); + CHIP_ERROR SetDefaultNtp(DataModel::Nullable & dntp); + /** + * @brief Sets TimeZone Attribute. Assumes the size of the list is already validated. + * + * @param tz TimeZone list + * @return CHIP_ERROR + */ + CHIP_ERROR SetTimeZone(DataModel::DecodableList tz); + /** + * @brief Sets DstOffset Attribute. Assumes the size of the list is already validated. + * + * @param dst DstOffset list + * @return CHIP_ERROR + */ + CHIP_ERROR SetDSTOffset(DataModel::DecodableList dst); + CHIP_ERROR ClearDSTOffset(void); + DataModel::Nullable & GetTrustedTimeSource(void); + CHIP_ERROR GetDefaultNtp(MutableByteSpan & dntp); + DataModel::List & GetTimeZone(void); + DataModel::List & GetDSTOffset(void); + + void ScheduleDelayedAction(System::Clock::Seconds32 delay, System::TimerCompleteCallback action, void * aAppState); + +private: + DataModel::Nullable mTrustedTimeSource; + DataModel::List mTimeZoneList = + DataModel::List(mTz); + DataModel::List mDstOffsetList = + DataModel::List(mDst); + + uint8_t mTimeZoneListSize = 0; + uint8_t mDstOffsetListSize = 0; + + TimeSynchronization::Structs::TimeZoneStruct::Type mTz[CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE]; + struct timeZoneName mNames[CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE]; + TimeSynchronization::Structs::DSTOffsetStruct::Type mDst[CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE]; + + TimeSyncDataProvider mTimeSyncDataProvider; + static TimeSynchronizationServer mTimeSyncInstance; +}; + +} // namespace TimeSynchronization +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index b4da7f9f6af015..732b4fdc01b6ba 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -133,6 +133,7 @@ chip_test_suite("tests") { "TestStatusResponseMessage.cpp", "TestTimedHandler.cpp", "TestWriteInteraction.cpp", + "TestTimeSyncDataProvider.cpp", ] if (!chip_fake_platform) { diff --git a/src/app/tests/TestTimeSyncDataProvider.cpp b/src/app/tests/TestTimeSyncDataProvider.cpp new file mode 100644 index 00000000000000..8a9e60b83628f9 --- /dev/null +++ b/src/app/tests/TestTimeSyncDataProvider.cpp @@ -0,0 +1,93 @@ +/* + * + * 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. + */ + +#include +#include +#include +#include + +#include + +using namespace chip; +using namespace chip::DeviceLayer; + +namespace { + +void TestTrustedTimeSource(nlTestSuite * inSuite, void * inContext) +{ + TestPersistentStorageDelegate persistentStorage; + TimeSyncDataProvider timeSyncDataProv; + timeSyncDataProv.Init(persistentStorage); + + NL_TEST_ASSERT(inSuite, true); +} + +void TestDefaultNtp(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, true); +} + +void TestTimeZone(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, true); +} + +void TestTimeZoneEmpty(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, true); +} + +void TestDSTOffset(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, true); +} + +void TestDSTOffsetEmpty(nlTestSuite * inSuite, void * inContext) +{ + NL_TEST_ASSERT(inSuite, true); +} + +const nlTest sTests[] = { NL_TEST_DEF("Test TrustedTimeSource", TestTrustedTimeSource), + NL_TEST_DEF("Test default NTP", TestDefaultNtp), + NL_TEST_DEF("Test time zone", TestTimeZone), + NL_TEST_DEF("Test time zone (empty list)", TestTimeZoneEmpty), + NL_TEST_DEF("Test DSTOffset", TestDSTOffset), + NL_TEST_DEF("Test DSTOffset (empty list)", TestDSTOffsetEmpty), + NL_TEST_SENTINEL() }; + +int TestSetup(void * inContext) +{ + return SUCCESS; +} + +int TestTearDown(void * inContext) +{ + return SUCCESS; +} + +} // namespace + +int TestTimeSyncDataProvider() +{ + nlTestSuite theSuite = { "Time Sync data provider tests", &sTests[0], TestSetup, TestTearDown }; + + // Run test suit againt one context. + nlTestRunner(&theSuite, nullptr); + return nlTestRunnerStats(&theSuite); +} + +CHIP_REGISTER_TEST_SUITE(TestTimeSyncDataProvider) diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index f11e4c635a5509..110864f57db43b 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -132,7 +132,6 @@ void MatterTimePluginServerInitCallback() {} void MatterAclPluginServerInitCallback() {} void MatterPollControlPluginServerInitCallback() {} void MatterUnitLocalizationPluginServerInitCallback() {} -void MatterTimeSynchronizationPluginServerInitCallback() {} void MatterProxyValidPluginServerInitCallback() {} void MatterProxyDiscoveryPluginServerInitCallback() {} void MatterProxyConfigurationPluginServerInitCallback() {} diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index 9d0a3dfc082ac7..eafcf1c62c0bef 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -91,7 +91,7 @@ ], "TIME_CLUSTER": [], "TIME_FORMAT_LOCALIZATION_CLUSTER": ["time-format-localization-server"], - "TIME_SYNCHRONIZATION_CLUSTER": [], + "TIME_SYNCHRONIZATION_CLUSTER": ["time-synchronization-server"], "UNIT_LOCALIZATION_CLUSTER": [], "USER_LABEL_CLUSTER": ["user-label-server"], "WAKE_ON_LAN_CLUSTER": ["wake-on-lan-server"], diff --git a/src/controller/data_model/BUILD.gn b/src/controller/data_model/BUILD.gn index 3a2f40e4961e9d..a809c13f7e57f1 100644 --- a/src/controller/data_model/BUILD.gn +++ b/src/controller/data_model/BUILD.gn @@ -179,6 +179,8 @@ if (current_os == "android" || build_java_matter_controller) { # https://github.com/project-chip/connectedhomeip/issues/24425 #"jni/ClientMonitoringClient-ReadImpl.cpp", #"jni/ClientMonitoringClient-InvokeSubscribeImpl.cpp", + "jni/TimeSynchronizationClient-ReadImpl.cpp", + "jni/TimeSynchronizationClient-InvokeSubscribeImpl.cpp", ] deps = [ diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 94c497a81ff917..fb163c0a1b7ad4 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -2072,6 +2072,152 @@ client cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } +/** Accurate time is required for a number of reasons, including scheduling, display and validating security materials. */ +client cluster TimeSynchronization = 56 { + enum GranularityEnum : ENUM8 { + kNoTimeGranularity = 0; + kMinutesGranularity = 1; + kSecondsGranularity = 2; + kMillisecondsGranularity = 3; + kMicrosecondsGranularity = 4; + } + + enum StatusCode : ENUM8 { + kTimeNotAccepted = 2; + } + + enum TimeSourceEnum : ENUM8 { + kNone = 0; + kUnknown = 1; + kAdmin = 2; + kNodeTimeCluster = 3; + kNonMatterSNTP = 4; + kNonMatterNTP = 5; + kMatterSNTP = 6; + kMatterNTP = 7; + kMixedNTP = 8; + kNonMatterSNTPNTS = 9; + kNonMatterNTPNTS = 10; + kMatterSNTPNTS = 11; + kMatterNTPNTS = 12; + kMixedNTPNTS = 13; + kCloudSource = 14; + kPtp = 15; + kGnss = 16; + } + + enum TimeZoneDatabaseEnum : ENUM8 { + kFull = 0; + kPartial = 1; + kNone = 2; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + optional CHAR_STRING name = 1; + } + + info event TimeFailure = 3 { + } + + info event MissingTrustedTimeSource = 4 { + } + + readonly attribute nullable epoch_us UTCTime = 0; + readonly attribute GranularityEnum granularity = 1; + readonly attribute optional TimeSourceEnum timeSource = 2; + readonly attribute optional nullable TrustedTimeSourceStruct trustedTimeSource = 3; + readonly attribute optional nullable char_string<128> defaultNTP = 4; + readonly attribute optional TimeZoneStruct timeZone[] = 5; + readonly attribute optional DSTOffsetStruct DSTOffset[] = 6; + readonly attribute optional nullable epoch_us localTime = 7; + readonly attribute optional TimeZoneDatabaseEnum timeZoneDatabase = 8; + readonly attribute optional boolean NTPServerAvailable = 9; + readonly attribute optional int8u timeZoneListMaxSize = 10; + readonly attribute optional int8u DSTOffsetListMaxSize = 11; + readonly attribute optional boolean supportsDNSResolve = 12; + 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 SetUTCTimeRequest { + epoch_us UTCTime = 0; + GranularityEnum granularity = 1; + optional TimeSourceEnum timeSource = 2; + } + + request struct SetTrustedTimeSourceRequest { + nullable FabricScopedTrustedTimeSourceStruct trustedTimeSource = 0; + } + + request struct SetTimeZoneRequest { + TimeZoneStruct timeZone[] = 0; + } + + response struct SetTimeZoneResponse = 3 { + boolean DSTOffsetRequired = 0; + } + + request struct SetDSTOffsetRequest { + DSTOffsetStruct DSTOffset[] = 0; + } + + request struct SetDefaultNTPRequest { + nullable CHAR_STRING<128> defaultNTP = 0; + } + + /** This command MAY be issued by Administrator to set the time. */ + command access(invoke: administer) SetUTCTime(SetUTCTimeRequest): DefaultSuccess = 0; + /** This command SHALL set TrustedTimeSource. */ + fabric command access(invoke: administer) SetTrustedTimeSource(SetTrustedTimeSourceRequest): DefaultSuccess = 1; + /** This command SHALL set TimeZone. */ + command access(invoke: manage) SetTimeZone(SetTimeZoneRequest): SetTimeZoneResponse = 2; + /** This command SHALL set DSTOffset. */ + command access(invoke: manage) SetDSTOffset(SetDSTOffsetRequest): DefaultSuccess = 4; + /** This command is used to set DefaultNTP. */ + command access(invoke: administer) SetDefaultNTP(SetDefaultNTPRequest): DefaultSuccess = 5; +} + /** This Cluster serves two purposes towards a Node communicating with a Bridge: indicate that the functionality on the Endpoint where it is placed (and its Parts) is bridged from a non-CHIP technology; and provide a centralized collection of attributes that the Node MAY collect to aid in conveying information regarding the Bridged Device to a user, @@ -5445,6 +5591,7 @@ endpoint 1 { binding cluster ThreadNetworkDiagnostics; binding cluster WiFiNetworkDiagnostics; binding cluster EthernetNetworkDiagnostics; + binding cluster TimeSynchronization; binding cluster BridgedDeviceBasicInformation; binding cluster Switch; binding cluster AdministratorCommissioning; diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index baee7e2a4f6045..c992b1783b6e4e 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -7982,6 +7982,435 @@ } ] }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "SetUTCTime", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTrustedTimeSource", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetTimeZone", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetDSTOffset", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetDefaultNTP", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Synchronization", + "code": 56, + "mfgCode": null, + "define": "TIME_SYNCHRONIZATION_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "SetTimeZoneResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "UTCTime", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Granularity", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "GranularityEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSource", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "TimeSourceEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TrustedTimeSource", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "TrustedTimeSourceStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultNTP", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZone", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffset", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocalTime", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "epoch_us", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneDatabase", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "TimeZoneDatabaseEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NTPServerAvailable", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeZoneListMaxSize", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DSTOffsetListMaxSize", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "DSTTableEmpty", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DSTStatus", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeZoneStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "TimeFailure", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MissingTrustedTimeSource", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "Bridged Device Basic Information", "code": 57, @@ -16861,7 +17290,7 @@ "side": "server", "type": "LineupInfoStruct", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -16877,7 +17306,7 @@ "side": "server", "type": "ChannelInfoStruct", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -17389,7 +17818,7 @@ "side": "server", "type": "PlaybackPositionStruct", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -18599,7 +19028,7 @@ "side": "server", "type": "ApplicationEPStruct", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -18827,7 +19256,7 @@ "side": "server", "type": "ApplicationStruct", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 7f6ec70bd29dc8..ca74ac4a2b37b6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -5609,6 +5609,271 @@ public Map> getReadAttributeMap() { readEthernetNetworkDiagnosticsClusterRevisionAttributeInteractionInfo); readAttributeMap.put( "ethernetNetworkDiagnostics", readEthernetNetworkDiagnosticsInteractionInfo); + Map readTimeSynchronizationInteractionInfo = new LinkedHashMap<>(); + Map readTimeSynchronizationUTCTimeCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationUTCTimeAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readUTCTimeAttribute( + (ChipClusters.TimeSynchronizationCluster.UTCTimeAttributeCallback) callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterUTCTimeAttributeCallback(), + readTimeSynchronizationUTCTimeCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readUTCTimeAttribute", readTimeSynchronizationUTCTimeAttributeInteractionInfo); + Map readTimeSynchronizationGranularityCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationGranularityAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readGranularityAttribute((ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationGranularityCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readGranularityAttribute", readTimeSynchronizationGranularityAttributeInteractionInfo); + Map readTimeSynchronizationTimeSourceCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationTimeSourceAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readTimeSourceAttribute((ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationTimeSourceCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readTimeSourceAttribute", readTimeSynchronizationTimeSourceAttributeInteractionInfo); + Map readTimeSynchronizationDefaultNTPCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationDefaultNTPAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readDefaultNTPAttribute( + (ChipClusters.TimeSynchronizationCluster.DefaultNTPAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterDefaultNTPAttributeCallback(), + readTimeSynchronizationDefaultNTPCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readDefaultNTPAttribute", readTimeSynchronizationDefaultNTPAttributeInteractionInfo); + Map readTimeSynchronizationTimeZoneCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationTimeZoneAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readTimeZoneAttribute( + (ChipClusters.TimeSynchronizationCluster.TimeZoneAttributeCallback) callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterTimeZoneAttributeCallback(), + readTimeSynchronizationTimeZoneCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readTimeZoneAttribute", readTimeSynchronizationTimeZoneAttributeInteractionInfo); + Map readTimeSynchronizationDSTOffsetCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationDSTOffsetAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readDSTOffsetAttribute( + (ChipClusters.TimeSynchronizationCluster.DSTOffsetAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterDSTOffsetAttributeCallback(), + readTimeSynchronizationDSTOffsetCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readDSTOffsetAttribute", readTimeSynchronizationDSTOffsetAttributeInteractionInfo); + Map readTimeSynchronizationLocalTimeCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationLocalTimeAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readLocalTimeAttribute( + (ChipClusters.TimeSynchronizationCluster.LocalTimeAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterLocalTimeAttributeCallback(), + readTimeSynchronizationLocalTimeCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readLocalTimeAttribute", readTimeSynchronizationLocalTimeAttributeInteractionInfo); + Map readTimeSynchronizationTimeZoneDatabaseCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationTimeZoneDatabaseAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readTimeZoneDatabaseAttribute((ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationTimeZoneDatabaseCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readTimeZoneDatabaseAttribute", + readTimeSynchronizationTimeZoneDatabaseAttributeInteractionInfo); + Map readTimeSynchronizationNTPServerAvailableCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationNTPServerAvailableAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readNTPServerAvailableAttribute( + (ChipClusters.BooleanAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedBooleanAttributeCallback(), + readTimeSynchronizationNTPServerAvailableCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readNTPServerAvailableAttribute", + readTimeSynchronizationNTPServerAvailableAttributeInteractionInfo); + Map readTimeSynchronizationTimeZoneListMaxSizeCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationTimeZoneListMaxSizeAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readTimeZoneListMaxSizeAttribute( + (ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationTimeZoneListMaxSizeCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readTimeZoneListMaxSizeAttribute", + readTimeSynchronizationTimeZoneListMaxSizeAttributeInteractionInfo); + Map readTimeSynchronizationDSTOffsetListMaxSizeCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationDSTOffsetListMaxSizeAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readDSTOffsetListMaxSizeAttribute( + (ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationDSTOffsetListMaxSizeCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readDSTOffsetListMaxSizeAttribute", + readTimeSynchronizationDSTOffsetListMaxSizeAttributeInteractionInfo); + Map readTimeSynchronizationSupportsDNSResolveCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationSupportsDNSResolveAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readSupportsDNSResolveAttribute( + (ChipClusters.BooleanAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedBooleanAttributeCallback(), + readTimeSynchronizationSupportsDNSResolveCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readSupportsDNSResolveAttribute", + readTimeSynchronizationSupportsDNSResolveAttributeInteractionInfo); + Map readTimeSynchronizationGeneratedCommandListCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationGeneratedCommandListAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readGeneratedCommandListAttribute( + (ChipClusters.TimeSynchronizationCluster + .GeneratedCommandListAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterGeneratedCommandListAttributeCallback(), + readTimeSynchronizationGeneratedCommandListCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readGeneratedCommandListAttribute", + readTimeSynchronizationGeneratedCommandListAttributeInteractionInfo); + Map readTimeSynchronizationAcceptedCommandListCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationAcceptedCommandListAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readAcceptedCommandListAttribute( + (ChipClusters.TimeSynchronizationCluster.AcceptedCommandListAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterAcceptedCommandListAttributeCallback(), + readTimeSynchronizationAcceptedCommandListCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readAcceptedCommandListAttribute", + readTimeSynchronizationAcceptedCommandListAttributeInteractionInfo); + Map readTimeSynchronizationEventListCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationEventListAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readEventListAttribute( + (ChipClusters.TimeSynchronizationCluster.EventListAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterEventListAttributeCallback(), + readTimeSynchronizationEventListCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readEventListAttribute", readTimeSynchronizationEventListAttributeInteractionInfo); + Map readTimeSynchronizationAttributeListCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationAttributeListAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readAttributeListAttribute( + (ChipClusters.TimeSynchronizationCluster.AttributeListAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterAttributeListAttributeCallback(), + readTimeSynchronizationAttributeListCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readAttributeListAttribute", readTimeSynchronizationAttributeListAttributeInteractionInfo); + Map readTimeSynchronizationFeatureMapCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationFeatureMapAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readFeatureMapAttribute((ChipClusters.LongAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + readTimeSynchronizationFeatureMapCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readFeatureMapAttribute", readTimeSynchronizationFeatureMapAttributeInteractionInfo); + Map readTimeSynchronizationClusterRevisionCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationClusterRevisionAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readClusterRevisionAttribute((ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readTimeSynchronizationClusterRevisionCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readClusterRevisionAttribute", + readTimeSynchronizationClusterRevisionAttributeInteractionInfo); + readAttributeMap.put("timeSynchronization", readTimeSynchronizationInteractionInfo); Map readBridgedDeviceBasicInformationInteractionInfo = new LinkedHashMap<>(); Map readBridgedDeviceBasicInformationVendorNameCommandParams = diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index e50aed4bfa0f08..3e4427aa2bbbf8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -553,6 +553,8 @@ public Map> getWriteAttributeMap() { new LinkedHashMap<>(); writeAttributeMap.put( "ethernetNetworkDiagnostics", writeEthernetNetworkDiagnosticsInteractionInfo); + Map writeTimeSynchronizationInteractionInfo = new LinkedHashMap<>(); + writeAttributeMap.put("timeSynchronization", writeTimeSynchronizationInteractionInfo); Map writeBridgedDeviceBasicInformationInteractionInfo = new LinkedHashMap<>(); Map writeBridgedDeviceBasicInformationNodeLabelCommandParams = diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 9790f0e75b3306..17d632ff035893 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -8643,6 +8643,493 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } break; } + case app::Clusters::TimeSynchronization::Id: { + using namespace app::Clusters::TimeSynchronization; + switch (aPath.mAttributeId) + { + case Attributes::UTCTime::Id: { + using TypeInfo = Attributes::UTCTime::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue.Value(), value); + } + return value; + } + case Attributes::Granularity::Id: { + using TypeInfo = Attributes::Granularity::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + static_cast(cppValue), value); + return value; + } + case Attributes::TimeSource::Id: { + using TypeInfo = Attributes::TimeSource::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + static_cast(cppValue), value); + return value; + } + case Attributes::TrustedTimeSource::Id: { + using TypeInfo = Attributes::TrustedTimeSource::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_fabricIndex; + std::string value_fabricIndexClassName = "java/lang/Integer"; + std::string value_fabricIndexCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(value_fabricIndexClassName.c_str(), + value_fabricIndexCtorSignature.c_str(), + cppValue.Value().fabricIndex, value_fabricIndex); + jobject value_nodeID; + std::string value_nodeIDClassName = "java/lang/Long"; + std::string value_nodeIDCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + value_nodeIDClassName.c_str(), value_nodeIDCtorSignature.c_str(), cppValue.Value().nodeID, value_nodeID); + jobject value_endpoint; + std::string value_endpointClassName = "java/lang/Integer"; + std::string value_endpointCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(value_endpointClassName.c_str(), + value_endpointCtorSignature.c_str(), + cppValue.Value().endpoint, value_endpoint); + + jclass trustedTimeSourceStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct", + trustedTimeSourceStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct"); + return nullptr; + } + jmethodID trustedTimeSourceStructStructCtor_1 = env->GetMethodID( + trustedTimeSourceStructStructClass_1, "", "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (trustedTimeSourceStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct constructor"); + return nullptr; + } + + value = env->NewObject(trustedTimeSourceStructStructClass_1, trustedTimeSourceStructStructCtor_1, value_fabricIndex, + value_nodeID, value_endpoint); + } + return value; + } + case Attributes::DefaultNTP::Id: { + using TypeInfo = Attributes::DefaultNTP::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value(), value)); + } + return value; + } + case Attributes::TimeZone::Id: { + using TypeInfo = Attributes::TimeZone::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + jobject newElement_0_offset; + std::string newElement_0_offsetClassName = "java/lang/Long"; + std::string newElement_0_offsetCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_offsetClassName.c_str(), + newElement_0_offsetCtorSignature.c_str(), + entry_0.offset, newElement_0_offset); + jobject newElement_0_validAt; + std::string newElement_0_validAtClassName = "java/lang/Long"; + std::string newElement_0_validAtCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_validAtClassName.c_str(), + newElement_0_validAtCtorSignature.c_str(), + entry_0.validAt, newElement_0_validAt); + jobject newElement_0_name; + if (!entry_0.name.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_name); + } + else + { + jobject newElement_0_nameInsideOptional; + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); + } + + jclass timeZoneStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTimeZoneStruct", timeZoneStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterTimeZoneStruct"); + return nullptr; + } + jmethodID timeZoneStructStructCtor_1 = env->GetMethodID(timeZoneStructStructClass_1, "", + "(Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;)V"); + if (timeZoneStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterTimeZoneStruct constructor"); + return nullptr; + } + + newElement_0 = env->NewObject(timeZoneStructStructClass_1, timeZoneStructStructCtor_1, newElement_0_offset, + newElement_0_validAt, newElement_0_name); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::DSTOffset::Id: { + using TypeInfo = Attributes::DSTOffset::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + jobject newElement_0_offset; + std::string newElement_0_offsetClassName = "java/lang/Long"; + std::string newElement_0_offsetCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_offsetClassName.c_str(), + newElement_0_offsetCtorSignature.c_str(), + entry_0.offset, newElement_0_offset); + jobject newElement_0_validStarting; + std::string newElement_0_validStartingClassName = "java/lang/Long"; + std::string newElement_0_validStartingCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_validStartingClassName.c_str(), + newElement_0_validStartingCtorSignature.c_str(), + entry_0.validStarting, newElement_0_validStarting); + jobject newElement_0_validUntil; + if (entry_0.validUntil.IsNull()) + { + newElement_0_validUntil = nullptr; + } + else + { + std::string newElement_0_validUntilClassName = "java/lang/Long"; + std::string newElement_0_validUntilCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_validUntilClassName.c_str(), newElement_0_validUntilCtorSignature.c_str(), + entry_0.validUntil.Value(), newElement_0_validUntil); + } + + jclass DSTOffsetStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterDSTOffsetStruct", + DSTOffsetStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterDSTOffsetStruct"); + return nullptr; + } + jmethodID DSTOffsetStructStructCtor_1 = + env->GetMethodID(DSTOffsetStructStructClass_1, "", "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;)V"); + if (DSTOffsetStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterDSTOffsetStruct constructor"); + return nullptr; + } + + newElement_0 = env->NewObject(DSTOffsetStructStructClass_1, DSTOffsetStructStructCtor_1, newElement_0_offset, + newElement_0_validStarting, newElement_0_validUntil); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::LocalTime::Id: { + using TypeInfo = Attributes::LocalTime::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue.Value(), value); + } + return value; + } + case Attributes::TimeZoneDatabase::Id: { + using TypeInfo = Attributes::TimeZoneDatabase::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + static_cast(cppValue), value); + return value; + } + case Attributes::NTPServerAvailable::Id: { + using TypeInfo = Attributes::NTPServerAvailable::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Boolean"; + std::string valueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), cppValue, + value); + return value; + } + case Attributes::TimeZoneListMaxSize::Id: { + using TypeInfo = Attributes::TimeZoneListMaxSize::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); + return value; + } + case Attributes::DSTOffsetListMaxSize::Id: { + using TypeInfo = Attributes::DSTOffsetListMaxSize::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); + return value; + } + case Attributes::SupportsDNSResolve::Id: { + using TypeInfo = Attributes::SupportsDNSResolve::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Boolean"; + std::string valueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), cppValue, + value); + return value; + } + case Attributes::GeneratedCommandList::Id: { + using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AcceptedCommandList::Id: { + using TypeInfo = Attributes::AcceptedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::EventList::Id: { + using TypeInfo = Attributes::EventList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::AttributeList::Id: { + using TypeInfo = Attributes::AttributeList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_0 = cppValue.begin(); + while (iter_value_0.Next()) + { + auto & entry_0 = iter_value_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(value, newElement_0); + } + return value; + } + case Attributes::FeatureMap::Id: { + using TypeInfo = Attributes::FeatureMap::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); + return value; + } + case Attributes::ClusterRevision::Id: { + using TypeInfo = Attributes::ClusterRevision::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + break; + } + break; + } case app::Clusters::BridgedDeviceBasicInformation::Id: { using namespace app::Clusters::BridgedDeviceBasicInformation; switch (aPath.mAttributeId) diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 71c20ae30036fe..6b6054efaa9de9 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -1707,6 +1707,177 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } break; } + case app::Clusters::TimeSynchronization::Id: { + using namespace app::Clusters::TimeSynchronization; + switch (aPath.mEventId) + { + case Events::DSTTableEmpty::Id: { + Events::DSTTableEmpty::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jclass DSTTableEmptyStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterDSTTableEmptyEvent", + DSTTableEmptyStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$TimeSynchronizationClusterDSTTableEmptyEvent"); + return nullptr; + } + jmethodID DSTTableEmptyStructCtor = env->GetMethodID(DSTTableEmptyStructClass, "", "()V"); + if (DSTTableEmptyStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$TimeSynchronizationClusterDSTTableEmptyEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(DSTTableEmptyStructClass, DSTTableEmptyStructCtor); + + return value; + } + case Events::DSTStatus::Id: { + Events::DSTStatus::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_DSTOffsetActive; + std::string value_DSTOffsetActiveClassName = "java/lang/Boolean"; + std::string value_DSTOffsetActiveCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(value_DSTOffsetActiveClassName.c_str(), + value_DSTOffsetActiveCtorSignature.c_str(), + cppValue.DSTOffsetActive, value_DSTOffsetActive); + + jclass DSTStatusStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterDSTStatusEvent", DSTStatusStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$TimeSynchronizationClusterDSTStatusEvent"); + return nullptr; + } + jmethodID DSTStatusStructCtor = env->GetMethodID(DSTStatusStructClass, "", "(Ljava/lang/Boolean;)V"); + if (DSTStatusStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$TimeSynchronizationClusterDSTStatusEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(DSTStatusStructClass, DSTStatusStructCtor, value_DSTOffsetActive); + + return value; + } + case Events::TimeZoneStatus::Id: { + Events::TimeZoneStatus::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_offset; + std::string value_offsetClassName = "java/lang/Long"; + std::string value_offsetCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + value_offsetClassName.c_str(), value_offsetCtorSignature.c_str(), cppValue.offset, value_offset); + + jobject value_name; + if (!cppValue.name.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_name); + } + else + { + jobject value_nameInsideOptional; + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(cppValue.name.Value(), value_nameInsideOptional)); + chip::JniReferences::GetInstance().CreateOptional(value_nameInsideOptional, value_name); + } + + jclass timeZoneStatusStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterTimeZoneStatusEvent", + timeZoneStatusStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$TimeSynchronizationClusterTimeZoneStatusEvent"); + return nullptr; + } + jmethodID timeZoneStatusStructCtor = + env->GetMethodID(timeZoneStatusStructClass, "", "(Ljava/lang/Long;Ljava/util/Optional;)V"); + if (timeZoneStatusStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$TimeSynchronizationClusterTimeZoneStatusEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(timeZoneStatusStructClass, timeZoneStatusStructCtor, value_offset, value_name); + + return value; + } + case Events::TimeFailure::Id: { + Events::TimeFailure::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jclass timeFailureStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterTimeFailureEvent", timeFailureStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$TimeSynchronizationClusterTimeFailureEvent"); + return nullptr; + } + jmethodID timeFailureStructCtor = env->GetMethodID(timeFailureStructClass, "", "()V"); + if (timeFailureStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$TimeSynchronizationClusterTimeFailureEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(timeFailureStructClass, timeFailureStructCtor); + + return value; + } + case Events::MissingTrustedTimeSource::Id: { + Events::MissingTrustedTimeSource::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jclass missingTrustedTimeSourceStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$TimeSynchronizationClusterMissingTrustedTimeSourceEvent", + missingTrustedTimeSourceStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$TimeSynchronizationClusterMissingTrustedTimeSourceEvent"); + return nullptr; + } + jmethodID missingTrustedTimeSourceStructCtor = env->GetMethodID(missingTrustedTimeSourceStructClass, "", "()V"); + if (missingTrustedTimeSourceStructCtor == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipEventStructs$TimeSynchronizationClusterMissingTrustedTimeSourceEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(missingTrustedTimeSourceStructClass, missingTrustedTimeSourceStructCtor); + + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + break; + } + break; + } case app::Clusters::BridgedDeviceBasicInformation::Id: { using namespace app::Clusters::BridgedDeviceBasicInformation; switch (aPath.mEventId) diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index 2fb5e13227f298..7f33a36936658f 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -2174,6 +2174,68 @@ void CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, Status, LogContent, UTCTimeStamp, TimeSinceBoot); } +CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback( + jobject javaCallback) : + Callback::Callback(CallbackFn, this) +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::~CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback() +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +}; + +void CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback::CallbackFn( + void * context, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & dataResponse) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + jmethodID javaMethod; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); + + std::unique_ptr + cppCallback(reinterpret_cast(context), + chip::Platform::Delete); + VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); + + javaCallbackRef = cppCallback->javaCallbackRef; + // Java callback is allowed to be null, exit early if this is the case. + VerifyOrReturn(javaCallbackRef != nullptr); + + err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); + + jobject DSTOffsetRequired; + std::string DSTOffsetRequiredClassName = "java/lang/Boolean"; + std::string DSTOffsetRequiredCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(DSTOffsetRequiredClassName.c_str(), + DSTOffsetRequiredCtorSignature.c_str(), + dataResponse.DSTOffsetRequired, DSTOffsetRequired); + + env->CallVoidMethod(javaCallbackRef, javaMethod, DSTOffsetRequired); +} CHIPOperationalCredentialsClusterAttestationResponseCallback::CHIPOperationalCredentialsClusterAttestationResponseCallback( jobject javaCallback) : Callback::Callback(CallbackFn, this) diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.h b/src/controller/java/zap-generated/CHIPInvokeCallbacks.h index 5a264fb1994368..c0360e7b50a881 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.h +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.h @@ -342,6 +342,21 @@ class CHIPDiagnosticLogsClusterRetrieveLogsResponseCallback jobject javaCallbackRef; }; +class CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback + : public Callback::Callback +{ +public: + CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback(jobject javaCallback); + + ~CHIPTimeSynchronizationClusterSetTimeZoneResponseCallback(); + + static void CallbackFn(void * context, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data); + +private: + jobject javaCallbackRef; +}; + class CHIPOperationalCredentialsClusterAttestationResponseCallback : public Callback::Callback { diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index 198aa3b31806bc..2a75fcbe420ff8 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -14287,6 +14287,711 @@ void CHIPEthernetNetworkDiagnosticsAttributeListAttributeCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); } +CHIPTimeSynchronizationUTCTimeAttributeCallback::CHIPTimeSynchronizationUTCTimeAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationUTCTimeAttributeCallback::~CHIPTimeSynchronizationUTCTimeAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationUTCTimeAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Long"; + std::string javaValueCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + value.Value(), javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPTimeSynchronizationDefaultNTPAttributeCallback::CHIPTimeSynchronizationDefaultNTPAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationDefaultNTPAttributeCallback::~CHIPTimeSynchronizationDefaultNTPAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationDefaultNTPAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/String;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(value.Value(), javaValue)); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPTimeSynchronizationTimeZoneAttributeCallback::CHIPTimeSynchronizationTimeZoneAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationTimeZoneAttributeCallback::~CHIPTimeSynchronizationTimeZoneAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationTimeZoneAttributeCallback::CallbackFn( + void * context, + const chip::app::DataModel::DecodableList & + list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + jobject newElement_0_offset; + std::string newElement_0_offsetClassName = "java/lang/Long"; + std::string newElement_0_offsetCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_offsetClassName.c_str(), newElement_0_offsetCtorSignature.c_str(), entry_0.offset, newElement_0_offset); + jobject newElement_0_validAt; + std::string newElement_0_validAtClassName = "java/lang/Long"; + std::string newElement_0_validAtCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_validAtClassName.c_str(), + newElement_0_validAtCtorSignature.c_str(), entry_0.validAt, + newElement_0_validAt); + jobject newElement_0_name; + if (!entry_0.name.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_name); + } + else + { + jobject newElement_0_nameInsideOptional; + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); + } + + jclass timeZoneStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTimeZoneStruct", timeZoneStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterTimeZoneStruct"); + return; + } + jmethodID timeZoneStructStructCtor_1 = + env->GetMethodID(timeZoneStructStructClass_1, "", "(Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;)V"); + if (timeZoneStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterTimeZoneStruct constructor"); + return; + } + + newElement_0 = env->NewObject(timeZoneStructStructClass_1, timeZoneStructStructCtor_1, newElement_0_offset, + newElement_0_validAt, newElement_0_name); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPTimeSynchronizationDSTOffsetAttributeCallback::CHIPTimeSynchronizationDSTOffsetAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationDSTOffsetAttributeCallback::~CHIPTimeSynchronizationDSTOffsetAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationDSTOffsetAttributeCallback::CallbackFn( + void * context, + const chip::app::DataModel::DecodableList & + list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + jobject newElement_0_offset; + std::string newElement_0_offsetClassName = "java/lang/Long"; + std::string newElement_0_offsetCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_offsetClassName.c_str(), newElement_0_offsetCtorSignature.c_str(), entry_0.offset, newElement_0_offset); + jobject newElement_0_validStarting; + std::string newElement_0_validStartingClassName = "java/lang/Long"; + std::string newElement_0_validStartingCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_validStartingClassName.c_str(), + newElement_0_validStartingCtorSignature.c_str(), + entry_0.validStarting, newElement_0_validStarting); + jobject newElement_0_validUntil; + if (entry_0.validUntil.IsNull()) + { + newElement_0_validUntil = nullptr; + } + else + { + std::string newElement_0_validUntilClassName = "java/lang/Long"; + std::string newElement_0_validUntilCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0_validUntilClassName.c_str(), + newElement_0_validUntilCtorSignature.c_str(), + entry_0.validUntil.Value(), newElement_0_validUntil); + } + + jclass DSTOffsetStructStructClass_1; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterDSTOffsetStruct", DSTOffsetStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterDSTOffsetStruct"); + return; + } + jmethodID DSTOffsetStructStructCtor_1 = + env->GetMethodID(DSTOffsetStructStructClass_1, "", "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;)V"); + if (DSTOffsetStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterDSTOffsetStruct constructor"); + return; + } + + newElement_0 = env->NewObject(DSTOffsetStructStructClass_1, DSTOffsetStructStructCtor_1, newElement_0_offset, + newElement_0_validStarting, newElement_0_validUntil); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPTimeSynchronizationLocalTimeAttributeCallback::CHIPTimeSynchronizationLocalTimeAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationLocalTimeAttributeCallback::~CHIPTimeSynchronizationLocalTimeAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationLocalTimeAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Long;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Long"; + std::string javaValueCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + value.Value(), javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPTimeSynchronizationGeneratedCommandListAttributeCallback::CHIPTimeSynchronizationGeneratedCommandListAttributeCallback( + jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationGeneratedCommandListAttributeCallback::~CHIPTimeSynchronizationGeneratedCommandListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationGeneratedCommandListAttributeCallback::CallbackFn( + void * context, const chip::app::DataModel::DecodableList & list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), + newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPTimeSynchronizationAcceptedCommandListAttributeCallback::CHIPTimeSynchronizationAcceptedCommandListAttributeCallback( + jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationAcceptedCommandListAttributeCallback::~CHIPTimeSynchronizationAcceptedCommandListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationAcceptedCommandListAttributeCallback::CallbackFn( + void * context, const chip::app::DataModel::DecodableList & list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), + newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPTimeSynchronizationEventListAttributeCallback::CHIPTimeSynchronizationEventListAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationEventListAttributeCallback::~CHIPTimeSynchronizationEventListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationEventListAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::DecodableList & list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), + newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPTimeSynchronizationAttributeListAttributeCallback::CHIPTimeSynchronizationAttributeListAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPTimeSynchronizationAttributeListAttributeCallback::~CHIPTimeSynchronizationAttributeListAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationAttributeListAttributeCallback::CallbackFn( + void * context, const chip::app::DataModel::DecodableList & list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject arrayListObj; + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_0 = list.begin(); + while (iter_arrayListObj_0.Next()) + { + auto & entry_0 = iter_arrayListObj_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Long"; + std::string newElement_0CtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_0ClassName.c_str(), + newElement_0CtorSignature.c_str(), entry_0, newElement_0); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + CHIPBridgedDeviceBasicInformationGeneratedCommandListAttributeCallback:: CHIPBridgedDeviceBasicInformationGeneratedCommandListAttributeCallback(jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, this), diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 9bf694f16f5f5a..e92aa695585646 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -10171,6 +10171,480 @@ private native void subscribeClusterRevisionAttribute( long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); } + public static class TimeSynchronizationCluster extends BaseChipCluster { + public static final long CLUSTER_ID = 56L; + + public TimeSynchronizationCluster(long devicePtr, int endpointId) { + super(devicePtr, endpointId); + } + + @Override + public native long initWithDevice(long devicePtr, int endpointId); + + public void setUTCTime( + DefaultClusterCallback callback, + Long UTCTime, + Integer granularity, + Optional timeSource) { + setUTCTime(chipClusterPtr, callback, UTCTime, granularity, timeSource, null); + } + + public void setUTCTime( + DefaultClusterCallback callback, + Long UTCTime, + Integer granularity, + Optional timeSource, + int timedInvokeTimeoutMs) { + setUTCTime(chipClusterPtr, callback, UTCTime, granularity, timeSource, timedInvokeTimeoutMs); + } + + public void setTrustedTimeSource( + DefaultClusterCallback callback, + @Nullable + ChipStructs.TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct + trustedTimeSource) { + setTrustedTimeSource(chipClusterPtr, callback, trustedTimeSource, null); + } + + public void setTrustedTimeSource( + DefaultClusterCallback callback, + @Nullable + ChipStructs.TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct + trustedTimeSource, + int timedInvokeTimeoutMs) { + setTrustedTimeSource(chipClusterPtr, callback, trustedTimeSource, timedInvokeTimeoutMs); + } + + public void setTimeZone( + SetTimeZoneResponseCallback callback, + ArrayList timeZone) { + setTimeZone(chipClusterPtr, callback, timeZone, null); + } + + public void setTimeZone( + SetTimeZoneResponseCallback callback, + ArrayList timeZone, + int timedInvokeTimeoutMs) { + setTimeZone(chipClusterPtr, callback, timeZone, timedInvokeTimeoutMs); + } + + public void setDSTOffset( + DefaultClusterCallback callback, + ArrayList DSTOffset) { + setDSTOffset(chipClusterPtr, callback, DSTOffset, null); + } + + public void setDSTOffset( + DefaultClusterCallback callback, + ArrayList DSTOffset, + int timedInvokeTimeoutMs) { + setDSTOffset(chipClusterPtr, callback, DSTOffset, timedInvokeTimeoutMs); + } + + public void setDefaultNTP(DefaultClusterCallback callback, @Nullable String defaultNTP) { + setDefaultNTP(chipClusterPtr, callback, defaultNTP, null); + } + + public void setDefaultNTP( + DefaultClusterCallback callback, @Nullable String defaultNTP, int timedInvokeTimeoutMs) { + setDefaultNTP(chipClusterPtr, callback, defaultNTP, timedInvokeTimeoutMs); + } + + private native void setUTCTime( + long chipClusterPtr, + DefaultClusterCallback Callback, + Long UTCTime, + Integer granularity, + Optional timeSource, + @Nullable Integer timedInvokeTimeoutMs); + + private native void setTrustedTimeSource( + long chipClusterPtr, + DefaultClusterCallback Callback, + @Nullable + ChipStructs.TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct + trustedTimeSource, + @Nullable Integer timedInvokeTimeoutMs); + + private native void setTimeZone( + long chipClusterPtr, + SetTimeZoneResponseCallback Callback, + ArrayList timeZone, + @Nullable Integer timedInvokeTimeoutMs); + + private native void setDSTOffset( + long chipClusterPtr, + DefaultClusterCallback Callback, + ArrayList DSTOffset, + @Nullable Integer timedInvokeTimeoutMs); + + private native void setDefaultNTP( + long chipClusterPtr, + DefaultClusterCallback Callback, + @Nullable String defaultNTP, + @Nullable Integer timedInvokeTimeoutMs); + + public interface SetTimeZoneResponseCallback { + void onSuccess(Boolean DSTOffsetRequired); + + void onError(Exception error); + } + + public interface UTCTimeAttributeCallback { + void onSuccess(@Nullable Long value); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface DefaultNTPAttributeCallback { + void onSuccess(@Nullable String value); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface TimeZoneAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface DSTOffsetAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface LocalTimeAttributeCallback { + void onSuccess(@Nullable Long value); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface GeneratedCommandListAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface AcceptedCommandListAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface EventListAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public interface AttributeListAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished(long subscriptionId) {} + } + + public void readUTCTimeAttribute(UTCTimeAttributeCallback callback) { + readUTCTimeAttribute(chipClusterPtr, callback); + } + + public void subscribeUTCTimeAttribute( + UTCTimeAttributeCallback callback, int minInterval, int maxInterval) { + subscribeUTCTimeAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readGranularityAttribute(IntegerAttributeCallback callback) { + readGranularityAttribute(chipClusterPtr, callback); + } + + public void subscribeGranularityAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeGranularityAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readTimeSourceAttribute(IntegerAttributeCallback callback) { + readTimeSourceAttribute(chipClusterPtr, callback); + } + + public void subscribeTimeSourceAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeTimeSourceAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readDefaultNTPAttribute(DefaultNTPAttributeCallback callback) { + readDefaultNTPAttribute(chipClusterPtr, callback); + } + + public void subscribeDefaultNTPAttribute( + DefaultNTPAttributeCallback callback, int minInterval, int maxInterval) { + subscribeDefaultNTPAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readTimeZoneAttribute(TimeZoneAttributeCallback callback) { + readTimeZoneAttribute(chipClusterPtr, callback); + } + + public void subscribeTimeZoneAttribute( + TimeZoneAttributeCallback callback, int minInterval, int maxInterval) { + subscribeTimeZoneAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readDSTOffsetAttribute(DSTOffsetAttributeCallback callback) { + readDSTOffsetAttribute(chipClusterPtr, callback); + } + + public void subscribeDSTOffsetAttribute( + DSTOffsetAttributeCallback callback, int minInterval, int maxInterval) { + subscribeDSTOffsetAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readLocalTimeAttribute(LocalTimeAttributeCallback callback) { + readLocalTimeAttribute(chipClusterPtr, callback); + } + + public void subscribeLocalTimeAttribute( + LocalTimeAttributeCallback callback, int minInterval, int maxInterval) { + subscribeLocalTimeAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readTimeZoneDatabaseAttribute(IntegerAttributeCallback callback) { + readTimeZoneDatabaseAttribute(chipClusterPtr, callback); + } + + public void subscribeTimeZoneDatabaseAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeTimeZoneDatabaseAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readNTPServerAvailableAttribute(BooleanAttributeCallback callback) { + readNTPServerAvailableAttribute(chipClusterPtr, callback); + } + + public void subscribeNTPServerAvailableAttribute( + BooleanAttributeCallback callback, int minInterval, int maxInterval) { + subscribeNTPServerAvailableAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readTimeZoneListMaxSizeAttribute(IntegerAttributeCallback callback) { + readTimeZoneListMaxSizeAttribute(chipClusterPtr, callback); + } + + public void subscribeTimeZoneListMaxSizeAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeTimeZoneListMaxSizeAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readDSTOffsetListMaxSizeAttribute(IntegerAttributeCallback callback) { + readDSTOffsetListMaxSizeAttribute(chipClusterPtr, callback); + } + + public void subscribeDSTOffsetListMaxSizeAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeDSTOffsetListMaxSizeAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readSupportsDNSResolveAttribute(BooleanAttributeCallback callback) { + readSupportsDNSResolveAttribute(chipClusterPtr, callback); + } + + public void subscribeSupportsDNSResolveAttribute( + BooleanAttributeCallback callback, int minInterval, int maxInterval) { + subscribeSupportsDNSResolveAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readGeneratedCommandListAttribute(GeneratedCommandListAttributeCallback callback) { + readGeneratedCommandListAttribute(chipClusterPtr, callback); + } + + public void subscribeGeneratedCommandListAttribute( + GeneratedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + subscribeGeneratedCommandListAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readAcceptedCommandListAttribute(AcceptedCommandListAttributeCallback callback) { + readAcceptedCommandListAttribute(chipClusterPtr, callback); + } + + public void subscribeAcceptedCommandListAttribute( + AcceptedCommandListAttributeCallback callback, int minInterval, int maxInterval) { + subscribeAcceptedCommandListAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readEventListAttribute(EventListAttributeCallback callback) { + readEventListAttribute(chipClusterPtr, callback); + } + + public void subscribeEventListAttribute( + EventListAttributeCallback callback, int minInterval, int maxInterval) { + subscribeEventListAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readAttributeListAttribute(AttributeListAttributeCallback callback) { + readAttributeListAttribute(chipClusterPtr, callback); + } + + public void subscribeAttributeListAttribute( + AttributeListAttributeCallback callback, int minInterval, int maxInterval) { + subscribeAttributeListAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readFeatureMapAttribute(LongAttributeCallback callback) { + readFeatureMapAttribute(chipClusterPtr, callback); + } + + public void subscribeFeatureMapAttribute( + LongAttributeCallback callback, int minInterval, int maxInterval) { + subscribeFeatureMapAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readClusterRevisionAttribute(IntegerAttributeCallback callback) { + readClusterRevisionAttribute(chipClusterPtr, callback); + } + + public void subscribeClusterRevisionAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeClusterRevisionAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + private native void readUTCTimeAttribute( + long chipClusterPtr, UTCTimeAttributeCallback callback); + + private native void subscribeUTCTimeAttribute( + long chipClusterPtr, UTCTimeAttributeCallback callback, int minInterval, int maxInterval); + + private native void readGranularityAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeGranularityAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readTimeSourceAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeTimeSourceAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readDefaultNTPAttribute( + long chipClusterPtr, DefaultNTPAttributeCallback callback); + + private native void subscribeDefaultNTPAttribute( + long chipClusterPtr, + DefaultNTPAttributeCallback callback, + int minInterval, + int maxInterval); + + private native void readTimeZoneAttribute( + long chipClusterPtr, TimeZoneAttributeCallback callback); + + private native void subscribeTimeZoneAttribute( + long chipClusterPtr, TimeZoneAttributeCallback callback, int minInterval, int maxInterval); + + private native void readDSTOffsetAttribute( + long chipClusterPtr, DSTOffsetAttributeCallback callback); + + private native void subscribeDSTOffsetAttribute( + long chipClusterPtr, DSTOffsetAttributeCallback callback, int minInterval, int maxInterval); + + private native void readLocalTimeAttribute( + long chipClusterPtr, LocalTimeAttributeCallback callback); + + private native void subscribeLocalTimeAttribute( + long chipClusterPtr, LocalTimeAttributeCallback callback, int minInterval, int maxInterval); + + private native void readTimeZoneDatabaseAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeTimeZoneDatabaseAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readNTPServerAvailableAttribute( + long chipClusterPtr, BooleanAttributeCallback callback); + + private native void subscribeNTPServerAvailableAttribute( + long chipClusterPtr, BooleanAttributeCallback callback, int minInterval, int maxInterval); + + private native void readTimeZoneListMaxSizeAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeTimeZoneListMaxSizeAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readDSTOffsetListMaxSizeAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeDSTOffsetListMaxSizeAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readSupportsDNSResolveAttribute( + long chipClusterPtr, BooleanAttributeCallback callback); + + private native void subscribeSupportsDNSResolveAttribute( + long chipClusterPtr, BooleanAttributeCallback callback, int minInterval, int maxInterval); + + private native void readGeneratedCommandListAttribute( + long chipClusterPtr, GeneratedCommandListAttributeCallback callback); + + private native void subscribeGeneratedCommandListAttribute( + long chipClusterPtr, + GeneratedCommandListAttributeCallback callback, + int minInterval, + int maxInterval); + + private native void readAcceptedCommandListAttribute( + long chipClusterPtr, AcceptedCommandListAttributeCallback callback); + + private native void subscribeAcceptedCommandListAttribute( + long chipClusterPtr, + AcceptedCommandListAttributeCallback callback, + int minInterval, + int maxInterval); + + private native void readEventListAttribute( + long chipClusterPtr, EventListAttributeCallback callback); + + private native void subscribeEventListAttribute( + long chipClusterPtr, EventListAttributeCallback callback, int minInterval, int maxInterval); + + private native void readAttributeListAttribute( + long chipClusterPtr, AttributeListAttributeCallback callback); + + private native void subscribeAttributeListAttribute( + long chipClusterPtr, + AttributeListAttributeCallback callback, + int minInterval, + int maxInterval); + + private native void readFeatureMapAttribute( + long chipClusterPtr, LongAttributeCallback callback); + + private native void subscribeFeatureMapAttribute( + long chipClusterPtr, LongAttributeCallback callback, int minInterval, int maxInterval); + + private native void readClusterRevisionAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeClusterRevisionAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + } + public static class BridgedDeviceBasicInformationCluster extends BaseChipCluster { public static final long CLUSTER_ID = 57L; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java index 9f079111c14841..222ed166cc4333 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java @@ -653,6 +653,88 @@ public String toString() { } } + public static class TimeSynchronizationClusterDSTTableEmptyEvent { + + public TimeSynchronizationClusterDSTTableEmptyEvent() {} + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterDSTTableEmptyEvent {\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterDSTStatusEvent { + public Boolean DSTOffsetActive; + + public TimeSynchronizationClusterDSTStatusEvent(Boolean DSTOffsetActive) { + this.DSTOffsetActive = DSTOffsetActive; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterDSTStatusEvent {\n"); + output.append("\tDSTOffsetActive: "); + output.append(DSTOffsetActive); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterTimeZoneStatusEvent { + public Long offset; + public Optional name; + + public TimeSynchronizationClusterTimeZoneStatusEvent(Long offset, Optional name) { + this.offset = offset; + this.name = name; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterTimeZoneStatusEvent {\n"); + output.append("\toffset: "); + output.append(offset); + output.append("\n"); + output.append("\tname: "); + output.append(name); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterTimeFailureEvent { + + public TimeSynchronizationClusterTimeFailureEvent() {} + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterTimeFailureEvent {\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterMissingTrustedTimeSourceEvent { + + public TimeSynchronizationClusterMissingTrustedTimeSourceEvent() {} + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterMissingTrustedTimeSourceEvent {\n"); + output.append("}\n"); + return output.toString(); + } + } + public static class BridgedDeviceBasicInformationClusterStartUpEvent { public Long softwareVersion; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java index b50c4ff62cc48e..b9dd21a16d785d 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java @@ -106,6 +106,9 @@ public static String clusterIdToName(long clusterId) { if (clusterId == 55L) { return "EthernetNetworkDiagnostics"; } + if (clusterId == 56L) { + return "TimeSynchronization"; + } if (clusterId == 57L) { return "BridgedDeviceBasicInformation"; } @@ -1473,6 +1476,66 @@ public static String attributeIdToName(long clusterId, long attributeId) { } return ""; } + if (clusterId == 56L) { + if (attributeId == 0L) { + return "UTCTime"; + } + if (attributeId == 1L) { + return "Granularity"; + } + if (attributeId == 2L) { + return "TimeSource"; + } + if (attributeId == 3L) { + return "TrustedTimeSource"; + } + if (attributeId == 4L) { + return "DefaultNTP"; + } + if (attributeId == 5L) { + return "TimeZone"; + } + if (attributeId == 6L) { + return "DSTOffset"; + } + if (attributeId == 7L) { + return "LocalTime"; + } + if (attributeId == 8L) { + return "TimeZoneDatabase"; + } + if (attributeId == 9L) { + return "NTPServerAvailable"; + } + if (attributeId == 10L) { + return "TimeZoneListMaxSize"; + } + if (attributeId == 11L) { + return "DSTOffsetListMaxSize"; + } + if (attributeId == 12L) { + return "SupportsDNSResolve"; + } + if (attributeId == 65528L) { + return "GeneratedCommandList"; + } + if (attributeId == 65529L) { + return "AcceptedCommandList"; + } + if (attributeId == 65530L) { + return "EventList"; + } + if (attributeId == 65531L) { + return "AttributeList"; + } + if (attributeId == 65532L) { + return "FeatureMap"; + } + if (attributeId == 65533L) { + return "ClusterRevision"; + } + return ""; + } if (clusterId == 57L) { if (attributeId == 1L) { return "VendorName"; @@ -4046,6 +4109,24 @@ public static String eventIdToName(long clusterId, long eventId) { if (clusterId == 55L) { return ""; } + if (clusterId == 56L) { + if (eventId == 0L) { + return "DSTTableEmpty"; + } + if (eventId == 1L) { + return "DSTStatus"; + } + if (eventId == 2L) { + return "TimeZoneStatus"; + } + if (eventId == 3L) { + return "TimeFailure"; + } + if (eventId == 4L) { + return "MissingTrustedTimeSource"; + } + return ""; + } if (clusterId == 57L) { if (eventId == 0L) { return "StartUp"; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java index 18d55b362c7b68..b07715b9acc869 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -1029,6 +1029,121 @@ public String toString() { } } + public static class TimeSynchronizationClusterDSTOffsetStruct { + public Long offset; + public Long validStarting; + public @Nullable Long validUntil; + + public TimeSynchronizationClusterDSTOffsetStruct( + Long offset, Long validStarting, @Nullable Long validUntil) { + this.offset = offset; + this.validStarting = validStarting; + this.validUntil = validUntil; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterDSTOffsetStruct {\n"); + output.append("\toffset: "); + output.append(offset); + output.append("\n"); + output.append("\tvalidStarting: "); + output.append(validStarting); + output.append("\n"); + output.append("\tvalidUntil: "); + output.append(validUntil); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + public Long nodeID; + public Integer endpoint; + + public TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( + Long nodeID, Integer endpoint) { + this.nodeID = nodeID; + this.endpoint = endpoint; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct {\n"); + output.append("\tnodeID: "); + output.append(nodeID); + output.append("\n"); + output.append("\tendpoint: "); + output.append(endpoint); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterTimeZoneStruct { + public Long offset; + public Long validAt; + public Optional name; + + public TimeSynchronizationClusterTimeZoneStruct( + Long offset, Long validAt, Optional name) { + this.offset = offset; + this.validAt = validAt; + this.name = name; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterTimeZoneStruct {\n"); + output.append("\toffset: "); + output.append(offset); + output.append("\n"); + output.append("\tvalidAt: "); + output.append(validAt); + output.append("\n"); + output.append("\tname: "); + output.append(name); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class TimeSynchronizationClusterTrustedTimeSourceStruct { + public Integer fabricIndex; + public Long nodeID; + public Integer endpoint; + + public TimeSynchronizationClusterTrustedTimeSourceStruct( + Integer fabricIndex, Long nodeID, Integer endpoint) { + this.fabricIndex = fabricIndex; + this.nodeID = nodeID; + this.endpoint = endpoint; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("TimeSynchronizationClusterTrustedTimeSourceStruct {\n"); + output.append("\tfabricIndex: "); + output.append(fabricIndex); + output.append("\n"); + output.append("\tnodeID: "); + output.append(nodeID); + output.append("\n"); + output.append("\tendpoint: "); + output.append(endpoint); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + public static class BridgedDeviceBasicInformationClusterProductAppearanceStruct { public Integer finish; public @Nullable Integer primaryColor; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 8a8a431885d0f2..00dee01fdeca84 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -5258,6 +5258,251 @@ public void onError(Exception ex) { } } + public static class DelegatedTimeSynchronizationClusterSetTimeZoneResponseCallback + implements ChipClusters.TimeSynchronizationCluster.SetTimeZoneResponseCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(Boolean DSTOffsetRequired) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo DSTOffsetRequiredResponseValue = + new CommandResponseInfo("DSTOffsetRequired", "Boolean"); + responseValues.put(DSTOffsetRequiredResponseValue, DSTOffsetRequired); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception error) { + callback.onFailure(error); + } + } + + public static class DelegatedTimeSynchronizationClusterUTCTimeAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.UTCTimeAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterDefaultNTPAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.DefaultNTPAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable String value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "String"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterTimeZoneAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.TimeZoneAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = + new CommandResponseInfo( + "valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterDSTOffsetAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.DSTOffsetAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = + new CommandResponseInfo( + "valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterLocalTimeAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.LocalTimeAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Long value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterGeneratedCommandListAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.GeneratedCommandListAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterAcceptedCommandListAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.AcceptedCommandListAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterEventListAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.EventListAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedTimeSynchronizationClusterAttributeListAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.AttributeListAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(List valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List"); + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedBridgedDeviceBasicInformationClusterGeneratedCommandListAttributeCallback implements ChipClusters.BridgedDeviceBasicInformationCluster @@ -13271,6 +13516,11 @@ public Map initializeClusterMap() { new ChipClusters.EthernetNetworkDiagnosticsCluster(ptr, endpointId), new HashMap<>()); clusterMap.put("ethernetNetworkDiagnostics", ethernetNetworkDiagnosticsClusterInfo); + ClusterInfo timeSynchronizationClusterInfo = + new ClusterInfo( + (ptr, endpointId) -> new ChipClusters.TimeSynchronizationCluster(ptr, endpointId), + new HashMap<>()); + clusterMap.put("timeSynchronization", timeSynchronizationClusterInfo); ClusterInfo bridgedDeviceBasicInformationClusterInfo = new ClusterInfo( (ptr, endpointId) -> @@ -13511,6 +13761,7 @@ public void combineCommand( destination .get("ethernetNetworkDiagnostics") .combineCommands(source.get("ethernetNetworkDiagnostics")); + destination.get("timeSynchronization").combineCommands(source.get("timeSynchronization")); destination .get("bridgedDeviceBasicInformation") .combineCommands(source.get("bridgedDeviceBasicInformation")); @@ -15166,6 +15417,105 @@ public Map> getCommandMap() { "resetCounts", ethernetNetworkDiagnosticsresetCountsInteractionInfo); commandMap.put( "ethernetNetworkDiagnostics", ethernetNetworkDiagnosticsClusterInteractionInfoMap); + Map timeSynchronizationClusterInteractionInfoMap = + new LinkedHashMap<>(); + Map timeSynchronizationsetUTCTimeCommandParams = + new LinkedHashMap(); + CommandParameterInfo timeSynchronizationsetUTCTimeUTCTimeCommandParameterInfo = + new CommandParameterInfo("UTCTime", Long.class, Long.class); + timeSynchronizationsetUTCTimeCommandParams.put( + "UTCTime", timeSynchronizationsetUTCTimeUTCTimeCommandParameterInfo); + + CommandParameterInfo timeSynchronizationsetUTCTimegranularityCommandParameterInfo = + new CommandParameterInfo("granularity", Integer.class, Integer.class); + timeSynchronizationsetUTCTimeCommandParams.put( + "granularity", timeSynchronizationsetUTCTimegranularityCommandParameterInfo); + + CommandParameterInfo timeSynchronizationsetUTCTimetimeSourceCommandParameterInfo = + new CommandParameterInfo("timeSource", Optional.class, Integer.class); + timeSynchronizationsetUTCTimeCommandParams.put( + "timeSource", timeSynchronizationsetUTCTimetimeSourceCommandParameterInfo); + + InteractionInfo timeSynchronizationsetUTCTimeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .setUTCTime( + (DefaultClusterCallback) callback, + (Long) commandArguments.get("UTCTime"), + (Integer) commandArguments.get("granularity"), + (Optional) commandArguments.get("timeSource")); + }, + () -> new DelegatedDefaultClusterCallback(), + timeSynchronizationsetUTCTimeCommandParams); + timeSynchronizationClusterInteractionInfoMap.put( + "setUTCTime", timeSynchronizationsetUTCTimeInteractionInfo); + Map timeSynchronizationsetTrustedTimeSourceCommandParams = + new LinkedHashMap(); + InteractionInfo timeSynchronizationsetTrustedTimeSourceInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .setTrustedTimeSource( + (DefaultClusterCallback) callback, + (ChipStructs.TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct) + commandArguments.get("trustedTimeSource")); + }, + () -> new DelegatedDefaultClusterCallback(), + timeSynchronizationsetTrustedTimeSourceCommandParams); + timeSynchronizationClusterInteractionInfoMap.put( + "setTrustedTimeSource", timeSynchronizationsetTrustedTimeSourceInteractionInfo); + Map timeSynchronizationsetTimeZoneCommandParams = + new LinkedHashMap(); + InteractionInfo timeSynchronizationsetTimeZoneInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .setTimeZone( + (ChipClusters.TimeSynchronizationCluster.SetTimeZoneResponseCallback) + callback, + (ArrayList) + commandArguments.get("timeZone")); + }, + () -> new DelegatedTimeSynchronizationClusterSetTimeZoneResponseCallback(), + timeSynchronizationsetTimeZoneCommandParams); + timeSynchronizationClusterInteractionInfoMap.put( + "setTimeZone", timeSynchronizationsetTimeZoneInteractionInfo); + Map timeSynchronizationsetDSTOffsetCommandParams = + new LinkedHashMap(); + InteractionInfo timeSynchronizationsetDSTOffsetInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .setDSTOffset( + (DefaultClusterCallback) callback, + (ArrayList) + commandArguments.get("DSTOffset")); + }, + () -> new DelegatedDefaultClusterCallback(), + timeSynchronizationsetDSTOffsetCommandParams); + timeSynchronizationClusterInteractionInfoMap.put( + "setDSTOffset", timeSynchronizationsetDSTOffsetInteractionInfo); + Map timeSynchronizationsetDefaultNTPCommandParams = + new LinkedHashMap(); + CommandParameterInfo timeSynchronizationsetDefaultNTPdefaultNTPCommandParameterInfo = + new CommandParameterInfo("defaultNTP", String.class, String.class); + timeSynchronizationsetDefaultNTPCommandParams.put( + "defaultNTP", timeSynchronizationsetDefaultNTPdefaultNTPCommandParameterInfo); + + InteractionInfo timeSynchronizationsetDefaultNTPInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .setDefaultNTP( + (DefaultClusterCallback) callback, + (String) commandArguments.get("defaultNTP")); + }, + () -> new DelegatedDefaultClusterCallback(), + timeSynchronizationsetDefaultNTPCommandParams); + timeSynchronizationClusterInteractionInfoMap.put( + "setDefaultNTP", timeSynchronizationsetDefaultNTPInteractionInfo); + commandMap.put("timeSynchronization", timeSynchronizationClusterInteractionInfoMap); Map bridgedDeviceBasicInformationClusterInteractionInfoMap = new LinkedHashMap<>(); commandMap.put( diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index ed20a2b7b89283..436ed0adb83d2a 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -3097,6 +3097,170 @@ class ChipClusters: }, }, } + _TIME_SYNCHRONIZATION_CLUSTER_INFO = { + "clusterName": "TimeSynchronization", + "clusterId": 0x00000038, + "commands": { + 0x00000000: { + "commandId": 0x00000000, + "commandName": "SetUTCTime", + "args": { + "UTCTime": "int", + "granularity": "int", + "timeSource": "int", + }, + }, + 0x00000001: { + "commandId": 0x00000001, + "commandName": "SetTrustedTimeSource", + "args": { + "nodeID": "int", + "endpoint": "int", + }, + }, + 0x00000002: { + "commandId": 0x00000002, + "commandName": "SetTimeZone", + "args": { + "offset": "int", + "validAt": "int", + "name": "str", + }, + }, + 0x00000004: { + "commandId": 0x00000004, + "commandName": "SetDSTOffset", + "args": { + "offset": "int", + "validStarting": "int", + "validUntil": "int", + }, + }, + 0x00000005: { + "commandId": 0x00000005, + "commandName": "SetDefaultNTP", + "args": { + "defaultNTP": "str", + }, + }, + }, + "attributes": { + 0x00000000: { + "attributeName": "UTCTime", + "attributeId": 0x00000000, + "type": "int", + "reportable": True, + }, + 0x00000001: { + "attributeName": "Granularity", + "attributeId": 0x00000001, + "type": "int", + "reportable": True, + }, + 0x00000002: { + "attributeName": "TimeSource", + "attributeId": 0x00000002, + "type": "int", + "reportable": True, + }, + 0x00000003: { + "attributeName": "TrustedTimeSource", + "attributeId": 0x00000003, + "type": "", + "reportable": True, + }, + 0x00000004: { + "attributeName": "DefaultNTP", + "attributeId": 0x00000004, + "type": "str", + "reportable": True, + }, + 0x00000005: { + "attributeName": "TimeZone", + "attributeId": 0x00000005, + "type": "", + "reportable": True, + }, + 0x00000006: { + "attributeName": "DSTOffset", + "attributeId": 0x00000006, + "type": "", + "reportable": True, + }, + 0x00000007: { + "attributeName": "LocalTime", + "attributeId": 0x00000007, + "type": "int", + "reportable": True, + }, + 0x00000008: { + "attributeName": "TimeZoneDatabase", + "attributeId": 0x00000008, + "type": "int", + "reportable": True, + }, + 0x00000009: { + "attributeName": "NTPServerAvailable", + "attributeId": 0x00000009, + "type": "bool", + "reportable": True, + }, + 0x0000000A: { + "attributeName": "TimeZoneListMaxSize", + "attributeId": 0x0000000A, + "type": "int", + "reportable": True, + }, + 0x0000000B: { + "attributeName": "DSTOffsetListMaxSize", + "attributeId": 0x0000000B, + "type": "int", + "reportable": True, + }, + 0x0000000C: { + "attributeName": "SupportsDNSResolve", + "attributeId": 0x0000000C, + "type": "bool", + "reportable": True, + }, + 0x0000FFF8: { + "attributeName": "GeneratedCommandList", + "attributeId": 0x0000FFF8, + "type": "int", + "reportable": True, + }, + 0x0000FFF9: { + "attributeName": "AcceptedCommandList", + "attributeId": 0x0000FFF9, + "type": "int", + "reportable": True, + }, + 0x0000FFFA: { + "attributeName": "EventList", + "attributeId": 0x0000FFFA, + "type": "int", + "reportable": True, + }, + 0x0000FFFB: { + "attributeName": "AttributeList", + "attributeId": 0x0000FFFB, + "type": "int", + "reportable": True, + }, + 0x0000FFFC: { + "attributeName": "FeatureMap", + "attributeId": 0x0000FFFC, + "type": "int", + "reportable": True, + }, + 0x0000FFFD: { + "attributeName": "ClusterRevision", + "attributeId": 0x0000FFFD, + "type": "int", + "reportable": True, + }, + }, + } _BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_INFO = { "clusterName": "BridgedDeviceBasicInformation", "clusterId": 0x00000039, @@ -9186,6 +9350,7 @@ class ChipClusters: 0x00000035: _THREAD_NETWORK_DIAGNOSTICS_CLUSTER_INFO, 0x00000036: _WI_FI_NETWORK_DIAGNOSTICS_CLUSTER_INFO, 0x00000037: _ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_INFO, + 0x00000038: _TIME_SYNCHRONIZATION_CLUSTER_INFO, 0x00000039: _BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_INFO, 0x0000003B: _SWITCH_CLUSTER_INFO, 0x0000003C: _ADMINISTRATOR_COMMISSIONING_CLUSTER_INFO, @@ -9254,6 +9419,7 @@ class ChipClusters: "ThreadNetworkDiagnostics": _THREAD_NETWORK_DIAGNOSTICS_CLUSTER_INFO, "WiFiNetworkDiagnostics": _WI_FI_NETWORK_DIAGNOSTICS_CLUSTER_INFO, "EthernetNetworkDiagnostics": _ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_INFO, + "TimeSynchronization": _TIME_SYNCHRONIZATION_CLUSTER_INFO, "BridgedDeviceBasicInformation": _BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_INFO, "Switch": _SWITCH_CLUSTER_INFO, "AdministratorCommissioning": _ADMINISTRATOR_COMMISSIONING_CLUSTER_INFO, diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index cc788f353be5ec..41334a465b4549 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -45,7 +45,6 @@ class ConfigurationManagerImpl; class DeviceControlServer; class TraitManager; class ThreadStackManagerImpl; -class TimeSyncManager; namespace Internal { class BLEManagerImpl; @@ -258,7 +257,6 @@ class PlatformManager friend class FailSafeContext; friend class TraitManager; friend class ThreadStackManagerImpl; - friend class TimeSyncManager; friend class Internal::BLEManagerImpl; template friend class Internal::GenericPlatformManagerImpl; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 961db5250e7d63..f601f06b92b07a 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1423,6 +1423,24 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS 2 #endif +/** + * @def CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE + * + * Defines the size of the time zone list + */ +#ifndef CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE +#define CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE 2 +#endif + +/** + * @def CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE + * + * Defines the size of the DSTOffset list + */ +#ifndef CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE +#define CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE 1 +#endif + /** * @} */ diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index 418220a3f3d520..fe02cab6cb9393 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -204,6 +204,12 @@ class DefaultStorageKeyAllocator { return StorageKeyName::Formatted("f/%x/sc/%x", fabric, id); } + + // Time synchronization cluster + static StorageKeyName TSTrustedTimeSource() { return StorageKeyName::FromConst("g/ts/tts"); } + static StorageKeyName TSDefaultNTP() { return StorageKeyName::FromConst("g/ts/dntp"); } + static StorageKeyName TSTimeZone() { return StorageKeyName::FromConst("g/ts/tz"); } + static StorageKeyName TSDSTOffset() { return StorageKeyName::FromConst("g/ts/dsto"); } }; } // namespace chip 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 c46841fe3ea27f..a99ba7c4fb987c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -4112,6 +4112,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + ReturnErrorOnFailure(DataModelLogger::LogValue("DSTOffsetRequired", indent + 1, value.DSTOffsetRequired)); + DataModelLogger::LogString(indent, "}"); + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const OperationalCredentials::Commands::AttestationResponse::DecodableType & value) { @@ -6605,6 +6613,111 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP } break; } + case TimeSynchronization::Id: { + switch (path.mAttributeId) + { + case TimeSynchronization::Attributes::UTCTime::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("UTCTime", 1, value); + } + case TimeSynchronization::Attributes::Granularity::Id: { + chip::app::Clusters::TimeSynchronization::GranularityEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Granularity", 1, value); + } + case TimeSynchronization::Attributes::TimeSource::Id: { + chip::app::Clusters::TimeSynchronization::TimeSourceEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeSource", 1, value); + } + case TimeSynchronization::Attributes::TrustedTimeSource::Id: { + chip::app::DataModel::Nullable< + chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::DecodableType> + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TrustedTimeSource", 1, value); + } + case TimeSynchronization::Attributes::DefaultNTP::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("DefaultNTP", 1, value); + } + case TimeSynchronization::Attributes::TimeZone::Id: { + chip::app::DataModel::DecodableList + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeZone", 1, value); + } + case TimeSynchronization::Attributes::DSTOffset::Id: { + chip::app::DataModel::DecodableList + value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("DSTOffset", 1, value); + } + case TimeSynchronization::Attributes::LocalTime::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("LocalTime", 1, value); + } + case TimeSynchronization::Attributes::TimeZoneDatabase::Id: { + chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeZoneDatabase", 1, value); + } + case TimeSynchronization::Attributes::NTPServerAvailable::Id: { + bool value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("NTPServerAvailable", 1, value); + } + case TimeSynchronization::Attributes::TimeZoneListMaxSize::Id: { + uint8_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeZoneListMaxSize", 1, value); + } + case TimeSynchronization::Attributes::DSTOffsetListMaxSize::Id: { + uint8_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("DSTOffsetListMaxSize", 1, value); + } + case TimeSynchronization::Attributes::SupportsDNSResolve::Id: { + bool value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("SupportsDNSResolve", 1, value); + } + case TimeSynchronization::Attributes::GeneratedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("GeneratedCommandList", 1, value); + } + case TimeSynchronization::Attributes::AcceptedCommandList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AcceptedCommandList", 1, value); + } + case TimeSynchronization::Attributes::EventList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("EventList", 1, value); + } + case TimeSynchronization::Attributes::AttributeList::Id: { + chip::app::DataModel::DecodableList value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AttributeList", 1, value); + } + case TimeSynchronization::Attributes::FeatureMap::Id: { + uint32_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("FeatureMap", 1, value); + } + case TimeSynchronization::Attributes::ClusterRevision::Id: { + uint16_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("ClusterRevision", 1, value); + } + } + break; + } case BridgedDeviceBasicInformation::Id: { switch (path.mAttributeId) { @@ -10834,6 +10947,17 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa } break; } + case TimeSynchronization::Id: { + switch (path.mCommandId) + { + case TimeSynchronization::Commands::SetTimeZoneResponse::Id: { + TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("SetTimeZoneResponse", 1, value); + } + } + break; + } case OperationalCredentials::Id: { switch (path.mCommandId) { @@ -11291,6 +11415,37 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case TimeSynchronization::Id: { + switch (header.mPath.mEventId) + { + case TimeSynchronization::Events::DSTTableEmpty::Id: { + chip::app::Clusters::TimeSynchronization::Events::DSTTableEmpty::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("DSTTableEmpty", 1, value); + } + case TimeSynchronization::Events::DSTStatus::Id: { + chip::app::Clusters::TimeSynchronization::Events::DSTStatus::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("DSTStatus", 1, value); + } + case TimeSynchronization::Events::TimeZoneStatus::Id: { + chip::app::Clusters::TimeSynchronization::Events::TimeZoneStatus::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeZoneStatus", 1, value); + } + case TimeSynchronization::Events::TimeFailure::Id: { + chip::app::Clusters::TimeSynchronization::Events::TimeFailure::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TimeFailure", 1, value); + } + case TimeSynchronization::Events::MissingTrustedTimeSource::Id: { + chip::app::Clusters::TimeSynchronization::Events::MissingTrustedTimeSource::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("MissingTrustedTimeSource", 1, value); + } + } + break; + } case BridgedDeviceBasicInformation::Id: { switch (header.mPath.mEventId) { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index a1a038ba506b0b..b5c8d4defb45f6 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -403,6 +403,8 @@ LogValue(const char * label, size_t indent, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & value); static CHIP_ERROR diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h index 4c52eb1bf23c89..53018638db9ed7 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -316,6 +316,22 @@ typedef void (*EthernetNetworkDiagnosticsEventListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*EthernetNetworkDiagnosticsAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationTimeZoneListAttributeCallback)( + void * context, + const chip::app::DataModel::DecodableList & + data); +typedef void (*TimeSynchronizationDSTOffsetListAttributeCallback)( + void * context, + const chip::app::DataModel::DecodableList & + data); +typedef void (*TimeSynchronizationGeneratedCommandListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationAcceptedCommandListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationEventListListAttributeCallback)(void * context, + const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationAttributeListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BridgedDeviceBasicInformationGeneratedCommandListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BridgedDeviceBasicInformationAcceptedCommandListListAttributeCallback)( diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h index b08f6b47236de9..c1ab728d983987 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClusters.h @@ -282,6 +282,15 @@ class DLL_EXPORT EthernetNetworkDiagnosticsCluster : public ClusterBase ~EthernetNetworkDiagnosticsCluster() {} }; +class DLL_EXPORT TimeSynchronizationCluster : public ClusterBase +{ +public: + TimeSynchronizationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : + ClusterBase(exchangeManager, session, endpoint) + {} + ~TimeSynchronizationCluster() {} +}; + class DLL_EXPORT BridgedDeviceBasicInformationCluster : public ClusterBase { public: diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h b/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h index 7e8e00618681b5..a367f8bb71411f 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/endpoint_config.h @@ -59,7 +59,7 @@ #define GENERATED_FUNCTION_ARRAYS // This is an array of EmberAfCluster structures. -#define GENERATED_CLUSTER_COUNT 65 +#define GENERATED_CLUSTER_COUNT 66 // clang-format off #define GENERATED_CLUSTERS { \ { \ @@ -413,6 +413,19 @@ .eventList = nullptr, \ .eventCount = 0, \ },\ + { \ + /* Endpoint: 1, Cluster: Time Synchronization (client) */ \ + .clusterId = 0x00000038, \ + .attributes = ZAP_ATTRIBUTE_INDEX(0), \ + .attributeCount = 0, \ + .clusterSize = 0, \ + .mask = ZAP_CLUSTER_MASK(CLIENT), \ + .functions = NULL, \ + .acceptedCommandList = nullptr, \ + .generatedCommandList = nullptr, \ + .eventList = nullptr, \ + .eventCount = 0, \ + },\ { \ /* Endpoint: 1, Cluster: Bridged Device Basic Information (client) */ \ .clusterId = 0x00000039, \ @@ -916,7 +929,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 65, 0 }, \ + { ZAP_CLUSTER_INDEX(0), 66, 0 }, \ } // Largest attribute size is needed for various buffers diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h b/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h index 1800d8c39bb740..ba5da4bc43bcda 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/gen_config.h @@ -48,6 +48,7 @@ #define EMBER_AF_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_TIME_SYNCHRONIZATION_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_SWITCH_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ADMINISTRATOR_COMMISSIONING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) @@ -197,6 +198,10 @@ #define ZCL_USING_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ETHERNET_NETWORK_DIAGNOSTICS_CLIENT +// Use this macro to check if the client side of the Time Synchronization cluster is included +#define ZCL_USING_TIME_SYNCHRONIZATION_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_TIME_SYNCHRONIZATION_CLIENT + // Use this macro to check if the client side of the Bridged Device Basic Information cluster is included #define ZCL_USING_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_BRIDGED_DEVICE_BASIC_INFORMATION_CLIENT