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 7d5c990db66e81..3a82ace897d77c 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 @@ -1870,9 +1870,144 @@ server cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } -/** 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. */ +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 = 1; + kPartial = 2; + kNone = 3; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + 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; +} + server cluster Switch = 59 { bitmap SwitchFeature : BITMAP32 { kLatchingSwitch = 0x1; @@ -4863,6 +4998,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; + ram attribute UTCTime; + ram attribute granularity; + ram attribute timeSource; + callback attribute trustedTimeSource; + callback attribute defaultNTP; + callback attribute timeZone default = 1; + callback attribute DSTOffset; + ram attribute localTime default = 1; + ram attribute timeZoneDatabase; + 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 7bdd60bf91a82f..3881326a2e00e4 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 @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 94, "creator": "zap", "keyValuePairs": [ { @@ -16,6 +16,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -23,12 +29,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -5418,6 +5418,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": "RAM", + "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": "array", + "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": "RAM", + "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, @@ -25498,5 +25927,6 @@ "endpointVersion": 1, "deviceIdentifier": 61442 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 70f17774c00d77..d57e56f72604b0 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -89,6 +89,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 cba838c3007d9b..c7cd322b4268ef 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 @@ -1428,9 +1428,144 @@ server cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } -/** 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. */ +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 = 1; + kPartial = 2; + kNone = 3; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + 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; +} + server cluster Switch = 59 { bitmap SwitchFeature : BITMAP32 { kLatchingSwitch = 0x1; @@ -2302,6 +2437,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; + ram attribute UTCTime; + ram attribute granularity; + ram attribute timeSource; + callback attribute trustedTimeSource; + callback attribute defaultNTP; + callback attribute timeZone default = 1; + callback attribute DSTOffset; + ram attribute localTime; + ram attribute timeZoneDatabase; + 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 e38ff2637a6ad9..b83a10d58c5143 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": 94, "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": "RAM", + "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": "array", + "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": "RAM", + "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, @@ -9556,5 +9985,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 39b6f1869ae1dc..d67f84becaff79 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -261,6 +261,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..9aa436c80d6d87 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp @@ -0,0 +1,222 @@ +/* + * + * 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 kDefaultNtpMaxSerializedSize = 133u + 11u; // adding 11 as buffer +#if 1 // User TZ feature +constexpr size_t kTimeZoneMaxSerializedSize = 90u + 6u; // adding 6 as buffer +constexpr size_t kDSTOffsetMaxSerializedSize = 34u + 6u; // adding 6 as buffer +#endif + +#if 1 // user TZ feature +// 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; // Use a define instead +#endif + +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 MutableByteSpan & 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.begin(); timeZoneIter != timeZoneList.end(); timeZoneIter++) + { + 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 buffer[kTimeZoneListMaxSerializedSize]; + MutableByteSpan bufferSpan(buffer); + + 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(); + size_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)); + + 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 buffer[kDSTOffsetListMaxSerializedSize]; + MutableByteSpan bufferSpan(buffer); + + 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(); + size_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)); + + 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..35b8bbef5b2f7a --- /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 MutableByteSpan & defaultNtp); + CHIP_ERROR LoadDefaultNtp(MutableByteSpan & defaultNtp); + CHIP_ERROR ClearDefaultNtp(); + + CHIP_ERROR StoreTimeZone(const TimeZone & timeZoneList); + CHIP_ERROR LoadTimeZone(TimeZone & timeZoneList); + CHIP_ERROR ClearTimeZone(); + + CHIP_ERROR StoreDSTOffset(const DSTOffset & dstOffsetList); + CHIP_ERROR LoadDSTOffset(DSTOffset & dstOffsetList); + 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..357a9ae94142eb --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncManager.cpp @@ -0,0 +1,62 @@ +/* + * + * 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 + +#include "TimeSyncManager.h" +#include +#include +#include +#include +#include + +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..6ae95b00d28142 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/TimeSyncManager.h @@ -0,0 +1,56 @@ +/* + * + * 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 + +#include "time-synchronization-delegate.h" +#include +#include +#include +#include +#include + +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..835f97930e475a --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-delegate.h @@ -0,0 +1,63 @@ +/* + * + * 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 + +#include +#include +#include +#include +#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..3c79a657abafab --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -0,0 +1,685 @@ +/* + * 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() +{ + TimeSynchronization::Structs::TrustedTimeSourceStruct::Type tts; + chip::MutableByteSpan mutableDntp(mDefaultNtpBuf); + + mTimeSyncDataProvider.Init(Server::GetInstance().GetPersistentStorage()); + + (CHIP_NO_ERROR == mTimeSyncDataProvider.LoadTrustedTimeSource(tts)) ? (void) mTrustedTimeSource.SetNonNull(tts) + : mTrustedTimeSource.SetNull(); + (CHIP_NO_ERROR == mTimeSyncDataProvider.LoadDefaultNtp(mutableDntp)) ? (void) mDefaultNtp.SetNonNull(mutableDntp) + : mDefaultNtp.SetNull(); + + auto tz = mTimeZoneList.begin(); + for (size_t i = 0; i < mTimeZoneList.size(); i++) + { + const char * buf = reinterpret_cast(mNames[i].name); + tz[i].name.SetValue(chip::CharSpan(buf, sizeof(mNames[i].name))); + } + mTimeSyncDataProvider.LoadTimeZone(mTimeZoneList); + mTimeSyncDataProvider.LoadDSTOffset(mDstOffList); + // TODO if trusted time source is available schedule a time read + if (!mTrustedTimeSource.IsNull()) + { + } +} + +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 { + +struct TimeZoneCodec +{ + static constexpr TLV::Tag TagOffset() { return TLV::ContextTag(TimeSynchronization::Structs::TimeZoneStruct::Fields::kOffset); } + static constexpr TLV::Tag TagValidAt() + { + return TLV::ContextTag(TimeSynchronization::Structs::TimeZoneStruct::Fields::kValidAt); + } + static constexpr TLV::Tag TagName() { return TLV::ContextTag(TimeSynchronization::Structs::TimeZoneStruct::Fields::kName); } + + TimeSynchronization::Structs::TimeZoneStruct::Type timeZone; + + TimeZoneCodec(TimeSynchronization::Structs::TimeZoneStruct::Type tz) : timeZone(tz) {} + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const + { + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + + // Offset + ReturnErrorOnFailure(DataModel::Encode(writer, TagOffset(), timeZone.offset)); + // ValidAt + ReturnErrorOnFailure(DataModel::Encode(writer, TagValidAt(), timeZone.validAt)); + // Name + if (timeZone.name.HasValue()) + { + uint32_t name_size = static_cast(strnlen(timeZone.name.Value().data(), 64)); + ReturnErrorOnFailure(writer.PutString(TagName(), timeZone.name.Value().data(), name_size)); + ChipLogProgress(Zcl, "%s %d", timeZone.name.Value().data(), name_size); + } + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; + } +}; + +static bool computeLocalTime(chip::EndpointId ep) +{ + DataModel::Nullable utcTime, localTime; + int32_t timeZoneOffset = 0, dstOffset = 0; + UTCTime::Get(ep, utcTime); + if (utcTime.IsNull()) + { + return false; + } + auto tz = TimeSynchronizationServer::Instance().GetTimeZone().begin(); + auto dst = TimeSynchronizationServer::Instance().GetDSTOffset().begin(); + if (tz->validAt <= utcTime.Value()) + { + timeZoneOffset = tz->offset; + } + if (dst->validStarting <= utcTime.Value() && dst->offset != 0 && !dst->validUntil.IsNull()) + { + dstOffset = dst->offset; + } + localTime.SetNonNull(utcTime.Value() + static_cast(timeZoneOffset) + static_cast(dstOffset)); + LocalTime::Set(ep, localTime); + 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) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + auto tts = TimeSynchronizationServer::Instance().GetTrustedTimeSource(); + if (!tts.IsNull()) + { + err = aEncoder.Encode(tts.Value()); + } + else + { + err = aEncoder.EncodeNull(); + } + + return err; +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadDefaultNtp(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + auto dntp = TimeSynchronizationServer::Instance().GetDefaultNtp(); + if (!dntp.IsNull()) + { + const char * buf = reinterpret_cast(dntp.Value().data()); + err = aEncoder.Encode(chip::CharSpan(buf, strnlen(buf, dntp.Value().size()))); + } + else + { + err = aEncoder.EncodeNull(); + } + + return err; +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadTimeZone(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { + DataModel::List tzList = + TimeSynchronizationServer::Instance().GetTimeZone(); + for (auto it = tzList.begin(); it != tzList.end(); ++it) + { + ReturnErrorOnFailure(encoder.Encode(TimeZoneCodec(*it))); + } + + return CHIP_NO_ERROR; + }); + + return err; +} + +CHIP_ERROR TimeSynchronizationAttrAccess::ReadDSTOffset(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { + DataModel::List dst = + TimeSynchronizationServer::Instance().GetDSTOffset(); + for (auto it = dst.begin(); it != dst.end(); ++it) + { + ReturnErrorOnFailure(encoder.Encode(*it)); + } + + 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: { + DataModel::Nullable currentUtcTime; + UTCTime::Get(aPath.mEndpointId, currentUtcTime); + if (!currentUtcTime.IsNull()) + { + System::Clock::Microseconds64 utcTime; + System::SystemClock().GetClock_RealTime(utcTime); + UTCTime::Set(aPath.mEndpointId, utcTime.count()); + return aEncoder.Encode(utcTime.count()); + } + else + { + return aEncoder.EncodeNull(); + } + } + 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; + TimeZoneListMaxSize::Set(aPath.mEndpointId, CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE); + return aEncoder.Encode(max); + } + case DSTOffsetListMaxSize::Id: { + uint8_t max = CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE; + DSTOffsetListMaxSize::Set(aPath.mEndpointId, CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE); + return aEncoder.Encode(max); + } + case LocalTime::Id: { + DataModel::Nullable localTime; + if (computeLocalTime(aPath.mEndpointId)) + { + LocalTime::Get(aPath.mEndpointId, localTime); + return aEncoder.Encode(localTime.Value()); + } + else + { + return aEncoder.EncodeNull(); + } + } + 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 = 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 void 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); + ChipLogError(Zcl, "UTCTime: %llu Last Known Good Time: %u Real Time: %llu", utcTime, lastKnownGoodChipEpoch.count(), + realTime.count()); + chip::UnixEpochToChipEpochTime((uint32_t)(utcTime / chip::kMicrosecondsPerSecond), utcTimetoChipEpoch); + + if (utcTimetoChipEpoch >= lastKnownGoodChipEpoch.count()) // update Last Known Good Time if a more recent time is obtained + { + Server::GetInstance().GetFabricTable().SetLastKnownGoodChipEpochTime(System::Clock::Seconds32(utcTimetoChipEpoch)); + System::SystemClock().SetClock_RealTime(System::Clock::Microseconds64(utcTime)); + + Server::GetInstance().GetFabricTable().GetLastKnownGoodChipEpochTime(lastKnownGoodChipEpoch); + System::SystemClock().GetClock_RealTime(realTime); + ChipLogError(Zcl, " Last Known Good Time: %u Real Time: %llu", lastKnownGoodChipEpoch.count(), realTime.count()); + } +} + +bool emberAfTimeSynchronizationClusterSetUtcTimeCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetUtcTime::DecodableType & commandData) +{ + Optional status = Optional::Missing(); + Status globalStatus = Status::Success; + + auto utcTime = commandData.utcTime; + auto granularity = commandData.granularity; + auto timeSource = commandData.timeSource; + + TimeSynchronization::GranularityEnum currentGranularity; + Granularity::Get(commandPath.mEndpointId, ¤tGranularity); + + if (currentGranularity == TimeSynchronization::GranularityEnum::kNoTimeGranularity || granularity >= currentGranularity) + { + UTCTime::Set(commandPath.mEndpointId, utcTime); + utcTimeChanged(utcTime); + Granularity::Set(commandPath.mEndpointId, granularity); + if (timeSource.HasValue()) + { + TimeSource::Set(commandPath.mEndpointId, timeSource.Value()); + } + else + { + TimeSource::Set(commandPath.mEndpointId, TimeSynchronization::TimeSourceEnum::kAdmin); + } + } + else + { + status.Emplace(TimeSynchronization::StatusCode::kTimeNotAccepted); + } + + if (status.HasValue()) + { + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(status.Value())); + } + else + { + commandObj->AddStatus(commandPath, globalStatus); + } + return true; +} + +bool emberAfTimeSynchronizationClusterSetTrustedTimeSourceCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::DecodableType & commandData) +{ + Status status = Status::Success; + 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); + return true; +} + +bool emberAfTimeSynchronizationClusterSetTimeZoneCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::DecodableType & commandData) +{ + auto timeZone = commandData.timeZone; + size_t items; + uint8_t maxSize = 0; + timeZone.ComputeSize(&items); + 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); + if (GetDelegate()->HasFeature(0, TimeSynchronization::TimeSynchronizationFeature::kTimeZone) && + tzDb != TimeSynchronization::TimeZoneDatabaseEnum::kNone) + { + auto tz = TimeSynchronizationServer::Instance().GetTimeZone().begin(); + Commands::SetTimeZoneResponse::Type response; + if (GetDelegate()->HandleDstoffsetavailable(tz->name.Value()) == true) + { + GetDelegate()->HandleGetdstoffset(); + response.DSTOffsetRequired = false; + sendDSTStatus(commandPath.mEndpointId, true); + } + else + { + TimeSynchronizationServer::Instance().ClearDSTOffset(); + sendDSTTableEmpty(commandPath.mEndpointId); + response.DSTOffsetRequired = true; + sendDSTStatus(commandPath.mEndpointId, false); + } + commandObj->AddResponse(commandPath, response); + computeLocalTime(commandPath.mEndpointId); + return true; + } + + computeLocalTime(commandPath.mEndpointId); + + commandObj->AddStatus(commandPath, Status::Success); + + return true; +} + +bool emberAfTimeSynchronizationClusterSetDSTOffsetCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::DecodableType & commandData) +{ + Status status = Status::Success; + auto dstOffset = commandData.DSTOffset; + size_t items; + uint8_t maxSize = 0; + dstOffset.ComputeSize(&items); + 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); + 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; + DataModel::Nullable dntpByte; + + 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; + } + } + + uint8_t buffer[DefaultNTP::TypeInfo::MaxLength()]; + chip::MutableByteSpan dntp(buffer); + size_t len = (dntpChar.Value().size() < dntp.size()) ? dntpChar.Value().size() : dntp.size(); + memcpy(buffer, dntpChar.Value().data(), len); + + dntp = MutableByteSpan(dntp.data(), len); + dntpByte.SetNonNull(dntp); + } + else + { + dntpByte.SetNull(); + } + status = + (CHIP_NO_ERROR == TimeSynchronizationServer::Instance().SetDefaultNtp(dntpByte)) ? 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..fed8eb6c7897a8 --- /dev/null +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.h @@ -0,0 +1,170 @@ +/** + * + * 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) + { + if (!tts.IsNull()) + { + mTrustedTimeSource.SetNonNull(tts.Value()); + mTimeSyncDataProvider.StoreTrustedTimeSource(tts.Value()); + } + else + { + mTrustedTimeSource.SetNull(); + mTimeSyncDataProvider.ClearTrustedTimeSource(); + } + + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetDefaultNtp(DataModel::Nullable dntp) + { + if (!dntp.IsNull()) + { + memcpy(mDefaultNtpBuf, dntp.Value().data(), dntp.Value().size()); + mDefaultNtp.SetNonNull(MutableByteSpan(mDefaultNtpBuf, dntp.Value().size())); + return mTimeSyncDataProvider.StoreDefaultNtp(mDefaultNtp.Value()); + } + else + { + mDefaultNtp.SetNull(); + return mTimeSyncDataProvider.ClearDefaultNtp(); + } + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetTimeZone(DataModel::DecodableList tz) + { + auto mTzL = mTimeZoneList.begin(); + auto tzL = tz.begin(); + size_t i = 0; + + while (tzL.Next()) + { + mTzL[i].offset = tzL.GetValue().offset; + mTzL[i].validAt = tzL.GetValue().validAt; + if (tzL.GetValue().name.HasValue()) + { + const char * buf = tzL.GetValue().name.Value().data(); + size_t len = tzL.GetValue().name.Value().size(); + Platform::CopyString(mNames[i].name, chip::CharSpan(buf, len)); + } + i++; + } + + return mTimeSyncDataProvider.StoreTimeZone(mTimeZoneList); + } + + CHIP_ERROR SetDSTOffset(DataModel::DecodableList dst) + { + auto mDstL = mDstOffList.begin(); + auto dstL = dst.begin(); + size_t i = 0; + + while (dstL.Next()) + { + mDstL[i] = dstL.GetValue(); + i++; + } + + return mTimeSyncDataProvider.StoreDSTOffset(mDstOffList); + } + + CHIP_ERROR ClearDSTOffset() + { + for (size_t i = 0; i < CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE; i++) + { + mDst[i] = { 0 }; + } + + return mTimeSyncDataProvider.ClearDSTOffset(); + } + + DataModel::Nullable & GetTrustedTimeSource(void) + { + return mTrustedTimeSource; + } + DataModel::Nullable & GetDefaultNtp(void) { return mDefaultNtp; } + DataModel::List & GetTimeZone(void) { return mTimeZoneList; } + DataModel::List & GetDSTOffset(void) { return mDstOffList; } + + void ScheduleDelayedAction(System::Clock::Seconds32 delay, System::TimerCompleteCallback action, void * aAppState); + +private: + DataModel::Nullable mTrustedTimeSource; + DataModel::Nullable mDefaultNtp; + DataModel::List mTimeZoneList = + DataModel::List(mTz, CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE); + DataModel::List mDstOffList = + DataModel::List(mDst, CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE); + + 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]; + uint8_t mDefaultNtpBuf[DefaultNTP::TypeInfo::MaxLength()]; + + 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 f64f0f58fe5154..1901e6b13ed1a7 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -130,6 +130,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-templates/zcl/data-model/chip/time-synchronization-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml index d338454d7b5a04..6eba83c5292ca9 100644 --- a/src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml @@ -17,6 +17,19 @@ limitations under the License. + + + + + + + + + + + + + @@ -32,25 +45,39 @@ limitations under the License. - - - - - - - - - - + + + + + + + + + + - + + + + + + + + - + + + + + + + + @@ -64,7 +91,7 @@ limitations under the License. - + @@ -79,36 +106,52 @@ limitations under the License. UTCTime Granularity TimeSource - TrustedTimeSource - - DefaultNtp - - - - - TimeZone - - - - - DSTOffset - - - + TrustedTimeSource + DefaultNTP + TimeZone + DSTOffset LocalTime - TimeZoneDatabase - NtpServerPort + TimeZoneDatabase + NTPServerAvailable + TimeZoneListMaxSize + DSTOffsetListMaxSize + SupportsDNSResolve This command MAY be issued by Administrator to set the time. + + + + + This command SHALL set TrustedTimeSource. + + + + + + This command SHALL set TimeZone. + + + + + + Response to SetTimeZone. + + + + + This command SHALL set DSTOffset. + + - - This command SHALL set the TrustedTimeSource. - + + This command is used to set DefaultNTP. + + @@ -117,6 +160,7 @@ limitations under the License. This event SHALL be generated when the server starts or stops applying a DST offset. + diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 31c0bdafb533bb..7dc3c8a1960e97 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -269,6 +269,12 @@ "PacketUnicastTxCount", "CurrentMaxRate", "OverrunCount" + ], + "Time Synchronization": [ + "TrustedTimeSource", + "DefaultNTP", + "TimeZone", + "DSTOffset" ] }, "defaultReportingPolicy": "mandatory", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 989130f2ab0c88..23f38ec3993d7c 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -267,6 +267,12 @@ "PacketUnicastTxCount", "CurrentMaxRate", "OverrunCount" + ], + "Time Synchronization": [ + "TrustedTimeSource", + "DefaultNTP", + "TimeZone", + "DSTOffset" ] }, "defaultReportingPolicy": "mandatory", 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/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index a77f66684da4c4..eb817ce1f8d680 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -2033,10 +2033,145 @@ client cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } -/** 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, - such as the vendor name, the model name, or user-assigned name. */ +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 = 1; + kPartial = 2; + kNone = 3; + } + + bitmap TimeSynchronizationFeature : BITMAP32 { + kTimeZone = 0x1; + kNTPClient = 0x2; + kNTPServer = 0x4; + kTimeSyncClient = 0x8; + } + + struct TrustedTimeSourceStruct { + fabric_idx fabricIndex = 0; + node_id nodeID = 1; + endpoint_no endpoint = 2; + } + + struct TimeZoneStruct { + int32s offset = 0; + epoch_us validAt = 1; + optional char_string<64> name = 2; + } + + struct DSTOffsetStruct { + int32s offset = 0; + epoch_us validStarting = 1; + nullable epoch_us validUntil = 2; + } + + struct FabricScopedTrustedTimeSourceStruct { + node_id nodeID = 0; + endpoint_no endpoint = 1; + } + + info event DSTTableEmpty = 0 { + } + + info event DSTStatus = 1 { + boolean DSTOffsetActive = 0; + } + + info event TimeZoneStatus = 2 { + INT32S offset = 0; + 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 boolean NTPServerAvailable = 9; + 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; +} + client cluster BridgedDeviceBasicInformation = 57 { critical event StartUp = 0 { INT32U softwareVersion = 0; @@ -5404,6 +5539,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 b9da13cdd78caf..e475b66931d6e4 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -7966,6 +7966,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": "RAM", + "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": "array", + "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": "RAM", + "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, diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 509b9168a976d7..d9d039f6e48ee0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -5609,6 +5609,274 @@ 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 readTimeSynchronizationTrustedTimeSourceCommandParams = + new LinkedHashMap(); + InteractionInfo readTimeSynchronizationTrustedTimeSourceAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.TimeSynchronizationCluster) cluster) + .readTrustedTimeSourceAttribute( + (ChipClusters.TimeSynchronizationCluster.TrustedTimeSourceAttributeCallback) + callback); + }, + () -> + new ClusterInfoMapping + .DelegatedTimeSynchronizationClusterTrustedTimeSourceAttributeCallback(), + readTimeSynchronizationTrustedTimeSourceCommandParams); + readTimeSynchronizationInteractionInfo.put( + "readTrustedTimeSourceAttribute", + readTimeSynchronizationTrustedTimeSourceAttributeInteractionInfo); + 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 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 2dce6dab7f0433..d62958b7e4a3ef 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 4e02a196cc0db1..c2a30498f1f052 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -8593,6 +8593,490 @@ 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 + { + chip::JniReferences::GetInstance().CreateArrayList(value); + + auto iter_value_1 = cppValue.Value().begin(); + while (iter_value_1.Next()) + { + auto & entry_1 = iter_value_1.GetValue(); + jobject newElement_1; + jobject newElement_1_fabricIndex; + std::string newElement_1_fabricIndexClassName = "java/lang/Integer"; + std::string newElement_1_fabricIndexCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_fabricIndexClassName.c_str(), + newElement_1_fabricIndexCtorSignature.c_str(), + entry_1.fabricIndex, newElement_1_fabricIndex); + jobject newElement_1_nodeID; + std::string newElement_1_nodeIDClassName = "java/lang/Long"; + std::string newElement_1_nodeIDCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_nodeIDClassName.c_str(), + newElement_1_nodeIDCtorSignature.c_str(), + entry_1.nodeID, newElement_1_nodeID); + jobject newElement_1_endpoint; + std::string newElement_1_endpointClassName = "java/lang/Integer"; + std::string newElement_1_endpointCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_endpointClassName.c_str(), + newElement_1_endpointCtorSignature.c_str(), + entry_1.endpoint, newElement_1_endpoint); + + jclass trustedTimeSourceStructStructClass_2; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct", + trustedTimeSourceStructStructClass_2); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct"); + return nullptr; + } + jmethodID trustedTimeSourceStructStructCtor_2 = + env->GetMethodID(trustedTimeSourceStructStructClass_2, "", + "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (trustedTimeSourceStructStructCtor_2 == nullptr) + { + ChipLogError(Zcl, + "Could not find ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct constructor"); + return nullptr; + } + + newElement_1 = env->NewObject(trustedTimeSourceStructStructClass_2, trustedTimeSourceStructStructCtor_2, + newElement_1_fabricIndex, newElement_1_nodeID, newElement_1_endpoint); + chip::JniReferences::GetInstance().AddToList(value, newElement_1); + } + } + 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 + { + value = env->NewStringUTF(std::string(cppValue.Value().data(), cppValue.Value().size()).c_str()); + } + 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; + newElement_0_nameInsideOptional = + env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + 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::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 066d36bdd1f4d2..976bc26964532d 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -1707,6 +1707,167 @@ 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; + value_name = env->NewStringUTF(std::string(cppValue.name.data(), cppValue.name.size()).c_str()); + + 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/lang/String;)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 caf86b14ed9214..1ac539ddd7bafc 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -14287,6 +14287,884 @@ 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); +} + +CHIPTimeSynchronizationTrustedTimeSourceAttributeCallback::CHIPTimeSynchronizationTrustedTimeSourceAttributeCallback( + 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"); + } +} + +CHIPTimeSynchronizationTrustedTimeSourceAttributeCallback::~CHIPTimeSynchronizationTrustedTimeSourceAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPTimeSynchronizationTrustedTimeSourceAttributeCallback::CallbackFn( + void * context, + const chip::app::DataModel::Nullable> & 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; + if (list.IsNull()) + { + arrayListObj = nullptr; + } + else + { + chip::JniReferences::GetInstance().CreateArrayList(arrayListObj); + + auto iter_arrayListObj_1 = list.Value().begin(); + while (iter_arrayListObj_1.Next()) + { + auto & entry_1 = iter_arrayListObj_1.GetValue(); + jobject newElement_1; + jobject newElement_1_fabricIndex; + std::string newElement_1_fabricIndexClassName = "java/lang/Integer"; + std::string newElement_1_fabricIndexCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_fabricIndexClassName.c_str(), + newElement_1_fabricIndexCtorSignature.c_str(), + entry_1.fabricIndex, newElement_1_fabricIndex); + jobject newElement_1_nodeID; + std::string newElement_1_nodeIDClassName = "java/lang/Long"; + std::string newElement_1_nodeIDCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_nodeIDClassName.c_str(), + newElement_1_nodeIDCtorSignature.c_str(), entry_1.nodeID, + newElement_1_nodeID); + jobject newElement_1_endpoint; + std::string newElement_1_endpointClassName = "java/lang/Integer"; + std::string newElement_1_endpointCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_1_endpointClassName.c_str(), + newElement_1_endpointCtorSignature.c_str(), + entry_1.endpoint, newElement_1_endpoint); + + jclass trustedTimeSourceStructStructClass_2; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct", + trustedTimeSourceStructStructClass_2); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct"); + return; + } + jmethodID trustedTimeSourceStructStructCtor_2 = env->GetMethodID( + trustedTimeSourceStructStructClass_2, "", "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (trustedTimeSourceStructStructCtor_2 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$TimeSynchronizationClusterTrustedTimeSourceStruct constructor"); + return; + } + + newElement_1 = env->NewObject(trustedTimeSourceStructStructClass_2, trustedTimeSourceStructStructCtor_2, + newElement_1_fabricIndex, newElement_1_nodeID, newElement_1_endpoint); + chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_1); + } + } + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +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 + { + javaValue = env->NewStringUTF(std::string(value.Value().data(), value.Value().size()).c_str()); + } + + 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; + newElement_0_nameInsideOptional = + env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + 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); +} + +CHIPBridgedDeviceBasicInformationVendorIDAttributeCallback::CHIPBridgedDeviceBasicInformationVendorIDAttributeCallback( + 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"); + } +} + +CHIPBridgedDeviceBasicInformationVendorIDAttributeCallback::~CHIPBridgedDeviceBasicInformationVendorIDAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPBridgedDeviceBasicInformationVendorIDAttributeCallback::CallbackFn(void * context, chip::VendorId 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/Integer;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + std::string javaValueClassName = "java/lang/Integer"; + std::string javaValueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + static_cast(value), javaValue); + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + 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 68cadaf318e3e4..84f0a7d39d67fb 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -10171,6 +10171,492 @@ 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 TrustedTimeSourceAttributeCallback { + void onSuccess( + @Nullable List valueList); + + 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 readTrustedTimeSourceAttribute(TrustedTimeSourceAttributeCallback callback) { + readTrustedTimeSourceAttribute(chipClusterPtr, callback); + } + + public void subscribeTrustedTimeSourceAttribute( + TrustedTimeSourceAttributeCallback callback, int minInterval, int maxInterval) { + subscribeTrustedTimeSourceAttribute(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 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 readTrustedTimeSourceAttribute( + long chipClusterPtr, TrustedTimeSourceAttributeCallback callback); + + private native void subscribeTrustedTimeSourceAttribute( + long chipClusterPtr, + TrustedTimeSourceAttributeCallback 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 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..b8abcaed17dc2e 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 String name; + + public TimeSynchronizationClusterTimeZoneStatusEvent(Long offset, String 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 3ec024468a2f3d..e5ae87d27f9b54 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,63 @@ 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 == 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"; @@ -4076,6 +4136,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 56810ab1fb2871..5c2940bd311e7c 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -1004,6 +1004,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 OperationalCredentialsClusterFabricDescriptorStruct { public byte[] rootPublicKey; public Integer vendorID; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 68c919e25bb999..c88c7aee62bc84 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -5258,6 +5258,302 @@ 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 DelegatedTimeSynchronizationClusterTrustedTimeSourceAttributeCallback + implements ChipClusters.TimeSynchronizationCluster.TrustedTimeSourceAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess( + @Nullable 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 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 DelegatedBridgedDeviceBasicInformationClusterVendorIDAttributeCallback + implements ChipClusters.BridgedDeviceBasicInformationCluster.VendorIDAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedBridgedDeviceBasicInformationClusterGeneratedCommandListAttributeCallback implements ChipClusters.BridgedDeviceBasicInformationCluster @@ -13394,6 +13690,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) -> @@ -13639,6 +13940,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")); @@ -15295,6 +15597,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 63da4fe4764472..3251787d679bb4 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -3091,6 +3091,164 @@ 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, + }, + 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, @@ -9258,6 +9416,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, @@ -9327,6 +9486,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/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 951c635ea4ebfa..4a000a077ab7d9 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -10962,13 +10962,16 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="UTCTime", Tag=0x00000000, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="granularity", Tag=0x00000001, Type=TimeSynchronization.Enums.GranularityEnum), ClusterObjectFieldDescriptor(Label="timeSource", Tag=0x00000002, Type=typing.Optional[TimeSynchronization.Enums.TimeSourceEnum]), - ClusterObjectFieldDescriptor(Label="trustedTimeNodeId", Tag=0x00000003, Type=typing.Union[Nullable, uint]), - ClusterObjectFieldDescriptor(Label="defaultNtp", Tag=0x00000004, Type=typing.Union[None, Nullable, str]), + ClusterObjectFieldDescriptor(Label="trustedTimeSource", Tag=0x00000003, Type=typing.Union[Nullable, typing.List[TimeSynchronization.Structs.TrustedTimeSourceStruct]]), + ClusterObjectFieldDescriptor(Label="defaultNTP", Tag=0x00000004, Type=typing.Union[None, Nullable, str]), ClusterObjectFieldDescriptor(Label="timeZone", Tag=0x00000005, Type=typing.Optional[typing.List[TimeSynchronization.Structs.TimeZoneStruct]]), ClusterObjectFieldDescriptor(Label="DSTOffset", Tag=0x00000006, Type=typing.Optional[typing.List[TimeSynchronization.Structs.DSTOffsetStruct]]), ClusterObjectFieldDescriptor(Label="localTime", Tag=0x00000007, Type=typing.Union[None, Nullable, uint]), - ClusterObjectFieldDescriptor(Label="timeZoneDatabase", Tag=0x00000008, Type=typing.Optional[bool]), - ClusterObjectFieldDescriptor(Label="ntpServerPort", Tag=0x00000009, Type=typing.Union[None, Nullable, uint]), + ClusterObjectFieldDescriptor(Label="timeZoneDatabase", Tag=0x00000008, Type=typing.Optional[TimeSynchronization.Enums.TimeZoneDatabaseEnum]), + ClusterObjectFieldDescriptor(Label="NTPServerAvailable", Tag=0x00000009, Type=typing.Optional[bool]), + ClusterObjectFieldDescriptor(Label="timeZoneListMaxSize", Tag=0x0000000A, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="DSTOffsetListMaxSize", Tag=0x0000000B, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="supportsDNSResolve", Tag=0x0000000C, Type=typing.Optional[bool]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -10980,13 +10983,16 @@ def descriptor(cls) -> ClusterObjectDescriptor: UTCTime: 'typing.Union[Nullable, uint]' = None granularity: 'TimeSynchronization.Enums.GranularityEnum' = None timeSource: 'typing.Optional[TimeSynchronization.Enums.TimeSourceEnum]' = None - trustedTimeNodeId: 'typing.Union[Nullable, uint]' = None - defaultNtp: 'typing.Union[None, Nullable, str]' = None + trustedTimeSource: 'typing.Union[Nullable, typing.List[TimeSynchronization.Structs.TrustedTimeSourceStruct]]' = None + defaultNTP: 'typing.Union[None, Nullable, str]' = None timeZone: 'typing.Optional[typing.List[TimeSynchronization.Structs.TimeZoneStruct]]' = None DSTOffset: 'typing.Optional[typing.List[TimeSynchronization.Structs.DSTOffsetStruct]]' = None localTime: 'typing.Union[None, Nullable, uint]' = None - timeZoneDatabase: 'typing.Optional[bool]' = None - ntpServerPort: 'typing.Union[None, Nullable, uint]' = None + timeZoneDatabase: 'typing.Optional[TimeSynchronization.Enums.TimeZoneDatabaseEnum]' = None + NTPServerAvailable: 'typing.Optional[bool]' = None + timeZoneListMaxSize: 'typing.Optional[uint]' = None + DSTOffsetListMaxSize: 'typing.Optional[uint]' = None + supportsDNSResolve: 'typing.Optional[bool]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -11007,21 +11013,29 @@ class GranularityEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 5, + class StatusCode(MatterIntEnum): + kTimeNotAccepted = 0x02 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 0, + class TimeSourceEnum(MatterIntEnum): kNone = 0x00 kUnknown = 0x01 kAdmin = 0x02 kNodeTimeCluster = 0x03 - kNonFabricSntp = 0x04 - kNonFabricNtp = 0x05 - kFabricSntp = 0x06 - kFabricNtp = 0x07 - kMixedNtp = 0x08 - kNonFabricSntpNts = 0x09 - kNonFabricNtpNts = 0x0A - kFabricSntpNts = 0x0B - kFabricNtpNts = 0x0C - kMixedNtpNts = 0x0D + kNonMatterSNTP = 0x04 + kNonMatterNTP = 0x05 + kMatterSNTP = 0x06 + kMatterNTP = 0x07 + kMixedNTP = 0x08 + kNonMatterSNTPNTS = 0x09 + kNonMatterNTPNTS = 0x0A + kMatterSNTPNTS = 0x0B + kMatterNTPNTS = 0x0C + kMixedNTPNTS = 0x0D kCloudSource = 0x0E kPtp = 0x0F kGnss = 0x10 @@ -11031,6 +11045,23 @@ class TimeSourceEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 17, + class TimeZoneDatabaseEnum(MatterIntEnum): + kFull = 0x01 + kPartial = 0x02 + kNone = 0x03 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 0, + + class Bitmaps: + class TimeSynchronizationFeature(IntFlag): + kTimeZone = 0x1 + kNTPClient = 0x2 + kNTPServer = 0x4 + kTimeSyncClient = 0x8 + class Structs: @dataclass class DSTOffsetStruct(ClusterObject): @@ -11040,12 +11071,25 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ClusterObjectFieldDescriptor(Label="offset", Tag=0, Type=int), ClusterObjectFieldDescriptor(Label="validStarting", Tag=1, Type=uint), - ClusterObjectFieldDescriptor(Label="validUntil", Tag=2, Type=uint), + ClusterObjectFieldDescriptor(Label="validUntil", Tag=2, Type=typing.Union[Nullable, uint]), ]) offset: 'int' = 0 validStarting: 'uint' = 0 - validUntil: 'uint' = 0 + validUntil: 'typing.Union[Nullable, uint]' = NullValue + + @dataclass + class FabricScopedTrustedTimeSourceStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="nodeID", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="endpoint", Tag=1, Type=uint), + ]) + + nodeID: 'uint' = 0 + endpoint: 'uint' = 0 @dataclass class TimeZoneStruct(ClusterObject): @@ -11062,6 +11106,21 @@ def descriptor(cls) -> ClusterObjectDescriptor: validAt: 'uint' = 0 name: 'typing.Optional[str]' = None + @dataclass + class TrustedTimeSourceStruct(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="nodeID", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="endpoint", Tag=2, Type=uint), + ]) + + fabricIndex: 'uint' = 0 + nodeID: 'uint' = 0 + endpoint: 'uint' = 0 + class Commands: @dataclass class SetUtcTime(ClusterCommand): @@ -11083,6 +11142,86 @@ def descriptor(cls) -> ClusterObjectDescriptor: granularity: 'TimeSynchronization.Enums.GranularityEnum' = 0 timeSource: 'typing.Optional[TimeSynchronization.Enums.TimeSourceEnum]' = None + @dataclass + class SetTrustedTimeSource(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x0038 + command_id: typing.ClassVar[int] = 0x00000001 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="trustedTimeSource", Tag=0, Type=typing.Union[Nullable, TimeSynchronization.Structs.FabricScopedTrustedTimeSourceStruct]), + ]) + + trustedTimeSource: 'typing.Union[Nullable, TimeSynchronization.Structs.FabricScopedTrustedTimeSourceStruct]' = NullValue + + @dataclass + class SetTimeZone(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x0038 + command_id: typing.ClassVar[int] = 0x00000002 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'SetTimeZoneResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="timeZone", Tag=0, Type=typing.List[TimeSynchronization.Structs.TimeZoneStruct]), + ]) + + timeZone: 'typing.List[TimeSynchronization.Structs.TimeZoneStruct]' = field(default_factory=lambda: []) + + @dataclass + class SetTimeZoneResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x0038 + command_id: typing.ClassVar[int] = 0x00000003 + is_client: typing.ClassVar[bool] = False + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="DSTOffsetRequired", Tag=0, Type=bool), + ]) + + DSTOffsetRequired: 'bool' = False + + @dataclass + class SetDSTOffset(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x0038 + command_id: typing.ClassVar[int] = 0x00000004 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="DSTOffset", Tag=0, Type=typing.List[TimeSynchronization.Structs.DSTOffsetStruct]), + ]) + + DSTOffset: 'typing.List[TimeSynchronization.Structs.DSTOffsetStruct]' = field(default_factory=lambda: []) + + @dataclass + class SetDefaultNTP(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x0038 + command_id: typing.ClassVar[int] = 0x00000005 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="defaultNTP", Tag=0, Type=typing.Union[Nullable, str]), + ]) + + defaultNTP: 'typing.Union[Nullable, str]' = NullValue + class Attributes: @dataclass class UTCTime(ClusterAttributeDescriptor): @@ -11133,7 +11272,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.Optional[TimeSynchronization.Enums.TimeSourceEnum]' = None @dataclass - class TrustedTimeNodeId(ClusterAttributeDescriptor): + class TrustedTimeSource(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x0038 @@ -11144,12 +11283,12 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, typing.List[TimeSynchronization.Structs.TrustedTimeSourceStruct]]) - value: 'typing.Union[Nullable, uint]' = NullValue + value: 'typing.Union[Nullable, typing.List[TimeSynchronization.Structs.TrustedTimeSourceStruct]]' = NullValue @dataclass - class DefaultNtp(ClusterAttributeDescriptor): + class DefaultNTP(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x0038 @@ -11222,6 +11361,22 @@ def cluster_id(cls) -> int: def attribute_id(cls) -> int: return 0x00000008 + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[TimeSynchronization.Enums.TimeZoneDatabaseEnum]) + + value: 'typing.Optional[TimeSynchronization.Enums.TimeZoneDatabaseEnum]' = None + + @dataclass + class NTPServerAvailable(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000009 + @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: return ClusterObjectFieldDescriptor(Type=typing.Optional[bool]) @@ -11229,20 +11384,52 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.Optional[bool]' = None @dataclass - class NtpServerPort(ClusterAttributeDescriptor): + class TimeZoneListMaxSize(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x0038 @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x00000009 + return 0x0000000A @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, uint]) + return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - value: 'typing.Union[None, Nullable, uint]' = None + value: 'typing.Optional[uint]' = None + + @dataclass + class DSTOffsetListMaxSize(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000000B + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) + + value: 'typing.Optional[uint]' = None + + @dataclass + class SupportsDNSResolve(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0000000C + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[bool]) + + value: 'typing.Optional[bool]' = None @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @@ -11340,6 +11527,95 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 + class Events: + @dataclass + class DSTTableEmpty(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ]) + + @dataclass + class DSTStatus(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="DSTOffsetActive", Tag=0, Type=bool), + ]) + + DSTOffsetActive: 'bool' = False + + @dataclass + class TimeZoneStatus(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="offset", Tag=0, Type=int), + ClusterObjectFieldDescriptor(Label="name", Tag=1, Type=str), + ]) + + offset: 'int' = 0 + name: 'str' = "" + + @dataclass + class TimeFailure(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000003 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ]) + + @dataclass + class MissingTrustedTimeSource(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x0038 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000004 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ]) + @dataclass class BridgedDeviceBasicInformation(Cluster): diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 568ea996ca72d5..1bb3ca684590c4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -6282,6 +6282,340 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & } break; } + case Clusters::TimeSynchronization::Id: { + using namespace Clusters::TimeSynchronization; + switch (aPath.mAttributeId) { + case Attributes::UTCTime::Id: { + using TypeInfo = Attributes::UTCTime::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::Granularity::Id: { + using TypeInfo = Attributes::Granularity::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::TimeSource::Id: { + using TypeInfo = Attributes::TimeSource::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::TrustedTimeSource::Id: { + using TypeInfo = Attributes::TrustedTimeSource::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = cppValue.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRTimeSynchronizationClusterTrustedTimeSourceStruct * newElement_1; + newElement_1 = [MTRTimeSynchronizationClusterTrustedTimeSourceStruct new]; + newElement_1.fabricIndex = [NSNumber numberWithUnsignedChar:entry_1.fabricIndex]; + newElement_1.nodeID = [NSNumber numberWithUnsignedLongLong:entry_1.nodeID]; + newElement_1.endpoint = [NSNumber numberWithUnsignedShort:entry_1.endpoint]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_1; + } + } + return value; + } + case Attributes::DefaultNTP::Id: { + using TypeInfo = Attributes::DefaultNTP::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSString * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [[NSString alloc] initWithBytes:cppValue.Value().data() + length:cppValue.Value().size() + encoding:NSUTF8StringEncoding]; + } + return value; + } + case Attributes::TimeZone::Id: { + using TypeInfo = Attributes::TimeZone::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRTimeSynchronizationClusterTimeZoneStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterTimeZoneStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validAt = [NSNumber numberWithUnsignedLongLong:entry_0.validAt]; + if (entry_0.name.HasValue()) { + newElement_0.name = [[NSString alloc] initWithBytes:entry_0.name.Value().data() + length:entry_0.name.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + newElement_0.name = nil; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::DSTOffset::Id: { + using TypeInfo = Attributes::DSTOffset::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRTimeSynchronizationClusterDSTOffsetStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterDSTOffsetStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validStarting = [NSNumber numberWithUnsignedLongLong:entry_0.validStarting]; + if (entry_0.validUntil.IsNull()) { + newElement_0.validUntil = nil; + } else { + newElement_0.validUntil = [NSNumber numberWithUnsignedLongLong:entry_0.validUntil.Value()]; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::LocalTime::Id: { + using TypeInfo = Attributes::LocalTime::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedLongLong:cppValue.Value()]; + } + return value; + } + case Attributes::TimeZoneDatabase::Id: { + using TypeInfo = Attributes::TimeZoneDatabase::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::NTPServerAvailable::Id: { + using TypeInfo = Attributes::NTPServerAvailable::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithBool:cppValue]; + return value; + } + case Attributes::TimeZoneListMaxSize::Id: { + using TypeInfo = Attributes::TimeZoneListMaxSize::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:cppValue]; + return value; + } + case Attributes::DSTOffsetListMaxSize::Id: { + using TypeInfo = Attributes::DSTOffsetListMaxSize::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:cppValue]; + return value; + } + case Attributes::SupportsDNSResolve::Id: { + using TypeInfo = Attributes::SupportsDNSResolve::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithBool:cppValue]; + return value; + } + case Attributes::GeneratedCommandList::Id: { + using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::AcceptedCommandList::Id: { + using TypeInfo = Attributes::AcceptedCommandList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::AttributeList::Id: { + using TypeInfo = Attributes::AttributeList::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSArray * _Nonnull value; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + value = array_0; + } + return value; + } + case Attributes::FeatureMap::Id: { + using TypeInfo = Attributes::FeatureMap::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedInt:cppValue]; + return value; + } + case Attributes::ClusterRevision::Id: { + using TypeInfo = Attributes::ClusterRevision::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedShort:cppValue]; + return value; + } + default: + *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; + break; + } + break; + } case Clusters::BridgedDeviceBasicInformation::Id: { using namespace Clusters::BridgedDeviceBasicInformation; switch (aPath.mAttributeId) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c2960dafd0aad1..aab75bf865f874 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -5964,6 +5964,276 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @end +/** + * Cluster Time Synchronization + * + * Accurate time is required for a number of reasons, including scheduling, display and validating security materials. + */ +MTR_NEWLY_AVAILABLE +@interface MTRBaseClusterTimeSynchronization : MTRCluster + +- (instancetype _Nullable)initWithDevice:(MTRBaseDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE; + +/** + * Command SetUtcTime + * + * This command MAY be issued by Administrator to set the time. + */ +- (void)setUtcTimeWithParams:(MTRTimeSynchronizationClusterSetUtcTimeParams *)params + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +/** + * Command SetTrustedTimeSource + * + * This command SHALL set TrustedTimeSource. + */ +- (void)setTrustedTimeSourceWithParams:(MTRTimeSynchronizationClusterSetTrustedTimeSourceParams *)params + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +/** + * Command SetTimeZone + * + * This command SHALL set TimeZone. + */ +- (void)setTimeZoneWithParams:(MTRTimeSynchronizationClusterSetTimeZoneParams *)params + completion:(void (^)(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable data, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; +/** + * Command SetDSTOffset + * + * This command SHALL set DSTOffset. + */ +- (void)setDSTOffsetWithParams:(MTRTimeSynchronizationClusterSetDSTOffsetParams *)params + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +/** + * Command SetDefaultNTP + * + * This command is used to set DefaultNTP. + */ +- (void)setDefaultNTPWithParams:(MTRTimeSynchronizationClusterSetDefaultNTPParams *)params + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeUTCTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeUTCTimeWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeUTCTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeGranularityWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeGranularityWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeGranularityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeTimeSourceWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeTimeSourceWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeTimeSourceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeTrustedTimeSourceWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeTrustedTimeSourceWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeTrustedTimeSourceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeDefaultNTPWithCompletion:(void (^)(NSString * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeDefaultNTPWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSString * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeDefaultNTPWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSString * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeTimeZoneWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeTimeZoneWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeTimeZoneWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeDSTOffsetWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +- (void)subscribeAttributeDSTOffsetWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler + API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); ++ (void)readAttributeDSTOffsetWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); + +- (void)readAttributeLocalTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeLocalTimeWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeLocalTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeTimeZoneDatabaseWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeTimeZoneDatabaseWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeTimeZoneDatabaseWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeNTPServerAvailableWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeNTPServerAvailableWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeNTPServerAvailableWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeTimeZoneListMaxSizeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeTimeZoneListMaxSizeWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeTimeZoneListMaxSizeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeDSTOffsetListMaxSizeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeDSTOffsetListMaxSizeWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeDSTOffsetListMaxSizeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeSupportsDNSResolveWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeSupportsDNSResolveWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeSupportsDNSResolveWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE; ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + /** * Cluster Bridged Device Basic Information * @@ -19906,26 +20176,43 @@ typedef NS_ENUM(uint8_t, MTRTimeSynchronizationGranularity) { MTRTimeSynchronizationGranularityMicrosecondsGranularity API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x04, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTRTimeSynchronizationStatusCode) { + MTRTimeSynchronizationStatusCodeTimeNotAccepted MTR_NEWLY_AVAILABLE = 0x02, +} MTR_NEWLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRTimeSynchronizationTimeSource) { MTRTimeSynchronizationTimeSourceNone API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, MTRTimeSynchronizationTimeSourceUnknown API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, MTRTimeSynchronizationTimeSourceAdmin API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, MTRTimeSynchronizationTimeSourceNodeTimeCluster API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, - MTRTimeSynchronizationTimeSourceNonFabricSntp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x04, - MTRTimeSynchronizationTimeSourceNonFabricNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x05, - MTRTimeSynchronizationTimeSourceFabricSntp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x06, - MTRTimeSynchronizationTimeSourceFabricNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x07, - MTRTimeSynchronizationTimeSourceMixedNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x08, - MTRTimeSynchronizationTimeSourceNonFabricSntpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x09, - MTRTimeSynchronizationTimeSourceNonFabricNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0A, - MTRTimeSynchronizationTimeSourceFabricSntpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0B, - MTRTimeSynchronizationTimeSourceFabricNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0C, - MTRTimeSynchronizationTimeSourceMixedNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0D, + MTRTimeSynchronizationTimeSourceNonMatterSNTP MTR_NEWLY_AVAILABLE = 0x04, + MTRTimeSynchronizationTimeSourceNonMatterNTP MTR_NEWLY_AVAILABLE = 0x05, + MTRTimeSynchronizationTimeSourceMatterSNTP MTR_NEWLY_AVAILABLE = 0x06, + MTRTimeSynchronizationTimeSourceMatterNTP MTR_NEWLY_AVAILABLE = 0x07, + MTRTimeSynchronizationTimeSourceMixedNTP MTR_NEWLY_AVAILABLE = 0x08, + MTRTimeSynchronizationTimeSourceNonMatterSNTPNTS MTR_NEWLY_AVAILABLE = 0x09, + MTRTimeSynchronizationTimeSourceNonMatterNTPNTS MTR_NEWLY_AVAILABLE = 0x0A, + MTRTimeSynchronizationTimeSourceMatterSNTPNTS MTR_NEWLY_AVAILABLE = 0x0B, + MTRTimeSynchronizationTimeSourceMatterNTPNTS MTR_NEWLY_AVAILABLE = 0x0C, + MTRTimeSynchronizationTimeSourceMixedNTPNTS MTR_NEWLY_AVAILABLE = 0x0D, MTRTimeSynchronizationTimeSourceCloudSource API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0E, - MTRTimeSynchronizationTimeSourcePtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0F, + MTRTimeSynchronizationTimeSourcePTP MTR_NEWLY_AVAILABLE = 0x0F, MTRTimeSynchronizationTimeSourceGnss API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +typedef NS_ENUM(uint8_t, MTRTimeSynchronizationTimeZoneDatabase) { + MTRTimeSynchronizationTimeZoneDatabaseFull MTR_NEWLY_AVAILABLE = 0x01, + MTRTimeSynchronizationTimeZoneDatabasePartial MTR_NEWLY_AVAILABLE = 0x02, + MTRTimeSynchronizationTimeZoneDatabaseNone MTR_NEWLY_AVAILABLE = 0x03, +} MTR_NEWLY_AVAILABLE; + +typedef NS_OPTIONS(uint32_t, MTRTimeSynchronizationFeature) { + MTRTimeSynchronizationFeatureTimeZone MTR_NEWLY_AVAILABLE = 0x1, + MTRTimeSynchronizationFeatureNTPClient MTR_NEWLY_AVAILABLE = 0x2, + MTRTimeSynchronizationFeatureNTPServer MTR_NEWLY_AVAILABLE = 0x4, + MTRTimeSynchronizationFeatureTimeSyncClient MTR_NEWLY_AVAILABLE = 0x8, +} MTR_NEWLY_AVAILABLE; + typedef NS_OPTIONS(uint32_t, MTRSwitchFeature) { MTRSwitchFeatureLatchingSwitch API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)) = 0x1, MTRSwitchFeatureMomentarySwitch API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)) = 0x2, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 86a9e2d3c69d75..66de5caf25d5cb 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -37379,6 +37379,1067 @@ - (nullable instancetype)initWithDevice:(MTRBaseDevice *)device endpoint:(uint16 @end +@implementation MTRBaseClusterTimeSynchronization + +- (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _device = device; + _endpoint = [endpointID unsignedShortValue]; + } + return self; +} + +- (void)setUtcTimeWithParams:(MTRTimeSynchronizationClusterSetUtcTimeParams *)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(error); + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetUtcTime::Type request; + if (params != nil) { + if (params.timedInvokeTimeoutMs != nil) { + params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX)); + timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue); + } + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + request.utcTime = params.utcTime.unsignedLongLongValue; + request.granularity + = static_cast>(params.granularity.unsignedCharValue); + if (params.timeSource != nil) { + auto & definedValue_0 = request.timeSource.Emplace(); + definedValue_0 + = static_cast>(params.timeSource.unsignedCharValue); + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint, + timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)setTrustedTimeSourceWithParams:(MTRTimeSynchronizationClusterSetTrustedTimeSourceParams *)params + completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(error); + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetTrustedTimeSource::Type request; + if (params != nil) { + if (params.timedInvokeTimeoutMs != nil) { + params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX)); + timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue); + } + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + if (params.trustedTimeSource == nil) { + request.trustedTimeSource.SetNull(); + } else { + auto & nonNullValue_0 = request.trustedTimeSource.SetNonNull(); + nonNullValue_0.nodeID = params.trustedTimeSource.nodeID.unsignedLongLongValue; + nonNullValue_0.endpoint = params.trustedTimeSource.endpoint.unsignedShortValue; + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint, + timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)setTimeZoneWithParams:(MTRTimeSynchronizationClusterSetTimeZoneParams *)params + completion:(void (^)(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable data, + NSError * _Nullable error))completion +{ + // Make a copy of params before we go async. + params = [params copy]; + auto * bridge = new MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge(self.callbackQueue, completion, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, + TimeSynchronizationClusterSetTimeZoneResponseCallbackType successCb, MTRErrorCallback failureCb, + MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetTimeZone::Type request; + if (params != nil) { + if (params.timedInvokeTimeoutMs != nil) { + params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX)); + timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue); + } + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.timeZone.count != 0) { + auto * listHolder_0 = new ListHolder(params.timeZone.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return CHIP_ERROR_INVALID_ARGUMENT; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.timeZone.count; ++i_0) { + if (![params.timeZone[i_0] isKindOfClass:[MTRTimeSynchronizationClusterTimeZoneStruct class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_0 = (MTRTimeSynchronizationClusterTimeZoneStruct *) params.timeZone[i_0]; + listHolder_0->mList[i_0].offset = element_0.offset.intValue; + listHolder_0->mList[i_0].validAt = element_0.validAt.unsignedLongLongValue; + if (element_0.name != nil) { + auto & definedValue_2 = listHolder_0->mList[i_0].name.Emplace(); + definedValue_2 = [self asCharSpan:element_0.name]; + } + } + request.timeZone = ListType_0(listHolder_0->mList, params.timeZone.count); + } else { + request.timeZone = ListType_0(); + } + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint, + timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)setDSTOffsetWithParams:(MTRTimeSynchronizationClusterSetDSTOffsetParams *)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(error); + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetDSTOffset::Type request; + if (params != nil) { + if (params.timedInvokeTimeoutMs != nil) { + params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX)); + timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue); + } + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.dstOffset.count != 0) { + auto * listHolder_0 = new ListHolder(params.dstOffset.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return CHIP_ERROR_INVALID_ARGUMENT; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.dstOffset.count; ++i_0) { + if (![params.dstOffset[i_0] isKindOfClass:[MTRTimeSynchronizationClusterDSTOffsetStruct class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_0 = (MTRTimeSynchronizationClusterDSTOffsetStruct *) params.dstOffset[i_0]; + listHolder_0->mList[i_0].offset = element_0.offset.intValue; + listHolder_0->mList[i_0].validStarting = element_0.validStarting.unsignedLongLongValue; + if (element_0.validUntil == nil) { + listHolder_0->mList[i_0].validUntil.SetNull(); + } else { + auto & nonNullValue_2 = listHolder_0->mList[i_0].validUntil.SetNonNull(); + nonNullValue_2 = element_0.validUntil.unsignedLongLongValue; + } + } + request.DSTOffset = ListType_0(listHolder_0->mList, params.dstOffset.count); + } else { + request.DSTOffset = ListType_0(); + } + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint, + timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)setDefaultNTPWithParams:(MTRTimeSynchronizationClusterSetDefaultNTPParams *)params + completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(error); + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetDefaultNTP::Type request; + if (params != nil) { + if (params.timedInvokeTimeoutMs != nil) { + params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX)); + timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue); + } + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + if (params.defaultNTP == nil) { + request.defaultNTP.SetNull(); + } else { + auto & nonNullValue_0 = request.defaultNTP.SetNonNull(); + nonNullValue_0 = [self asCharSpan:params.defaultNTP]; + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint, + timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)readAttributeUTCTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::UTCTime::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeUTCTimeWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::UTCTime::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeUTCTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRNullableInt64uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(NullableInt64uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::UTCTime::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeGranularityWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::Granularity::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeGranularityWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::Granularity::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeGranularityWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationClusterGranularityEnumAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationClusterGranularityEnumAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::Granularity::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeTimeSourceWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::TimeSource::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeTimeSourceWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::TimeSource::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeTimeSourceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationClusterTimeSourceEnumAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationClusterTimeSourceEnumAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::TimeSource::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeTrustedTimeSourceWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::TrustedTimeSource::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeTrustedTimeSourceWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::TrustedTimeSource::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeTrustedTimeSourceWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationTrustedTimeSourceListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::TrustedTimeSource::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeDefaultNTPWithCompletion:(void (^)(NSString * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::DefaultNTP::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeDefaultNTPWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSString * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::DefaultNTP::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeDefaultNTPWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSString * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRNullableCharStringAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(NullableCharStringAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::DefaultNTP::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeTimeZoneWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::TimeZone::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeTimeZoneWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::TimeZone::TypeInfo; + MTRSubscribeAttribute( + params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeTimeZoneWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationTimeZoneListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::TimeZone::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeDSTOffsetWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::DSTOffset::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeDSTOffsetWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::DSTOffset::TypeInfo; + MTRSubscribeAttribute( + params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeDSTOffsetWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationDSTOffsetListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::DSTOffset::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeLocalTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::LocalTime::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeLocalTimeWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::LocalTime::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeLocalTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRNullableInt64uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(NullableInt64uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::LocalTime::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeTimeZoneDatabaseWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::TimeZoneDatabase::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeTimeZoneDatabaseWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::TimeZoneDatabase::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeTimeZoneDatabaseWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::TimeZoneDatabase::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeNTPServerAvailableWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::NTPServerAvailable::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeNTPServerAvailableWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::NTPServerAvailable::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeNTPServerAvailableWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRBooleanAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(BooleanAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::NTPServerAvailable::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeTimeZoneListMaxSizeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::TimeZoneListMaxSize::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeTimeZoneListMaxSizeWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::TimeZoneListMaxSize::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeTimeZoneListMaxSizeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRInt8uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(Int8uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::TimeZoneListMaxSize::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeDSTOffsetListMaxSizeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::DSTOffsetListMaxSize::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeDSTOffsetListMaxSizeWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::DSTOffsetListMaxSize::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeDSTOffsetListMaxSizeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRInt8uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(Int8uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::DSTOffsetListMaxSize::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeSupportsDNSResolveWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::SupportsDNSResolve::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeSupportsDNSResolveWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::SupportsDNSResolve::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeSupportsDNSResolveWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRBooleanAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(BooleanAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::SupportsDNSResolve::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::GeneratedCommandList::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::GeneratedCommandList::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationGeneratedCommandListListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::GeneratedCommandList::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::AcceptedCommandList::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::AcceptedCommandList::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationAcceptedCommandListListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::AcceptedCommandList::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::AttributeList::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::AttributeList::TypeInfo; + MTRSubscribeAttribute(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, + TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRTimeSynchronizationAttributeListListAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice, + ^(TimeSynchronizationAttributeListListAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::AttributeList::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::FeatureMap::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::FeatureMap::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRInt32uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(Int32uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::FeatureMap::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = TimeSynchronization::Attributes::ClusterRevision::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = TimeSynchronization::Attributes::ClusterRevision::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRInt16uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(Int16uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = TimeSynchronization::Attributes::ClusterRevision::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + +@end + @implementation MTRBaseClusterBridgedDeviceBasicInformation - (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h index da38cd3855be2b..2184a6a4239681 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h @@ -157,6 +157,11 @@ @property (nonatomic, assign, readonly) chip::EndpointId endpoint; @end +@interface MTRBaseClusterTimeSynchronization () +@property (nonatomic, strong, readonly) MTRBaseDevice * device; +@property (nonatomic, assign, readonly) chip::EndpointId endpoint; +@end + @interface MTRBaseClusterBridgedDeviceBasicInformation () @property (nonatomic, strong, readonly) MTRBaseDevice * device; @property (nonatomic, assign, readonly) chip::EndpointId endpoint; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h index f3a7deead776d0..60c6e2271fe1d6 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h @@ -73,6 +73,8 @@ typedef void (*NetworkCommissioningClusterConnectNetworkResponseCallbackType)( void *, const chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetworkResponse::DecodableType &); typedef void (*DiagnosticLogsClusterRetrieveLogsResponseCallbackType)( void *, const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType &); +typedef void (*TimeSynchronizationClusterSetTimeZoneResponseCallbackType)( + void *, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType &); typedef void (*OperationalCredentialsClusterAttestationResponseCallbackType)( void *, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType &); typedef void (*OperationalCredentialsClusterCertificateChainResponseCallbackType)( @@ -342,10 +344,17 @@ typedef void (*TimeSynchronizationClusterGranularityEnumAttributeCallback)( void *, chip::app::Clusters::TimeSynchronization::GranularityEnum); typedef void (*NullableTimeSynchronizationClusterGranularityEnumAttributeCallback)( void *, const chip::app::DataModel::Nullable &); +typedef void (*TimeSynchronizationClusterStatusCodeAttributeCallback)(void *, chip::app::Clusters::TimeSynchronization::StatusCode); +typedef void (*NullableTimeSynchronizationClusterStatusCodeAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); typedef void (*TimeSynchronizationClusterTimeSourceEnumAttributeCallback)(void *, chip::app::Clusters::TimeSynchronization::TimeSourceEnum); typedef void (*NullableTimeSynchronizationClusterTimeSourceEnumAttributeCallback)( void *, const chip::app::DataModel::Nullable &); +typedef void (*TimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallback)( + void *, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum); +typedef void (*NullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallback)( + void *, const chip::app::DataModel::Nullable &); typedef void (*AdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallback)( void *, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum); typedef void (*NullableAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallback)( @@ -794,6 +803,24 @@ typedef void (*EthernetNetworkDiagnosticsAcceptedCommandListListAttributeCallbac void * context, const chip::app::DataModel::DecodableList & data); typedef void (*EthernetNetworkDiagnosticsAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationTrustedTimeSourceListAttributeCallback)( + void * context, + const chip::app::DataModel::Nullable> & 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 (*TimeSynchronizationAttributeListListAttributeCallback)( + void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BridgedDeviceBasicInformationGeneratedCommandListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*BridgedDeviceBasicInformationAcceptedCommandListListAttributeCallback)( @@ -5645,6 +5672,211 @@ class MTREthernetNetworkDiagnosticsAttributeListListAttributeCallbackSubscriptio MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void + OnSuccessFn(void * context, + const chip::app::DataModel::Nullable> & value); +}; + +class MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType> & value); +}; + +class MTRTimeSynchronizationTimeZoneListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationTimeZoneListAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType> & value); +}; + +class MTRTimeSynchronizationDSTOffsetListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationDSTOffsetListAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList & value); +}; + +class MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList & value); +}; + +class MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRTimeSynchronizationAttributeListListAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationAttributeListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationAttributeListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList & value); +}; + +class MTRTimeSynchronizationAttributeListListAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationAttributeListListAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationAttributeListListAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationAttributeListListAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationAttributeListListAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationAttributeListListAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRBridgedDeviceBasicInformationGeneratedCommandListListAttributeCallbackBridge : public MTRCallbackBridge { @@ -11255,6 +11487,21 @@ class MTRDiagnosticLogsClusterRetrieveLogsResponseCallbackBridge const chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsResponse::DecodableType & data); }; +class MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data); +}; + class MTROperationalCredentialsClusterAttestationResponseCallbackBridge : public MTRCallbackBridge { @@ -15597,6 +15844,73 @@ class MTRNullableTimeSynchronizationClusterGranularityEnumAttributeCallbackSubsc MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::TimeSynchronization::StatusCode value); +}; + +class MTRTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge + : public MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge +{ +public: + MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRTimeSynchronizationClusterTimeSourceEnumAttributeCallbackBridge : public MTRCallbackBridge { @@ -15664,6 +15978,77 @@ class MTRNullableTimeSynchronizationClusterTimeSourceEnumAttributeCallbackSubscr MTRSubscriptionEstablishedHandler mEstablishedHandler; }; +class MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, OnSuccessFn){}; + + static void OnSuccessFn(void * context, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum value); +}; + +class MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge + : public MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge +{ +public: + MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + +class MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge + : public MTRCallbackBridge +{ +public: + MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler) : + MTRCallbackBridge(queue, handler, OnSuccessFn){}; + + MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(dispatch_queue_t queue, + ResponseHandler handler, + MTRActionBlock action) : + MTRCallbackBridge(queue, handler, action, + OnSuccessFn){}; + + static void + OnSuccessFn(void * context, + const chip::app::DataModel::Nullable & value); +}; + +class MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge + : public MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge +{ +public: + MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action, + MTRSubscriptionEstablishedHandler establishedHandler) : + MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge(queue, handler, action), + mEstablishedHandler(establishedHandler) + {} + + void OnSubscriptionEstablished(); + using MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::KeepAliveOnCallback; + using MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::OnDone; + +private: + MTRSubscriptionEstablishedHandler mEstablishedHandler; +}; + class MTRAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallbackBridge : public MTRCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm index 2dd1e11290d64c..7db0a093226441 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm @@ -5105,6 +5105,260 @@ } } +void MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::Nullable> & value) +{ + NSArray * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + { // Scope for our temporary variables + auto * array_1 = [NSMutableArray new]; + auto iter_1 = value.Value().begin(); + while (iter_1.Next()) { + auto & entry_1 = iter_1.GetValue(); + MTRTimeSynchronizationClusterTrustedTimeSourceStruct * newElement_1; + newElement_1 = [MTRTimeSynchronizationClusterTrustedTimeSourceStruct new]; + newElement_1.fabricIndex = [NSNumber numberWithUnsignedChar:entry_1.fabricIndex]; + newElement_1.nodeID = [NSNumber numberWithUnsignedLongLong:entry_1.nodeID]; + newElement_1.endpoint = [NSNumber numberWithUnsignedShort:entry_1.endpoint]; + [array_1 addObject:newElement_1]; + } + CHIP_ERROR err = iter_1.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_1; + } + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationTrustedTimeSourceListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRTimeSynchronizationTimeZoneListAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList & + value) +{ + NSArray * _Nonnull objCValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRTimeSynchronizationClusterTimeZoneStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterTimeZoneStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validAt = [NSNumber numberWithUnsignedLongLong:entry_0.validAt]; + if (entry_0.name.HasValue()) { + newElement_0.name = [[NSString alloc] initWithBytes:entry_0.name.Value().data() + length:entry_0.name.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + newElement_0.name = nil; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_0; + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationTimeZoneListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRTimeSynchronizationDSTOffsetListAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList & + value) +{ + NSArray * _Nonnull objCValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + MTRTimeSynchronizationClusterDSTOffsetStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterDSTOffsetStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validStarting = [NSNumber numberWithUnsignedLongLong:entry_0.validStarting]; + if (entry_0.validUntil.IsNull()) { + newElement_0.validUntil = nil; + } else { + newElement_0.validUntil = [NSNumber numberWithUnsignedLongLong:entry_0.validUntil.Value()]; + } + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_0; + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationDSTOffsetListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::DecodableList & value) +{ + NSArray * _Nonnull objCValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_0; + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationGeneratedCommandListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::DecodableList & value) +{ + NSArray * _Nonnull objCValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_0; + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationAcceptedCommandListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRTimeSynchronizationAttributeListListAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::DecodableList & value) +{ + NSArray * _Nonnull objCValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedInt:entry_0]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, err); + return; + } + objCValue = array_0; + } + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationAttributeListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRBridgedDeviceBasicInformationGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { @@ -11980,6 +12234,16 @@ DispatchSuccess(context, response); }; +void MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge::OnSuccessFn( + void * context, const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data) +{ + auto * response = [MTRTimeSynchronizationClusterSetTimeZoneResponseParams new]; + { + response.dstOffsetRequired = [NSNumber numberWithBool:data.DSTOffsetRequired]; + } + DispatchSuccess(context, response); +}; + void MTROperationalCredentialsClusterAttestationResponseCallbackBridge::OnSuccessFn( void * context, const chip::app::Clusters::OperationalCredentials::Commands::AttestationResponse::DecodableType & data) { @@ -15922,6 +16186,56 @@ } } +void MTRTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::TimeSynchronization::StatusCode value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableTimeSynchronizationClusterStatusCodeAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRTimeSynchronizationClusterTimeSourceEnumAttributeCallbackBridge::OnSuccessFn( void * context, chip::app::Clusters::TimeSynchronization::TimeSourceEnum value) { @@ -15972,6 +16286,56 @@ } } +void MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::OnSuccessFn( + void * context, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum value) +{ + NSNumber * _Nonnull objCValue; + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)]; + DispatchSuccess(context, objCValue); +}; + +void MTRTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + +void MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackBridge::OnSuccessFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + NSNumber * _Nullable objCValue; + if (value.IsNull()) { + objCValue = nil; + } else { + objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())]; + } + DispatchSuccess(context, objCValue); +}; + +void MTRNullableTimeSynchronizationClusterTimeZoneDatabaseEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished() +{ + if (!mQueue) { + return; + } + + if (mEstablishedHandler != nil) { + dispatch_async(mQueue, mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + mEstablishedHandler = nil; + } +} + void MTRAdministratorCommissioningClusterCommissioningWindowStatusEnumAttributeCallbackBridge::OnSuccessFn( void * context, chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum value) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 03490e7005d0de..a7573a0913d5ec 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -2848,14 +2848,6 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) = 0x00000002, - MTRClusterTimeSynchronizationAttributeTrustedTimeNodeIdID MTR_DEPRECATED( - "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeNodeIdID", ios(16.1, 16.4), macos(13.0, 13.3), - watchos(9.1, 9.4), tvos(16.1, 16.4)) - = 0x00000003, - MTRClusterTimeSynchronizationAttributeDefaultNtpID MTR_DEPRECATED( - "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNtpID", ios(16.1, 16.4), macos(13.0, 13.3), - watchos(9.1, 9.4), tvos(16.1, 16.4)) - = 0x00000004, MTRClusterTimeSynchronizationAttributeTimeZoneID MTR_DEPRECATED( "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @@ -2872,10 +2864,6 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) = 0x00000008, - MTRClusterTimeSynchronizationAttributeNtpServerPortID MTR_DEPRECATED( - "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeNtpServerPortID", ios(16.1, 16.4), macos(13.0, 13.3), - watchos(9.1, 9.4), tvos(16.1, 16.4)) - = 0x00000009, MTRClusterTimeSynchronizationAttributeGeneratedCommandListID MTR_DEPRECATED( "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @@ -2906,12 +2894,8 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeNodeIdID API_AVAILABLE( - ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - = 0x00000003, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNtpID API_AVAILABLE( - ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - = 0x00000004, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000003, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID MTR_NEWLY_AVAILABLE = 0x00000004, MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000005, MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetID API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) @@ -2925,9 +2909,10 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000008, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeNtpServerPortID API_AVAILABLE( - ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - = 0x00000009, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID MTR_NEWLY_AVAILABLE = 0x00000009, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneListMaxSizeID MTR_NEWLY_AVAILABLE = 0x0000000A, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetListMaxSizeID MTR_NEWLY_AVAILABLE = 0x0000000B, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeSupportsDNSResolveID MTR_NEWLY_AVAILABLE = 0x0000000C, MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, @@ -8566,6 +8551,11 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { // Cluster TimeSynchronization commands MTRCommandIDTypeClusterTimeSynchronizationCommandSetUtcTimeID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000000, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000001, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetTimeZoneID MTR_NEWLY_AVAILABLE = 0x00000002, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetTimeZoneResponseID MTR_NEWLY_AVAILABLE = 0x00000003, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetDSTOffsetID MTR_NEWLY_AVAILABLE = 0x00000004, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetDefaultNTPID MTR_NEWLY_AVAILABLE = 0x00000005, // Cluster AdministratorCommissioning deprecated command id names MTRClusterAdministratorCommissioningCommandOpenCommissioningWindowID MTR_DEPRECATED( @@ -9773,6 +9763,15 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, + // Cluster TimeSynchronization deprecated event names + + // Cluster TimeSynchronization events + MTREventIDTypeClusterTimeSynchronizationEventDSTTableEmptyID MTR_NEWLY_AVAILABLE = 0x00000000, + MTREventIDTypeClusterTimeSynchronizationEventDSTStatusID MTR_NEWLY_AVAILABLE = 0x00000001, + MTREventIDTypeClusterTimeSynchronizationEventTimeZoneStatusID MTR_NEWLY_AVAILABLE = 0x00000002, + MTREventIDTypeClusterTimeSynchronizationEventTimeFailureID MTR_NEWLY_AVAILABLE = 0x00000003, + MTREventIDTypeClusterTimeSynchronizationEventMissingTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000004, + // Cluster BridgedDeviceBasic deprecated event names MTRClusterBridgedDeviceBasicEventStartUpID MTR_DEPRECATED( "Please use MTREventIDTypeClusterBridgedDeviceBasicInformationEventStartUpID", ios(16.1, 16.4), macos(13.0, 13.3), diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 9d1d401fe294aa..cd1fe0376a5903 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -2172,6 +2172,81 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @end +/** + * Cluster Time Synchronization + * Accurate time is required for a number of reasons, including scheduling, display and validating security materials. + */ +MTR_NEWLY_AVAILABLE +@interface MTRClusterTimeSynchronization : MTRCluster + +- (instancetype _Nullable)initWithDevice:(MTRDevice *)device + endpointID:(NSNumber *)endpointID + queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE; + +- (void)setUtcTimeWithParams:(MTRTimeSynchronizationClusterSetUtcTimeParams *)params + expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries + expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +- (void)setTrustedTimeSourceWithParams:(MTRTimeSynchronizationClusterSetTrustedTimeSourceParams *)params + expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries + expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +- (void)setTimeZoneWithParams:(MTRTimeSynchronizationClusterSetTimeZoneParams *)params + expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries + expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs + completion:(void (^)(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable data, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; +- (void)setDSTOffsetWithParams:(MTRTimeSynchronizationClusterSetDSTOffsetParams *)params + expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries + expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; +- (void)setDefaultNTPWithParams:(MTRTimeSynchronizationClusterSetDefaultNTPParams *)params + expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries + expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeUTCTimeWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeGranularityWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeTimeSourceWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeTrustedTimeSourceWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeDefaultNTPWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeTimeZoneWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeDSTOffsetWithParams:(MTRReadParams * _Nullable)params + API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); + +- (NSDictionary *)readAttributeLocalTimeWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeTimeZoneDatabaseWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeNTPServerAvailableWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeTimeZoneListMaxSizeWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeDSTOffsetListMaxSizeWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeSupportsDNSResolveWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; + +@end + /** * Cluster Bridged Device Basic Information * This Cluster serves two purposes towards a Node communicating with a Bridge: indicate that the functionality on diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index e13f27f1464c38..c059ac04425d93 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -10187,6 +10187,581 @@ - (void)resetCountsWithExpectedValues:(NSArray *> * } @end +@implementation MTRClusterTimeSynchronization + +- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue +{ + if (self = [super initWithQueue:queue]) { + if (device == nil) { + return nil; + } + + _endpoint = [endpointID unsignedShortValue]; + _device = device; + } + return self; +} + +- (void)setUtcTimeWithParams:(MTRTimeSynchronizationClusterSetUtcTimeParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion +{ + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, + _endpoint, (unsigned int) MTRClusterIDTypeTimeSynchronizationID, + (unsigned int) MTRCommandIDTypeClusterTimeSynchronizationCommandSetUtcTimeID]; + // Make a copy of params before we go async. + params = [params copy]; + NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; + if (timedInvokeTimeoutMsParam) { + timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX)); + } + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue); + MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID + controller:self.device.deviceController]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.device.queue, + ^(id _Nullable value, NSError * _Nullable error) { + MTRClustersLogCompletion(logPrefix, value, error); + dispatch_async(self.callbackQueue, ^{ + completion(error); + }); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetUtcTime::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } + if (params != nil) { + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout + = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + request.utcTime = params.utcTime.unsignedLongLongValue; + request.granularity + = static_cast>(params.granularity.unsignedCharValue); + if (params.timeSource != nil) { + auto & definedValue_0 = request.timeSource.Emplace(); + definedValue_0 + = static_cast>(params.timeSource.unsignedCharValue); + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, + self->_endpoint, timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(baseDevice); + }; + workItem.readyHandler = readyHandler; + MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue); + [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) { + expectedValues = nil; + } else { + expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX)); + } + if (expectedValues) { + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + } +} + +- (void)setTrustedTimeSourceWithParams:(MTRTimeSynchronizationClusterSetTrustedTimeSourceParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion +{ + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, + _endpoint, (unsigned int) MTRClusterIDTypeTimeSynchronizationID, + (unsigned int) MTRCommandIDTypeClusterTimeSynchronizationCommandSetTrustedTimeSourceID]; + // Make a copy of params before we go async. + params = [params copy]; + NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; + if (timedInvokeTimeoutMsParam) { + timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX)); + } + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue); + MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID + controller:self.device.deviceController]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.device.queue, + ^(id _Nullable value, NSError * _Nullable error) { + MTRClustersLogCompletion(logPrefix, value, error); + dispatch_async(self.callbackQueue, ^{ + completion(error); + }); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetTrustedTimeSource::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } + if (params != nil) { + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout + = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + if (params.trustedTimeSource == nil) { + request.trustedTimeSource.SetNull(); + } else { + auto & nonNullValue_0 = request.trustedTimeSource.SetNonNull(); + nonNullValue_0.nodeID = params.trustedTimeSource.nodeID.unsignedLongLongValue; + nonNullValue_0.endpoint = params.trustedTimeSource.endpoint.unsignedShortValue; + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, + self->_endpoint, timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(baseDevice); + }; + workItem.readyHandler = readyHandler; + MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue); + [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) { + expectedValues = nil; + } else { + expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX)); + } + if (expectedValues) { + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + } +} + +- (void)setTimeZoneWithParams:(MTRTimeSynchronizationClusterSetTimeZoneParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completion:(void (^)(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable data, + NSError * _Nullable error))completion +{ + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, + _endpoint, (unsigned int) MTRClusterIDTypeTimeSynchronizationID, + (unsigned int) MTRCommandIDTypeClusterTimeSynchronizationCommandSetTimeZoneID]; + // Make a copy of params before we go async. + params = [params copy]; + NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; + if (timedInvokeTimeoutMsParam) { + timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX)); + } + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue); + MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID + controller:self.device.deviceController]; + auto * bridge = new MTRTimeSynchronizationClusterSetTimeZoneResponseCallbackBridge( + self.device.queue, + ^(id _Nullable value, NSError * _Nullable error) { + MTRClustersLogCompletion(logPrefix, value, error); + dispatch_async(self.callbackQueue, ^{ + completion(value, error); + }); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, + TimeSynchronizationClusterSetTimeZoneResponseCallbackType successCb, MTRErrorCallback failureCb, + MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetTimeZone::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } + if (params != nil) { + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout + = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.timeZone.count != 0) { + auto * listHolder_0 = new ListHolder(params.timeZone.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return CHIP_ERROR_INVALID_ARGUMENT; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.timeZone.count; ++i_0) { + if (![params.timeZone[i_0] isKindOfClass:[MTRTimeSynchronizationClusterTimeZoneStruct class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_0 = (MTRTimeSynchronizationClusterTimeZoneStruct *) params.timeZone[i_0]; + listHolder_0->mList[i_0].offset = element_0.offset.intValue; + listHolder_0->mList[i_0].validAt = element_0.validAt.unsignedLongLongValue; + if (element_0.name != nil) { + auto & definedValue_2 = listHolder_0->mList[i_0].name.Emplace(); + definedValue_2 = [self asCharSpan:element_0.name]; + } + } + request.timeZone = ListType_0(listHolder_0->mList, params.timeZone.count); + } else { + request.timeZone = ListType_0(); + } + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, + self->_endpoint, timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(baseDevice); + }; + workItem.readyHandler = readyHandler; + MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue); + [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) { + expectedValues = nil; + } else { + expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX)); + } + if (expectedValues) { + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + } +} + +- (void)setDSTOffsetWithParams:(MTRTimeSynchronizationClusterSetDSTOffsetParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion +{ + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, + _endpoint, (unsigned int) MTRClusterIDTypeTimeSynchronizationID, + (unsigned int) MTRCommandIDTypeClusterTimeSynchronizationCommandSetDSTOffsetID]; + // Make a copy of params before we go async. + params = [params copy]; + NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; + if (timedInvokeTimeoutMsParam) { + timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX)); + } + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue); + MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID + controller:self.device.deviceController]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.device.queue, + ^(id _Nullable value, NSError * _Nullable error) { + MTRClustersLogCompletion(logPrefix, value, error); + dispatch_async(self.callbackQueue, ^{ + completion(error); + }); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetDSTOffset::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } + if (params != nil) { + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout + = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (params.dstOffset.count != 0) { + auto * listHolder_0 = new ListHolder(params.dstOffset.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return CHIP_ERROR_INVALID_ARGUMENT; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < params.dstOffset.count; ++i_0) { + if (![params.dstOffset[i_0] isKindOfClass:[MTRTimeSynchronizationClusterDSTOffsetStruct class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_0 = (MTRTimeSynchronizationClusterDSTOffsetStruct *) params.dstOffset[i_0]; + listHolder_0->mList[i_0].offset = element_0.offset.intValue; + listHolder_0->mList[i_0].validStarting = element_0.validStarting.unsignedLongLongValue; + if (element_0.validUntil == nil) { + listHolder_0->mList[i_0].validUntil.SetNull(); + } else { + auto & nonNullValue_2 = listHolder_0->mList[i_0].validUntil.SetNonNull(); + nonNullValue_2 = element_0.validUntil.unsignedLongLongValue; + } + } + request.DSTOffset = ListType_0(listHolder_0->mList, params.dstOffset.count); + } else { + request.DSTOffset = ListType_0(); + } + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, + self->_endpoint, timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(baseDevice); + }; + workItem.readyHandler = readyHandler; + MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue); + [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) { + expectedValues = nil; + } else { + expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX)); + } + if (expectedValues) { + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + } +} + +- (void)setDefaultNTPWithParams:(MTRTimeSynchronizationClusterSetDefaultNTPParams *)params + expectedValues:(NSArray *> *)expectedValues + expectedValueInterval:(NSNumber *)expectedValueIntervalMs + completion:(MTRStatusCompletion)completion +{ + NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex, + _endpoint, (unsigned int) MTRClusterIDTypeTimeSynchronizationID, + (unsigned int) MTRCommandIDTypeClusterTimeSynchronizationCommandSetDefaultNTPID]; + // Make a copy of params before we go async. + params = [params copy]; + NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs; + if (timedInvokeTimeoutMsParam) { + timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX)); + } + MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue]; + MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { + MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue); + MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID + controller:self.device.deviceController]; + auto * bridge = new MTRCommandSuccessCallbackBridge( + self.device.queue, + ^(id _Nullable value, NSError * _Nullable error) { + MTRClustersLogCompletion(logPrefix, value, error); + dispatch_async(self.callbackQueue, ^{ + completion(error); + }); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, CommandSuccessCallbackType successCb, + MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + auto * typedBridge = static_cast(bridge); + Optional timedInvokeTimeoutMs; + Optional invokeTimeout; + ListFreer listFreer; + TimeSynchronization::Commands::SetDefaultNTP::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } + if (params != nil) { + if (params.serverSideProcessingTimeout != nil) { + // Clamp to a number of seconds that will not overflow 32-bit + // int when converted to ms. + auto * serverSideProcessingTimeout + = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX)); + invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue)); + } + } + if (params.defaultNTP == nil) { + request.defaultNTP.SetNull(); + } else { + auto & nonNullValue_0 = request.defaultNTP.SetNonNull(); + nonNullValue_0 = [self asCharSpan:params.defaultNTP]; + } + + return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, + self->_endpoint, timedInvokeTimeoutMs, invokeTimeout); + }); + std::move(*bridge).DispatchAction(baseDevice); + }; + workItem.readyHandler = readyHandler; + MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue); + [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem]; + + if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) { + expectedValues = nil; + } else { + expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX)); + } + if (expectedValues) { + [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; + } +} + +- (NSDictionary *)readAttributeUTCTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeUTCTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeGranularityWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeGranularityID) + params:params]; +} + +- (NSDictionary *)readAttributeTimeSourceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID) + params:params]; +} + +- (NSDictionary *)readAttributeTrustedTimeSourceWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID) + params:params]; +} + +- (NSDictionary *)readAttributeDefaultNTPWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID) + params:params]; +} + +- (NSDictionary *)readAttributeTimeZoneWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID) + params:params]; +} + +- (NSDictionary *)readAttributeDSTOffsetWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetID) + params:params]; +} + +- (NSDictionary *)readAttributeLocalTimeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeLocalTimeID) + params:params]; +} + +- (NSDictionary *)readAttributeTimeZoneDatabaseWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID) + params:params]; +} + +- (NSDictionary *)readAttributeNTPServerAvailableWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID) + params:params]; +} + +- (NSDictionary *)readAttributeTimeZoneListMaxSizeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneListMaxSizeID) + params:params]; +} + +- (NSDictionary *)readAttributeDSTOffsetListMaxSizeWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetListMaxSizeID) + params:params]; +} + +- (NSDictionary *)readAttributeSupportsDNSResolveWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeSupportsDNSResolveID) + params:params]; +} + +- (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeAcceptedCommandListID) + params:params]; +} + +- (NSDictionary *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeAttributeListID) + params:params]; +} + +- (NSDictionary *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeFeatureMapID) + params:params]; +} + +- (NSDictionary *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(_endpoint) + clusterID:@(MTRClusterIDTypeTimeSynchronizationID) + attributeID:@(MTRAttributeIDTypeClusterTimeSynchronizationAttributeClusterRevisionID) + params:params]; +} + +@end + @implementation MTRClusterBridgedDeviceBasicInformation - (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h index 01db1693d8f8e5..d212c00ba7fb60 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h @@ -158,6 +158,11 @@ @property (nonatomic, readonly) MTRDevice * device; @end +@interface MTRClusterTimeSynchronization () +@property (nonatomic, readonly) uint16_t endpoint; +@property (nonatomic, readonly) MTRDevice * device; +@end + @interface MTRClusterBridgedDeviceBasicInformation () @property (nonatomic, readonly) uint16_t endpoint; @property (nonatomic, readonly) MTRDevice * device; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 2e257f43660372..ed4155e4755e95 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -3046,6 +3046,133 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterSetTrustedTimeSourceParams : NSObject + +@property (nonatomic, copy) + MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct * _Nullable trustedTimeSource MTR_NEWLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterSetTimeZoneParams : NSObject + +@property (nonatomic, copy) NSArray * _Nonnull timeZone MTR_NEWLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterSetTimeZoneResponseParams : NSObject + +@property (nonatomic, copy) NSNumber * _Nonnull dstOffsetRequired MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterSetDSTOffsetParams : NSObject + +@property (nonatomic, copy) NSArray * _Nonnull dstOffset MTR_NEWLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterSetDefaultNTPParams : NSObject + +@property (nonatomic, copy) NSString * _Nullable defaultNTP MTR_NEWLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @interface MTRAdministratorCommissioningClusterOpenCommissioningWindowParams : NSObject diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index b0a66d4e6484ee..bc1bc542de9036 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -3715,6 +3715,155 @@ - (NSString *)description return descriptionString; } +@end +@implementation MTRTimeSynchronizationClusterSetTrustedTimeSourceParams +- (instancetype)init +{ + if (self = [super init]) { + + _trustedTimeSource = nil; + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; + + other.trustedTimeSource = self.trustedTimeSource; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: trustedTimeSource:%@; >", NSStringFromClass([self class]), _trustedTimeSource]; + return descriptionString; +} + +@end +@implementation MTRTimeSynchronizationClusterSetTimeZoneParams +- (instancetype)init +{ + if (self = [super init]) { + + _timeZone = [NSArray array]; + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + + other.timeZone = self.timeZone; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: timeZone:%@; >", NSStringFromClass([self class]), _timeZone]; + return descriptionString; +} + +@end +@implementation MTRTimeSynchronizationClusterSetTimeZoneResponseParams +- (instancetype)init +{ + if (self = [super init]) { + + _dstOffsetRequired = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetTimeZoneResponseParams alloc] init]; + + other.dstOffsetRequired = self.dstOffsetRequired; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: dstOffsetRequired:%@; >", NSStringFromClass([self class]), _dstOffsetRequired]; + return descriptionString; +} + +@end +@implementation MTRTimeSynchronizationClusterSetDSTOffsetParams +- (instancetype)init +{ + if (self = [super init]) { + + _dstOffset = [NSArray array]; + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + + other.dstOffset = self.dstOffset; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: dstOffset:%@; >", NSStringFromClass([self class]), _dstOffset]; + return descriptionString; +} + +@end +@implementation MTRTimeSynchronizationClusterSetDefaultNTPParams +- (instancetype)init +{ + if (self = [super init]) { + + _defaultNTP = nil; + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetDefaultNTPParams alloc] init]; + + other.defaultNTP = self.defaultNTP; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: defaultNTP:%@; >", NSStringFromClass([self class]), _defaultNTP]; + return descriptionString; +} + @end @implementation MTRAdministratorCommissioningClusterOpenCommissioningWindowParams - (instancetype)init diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index d36a169791c077..347e9ec4028ee0 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -1201,6 +1201,95 @@ id MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVReader & aRead } break; } + case Clusters::TimeSynchronization::Id: { + using namespace Clusters::TimeSynchronization; + switch (aPath.mEventId) { + + case Events::DSTTableEmpty::Id: { + Events::DSTTableEmpty::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRTimeSynchronizationClusterDSTTableEmptyEvent new]; + + return value; + } + + case Events::DSTStatus::Id: { + Events::DSTStatus::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRTimeSynchronizationClusterDSTStatusEvent new]; + + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithBool:cppValue.DSTOffsetActive]; + value.dstOffsetActive = memberValue; + } while (0); + + return value; + } + + case Events::TimeZoneStatus::Id: { + Events::TimeZoneStatus::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRTimeSynchronizationClusterTimeZoneStatusEvent new]; + + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithInt:cppValue.offset]; + value.offset = memberValue; + } while (0); + do { + NSString * _Nonnull memberValue; + memberValue = [[NSString alloc] initWithBytes:cppValue.name.data() + length:cppValue.name.size() + encoding:NSUTF8StringEncoding]; + value.name = memberValue; + } while (0); + + return value; + } + + case Events::TimeFailure::Id: { + Events::TimeFailure::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRTimeSynchronizationClusterTimeFailureEvent new]; + + return value; + } + + case Events::MissingTrustedTimeSource::Id: { + Events::MissingTrustedTimeSource::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRTimeSynchronizationClusterMissingTrustedTimeSourceEvent new]; + + return value; + } + + default: + *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; + break; + } + break; + } case Clusters::BridgedDeviceBasicInformation::Id: { using namespace Clusters::BridgedDeviceBasicInformation; switch (aPath.mEventId) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index ad2c33f3483205..dc36efe3ce0248 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -477,13 +477,19 @@ API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) @interface MTRTimeSynchronizationClusterDSTOffsetStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull offset API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); @property (nonatomic, copy) NSNumber * _Nonnull validStarting API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); -@property (nonatomic, copy) NSNumber * _Nonnull validUntil API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +@property (nonatomic, copy) NSNumber * _Nullable validUntil API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); @end MTR_DEPRECATED("Please use MTRTimeSynchronizationClusterDSTOffsetStruct", ios(16.1, 16.5), macos(13.0, 13.4), watchos(9.1, 9.5), tvos(16.1, 16.5)) @interface MTRTimeSynchronizationClusterDstOffsetType : MTRTimeSynchronizationClusterDSTOffsetStruct @end +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull nodeID MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull endpoint MTR_NEWLY_AVAILABLE; +@end + API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) @interface MTRTimeSynchronizationClusterTimeZoneStruct : NSObject @property (nonatomic, copy) NSNumber * _Nonnull offset API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); @@ -495,6 +501,35 @@ MTR_DEPRECATED("Please use MTRTimeSynchronizationClusterTimeZoneStruct", ios(16. tvos(16.1, 16.5)) @interface MTRTimeSynchronizationClusterTimeZoneType : MTRTimeSynchronizationClusterTimeZoneStruct @end +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterTrustedTimeSourceStruct : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull fabricIndex MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull nodeID MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull endpoint MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterDSTTableEmptyEvent : NSObject +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterDSTStatusEvent : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull dstOffsetActive MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterTimeZoneStatusEvent : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull offset MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSString * _Nonnull name MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterTimeFailureEvent : NSObject +@end + +MTR_NEWLY_AVAILABLE +@interface MTRTimeSynchronizationClusterMissingTrustedTimeSourceEvent : NSObject +@end API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @interface MTRBridgedDeviceBasicInformationClusterStartUpEvent : NSObject diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index f1022f235eaede..3f0ac452632de9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -1820,7 +1820,7 @@ - (instancetype)init _validStarting = @(0); - _validUntil = @(0); + _validUntil = nil; } return self; } @@ -1848,6 +1848,37 @@ - (NSString *)description @implementation MTRTimeSynchronizationClusterDstOffsetType : MTRTimeSynchronizationClusterDSTOffsetStruct @end +@implementation MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct +- (instancetype)init +{ + if (self = [super init]) { + + _nodeID = @(0); + + _endpoint = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct alloc] init]; + + other.nodeID = self.nodeID; + other.endpoint = self.endpoint; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: nodeID:%@; endpoint:%@; >", NSStringFromClass([self class]), _nodeID, _endpoint]; + return descriptionString; +} + +@end + @implementation MTRTimeSynchronizationClusterTimeZoneStruct - (instancetype)init { @@ -1885,6 +1916,168 @@ - (NSString *)description @implementation MTRTimeSynchronizationClusterTimeZoneType : MTRTimeSynchronizationClusterTimeZoneStruct @end +@implementation MTRTimeSynchronizationClusterTrustedTimeSourceStruct +- (instancetype)init +{ + if (self = [super init]) { + + _fabricIndex = @(0); + + _nodeID = @(0); + + _endpoint = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterTrustedTimeSourceStruct alloc] init]; + + other.fabricIndex = self.fabricIndex; + other.nodeID = self.nodeID; + other.endpoint = self.endpoint; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: fabricIndex:%@; nodeID:%@; endpoint:%@; >", + NSStringFromClass([self class]), _fabricIndex, _nodeID, _endpoint]; + return descriptionString; +} + +@end + +@implementation MTRTimeSynchronizationClusterDSTTableEmptyEvent +- (instancetype)init +{ + if (self = [super init]) { + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterDSTTableEmptyEvent alloc] init]; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; + return descriptionString; +} + +@end + +@implementation MTRTimeSynchronizationClusterDSTStatusEvent +- (instancetype)init +{ + if (self = [super init]) { + + _dstOffsetActive = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterDSTStatusEvent alloc] init]; + + other.dstOffsetActive = self.dstOffsetActive; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: dstOffsetActive:%@; >", NSStringFromClass([self class]), _dstOffsetActive]; + return descriptionString; +} + +@end + +@implementation MTRTimeSynchronizationClusterTimeZoneStatusEvent +- (instancetype)init +{ + if (self = [super init]) { + + _offset = @(0); + + _name = @""; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterTimeZoneStatusEvent alloc] init]; + + other.offset = self.offset; + other.name = self.name; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: offset:%@; name:%@; >", NSStringFromClass([self class]), _offset, _name]; + return descriptionString; +} + +@end + +@implementation MTRTimeSynchronizationClusterTimeFailureEvent +- (instancetype)init +{ + if (self = [super init]) { + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterTimeFailureEvent alloc] init]; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; + return descriptionString; +} + +@end + +@implementation MTRTimeSynchronizationClusterMissingTrustedTimeSourceEvent +- (instancetype)init +{ + if (self = [super init]) { + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRTimeSynchronizationClusterMissingTrustedTimeSourceEvent alloc] init]; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; + return descriptionString; +} + +@end + @implementation MTRBridgedDeviceBasicInformationClusterStartUpEvent - (instancetype)init { 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 4052c17a446bfa..886d4c3848fae2 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1366,52 +1366,19 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #endif /** - * @brief The minimum number of scenes to support according to spec - */ -#ifndef CHIP_CONFIG_SCENES_MAX_NUMBER -#define CHIP_CONFIG_SCENES_MAX_NUMBER 16 -#endif - -/** - * @brief Maximum length of Scene names - */ -#ifndef CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH -#define CHIP_CONFIG_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH 16 -#endif - -/** - * @brief The maximum number of scenes allowed on a single fabric - */ -#ifndef CHIP_CONFIG_SCENES_MAX_PER_FABRIC -#define CHIP_CONFIG_SCENES_MAX_PER_FABRIC (CHIP_CONFIG_SCENES_MAX_NUMBER / 2) -#endif - -/** - * @brief The maximum number of clusters per scene, defaults to 3 for a typical usecase (onOff + level control + color control - * cluster). Needs to be changed in case a greater number of clusters is chosen. - */ -#ifndef CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE -#define CHIP_CONFIG_SCENES_MAX_CLUSTERS_PER_SCENE 3 -#endif - -/** - * @brief The maximum size of a single extension field set for a single cluster + * @def CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE + * + * Defines the size of the time zone list */ -#ifndef CHIP_CONFIG_SCENES_MAX_EXTENSION_FIELDSET_SIZE_PER_CLUSTER -#define CHIP_CONFIG_SCENES_MAX_EXTENSION_FIELDSET_SIZE_PER_CLUSTER 128 +#ifndef CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE +#define CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE 1 #endif /** - * @def CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS + * @def CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE * - * @brief Defines the number of simultaneous Scenes iterators that can be allocated - * - * Number of iterator instances that can be allocated at any one time + * Defines the size of the DSTOffset list */ -#ifndef CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS -#define CHIP_CONFIG_MAX_SCENES_CONCURRENT_ITERATORS 2 +#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..c79f3bd8a04408 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -198,12 +198,11 @@ class DefaultStorageKeyAllocator } static StorageKeyName SubscriptionResumptionMaxCount() { return StorageKeyName::Formatted("g/sum"); } - static StorageKeyName GlobalSceneCountKey() { return StorageKeyName::Formatted("g/scc"); } - static StorageKeyName FabricSceneDataKey(chip::FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/sc", fabric); } - static StorageKeyName FabricSceneKey(chip::FabricIndex fabric, uint8_t id) - { - 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/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index ebd102aded5e53..8f619b65c25c2c 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -9222,60 +9222,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchroniz } // namespace TimeSource -namespace TrustedTimeNodeId { - -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) - { - value.SetNull(); - } - else - { - value.SetNonNull() = Traits::StorageToWorking(temp); - } - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); -} - -EmberAfStatus SetNull(chip::EndpointId endpoint) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_NODE_ID_ATTRIBUTE_TYPE); -} - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace TrustedTimeNodeId - -namespace DefaultNtp { +namespace DefaultNTP { EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { @@ -9321,7 +9268,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl return Set(endpoint, value.Value()); } -} // namespace DefaultNtp +} // namespace DefaultNTP namespace LocalTime { @@ -9378,6 +9325,37 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl namespace TimeZoneDatabase { +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +} // namespace TimeZoneDatabase + +namespace NTPServerAvailable { + EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { using Traits = NumericAttributeTraits; @@ -9405,60 +9383,100 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace TimeZoneDatabase +} // namespace NTPServerAvailable -namespace NtpServerPort { +namespace TimeZoneListMaxSize { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (Traits::IsNullValue(temp)) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { - value.SetNull(); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - else + *value = Traits::StorageToWorking(temp); + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { - value.SetNonNull() = Traits::StorageToWorking(temp); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); +} + +} // namespace TimeZoneListMaxSize + +namespace DSTOffsetListMaxSize { + +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); } -EmberAfStatus SetNull(chip::EndpointId endpoint) +} // namespace DSTOffsetListMaxSize + +namespace SupportsDNSResolve { + +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - using Traits = NumericAttributeTraits; - Traits::StorageType value; - Traits::SetNull(value); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); - return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + *value = Traits::StorageToWorking(temp); + return status; } - -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - if (value.IsNull()) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { - return SetNull(endpoint); + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - return Set(endpoint, value.Value()); + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::TimeSynchronization::Id, Id, writable, ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace NtpServerPort +} // namespace SupportsDNSResolve namespace FeatureMap { diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 510d8bd4cc582b..c39e4ed69a7a42 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1607,19 +1607,12 @@ EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchroniz EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeSourceEnum value); } // namespace TimeSource -namespace TrustedTimeNodeId { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // node_id -EmberAfStatus Set(chip::EndpointId endpoint, chip::NodeId value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace TrustedTimeNodeId - -namespace DefaultNtp { +namespace DefaultNTP { EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // char_string EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); EmberAfStatus SetNull(chip::EndpointId endpoint); EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace DefaultNtp +} // namespace DefaultNTP namespace LocalTime { EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // epoch_us @@ -1629,16 +1622,30 @@ EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullabl } // namespace LocalTime namespace TimeZoneDatabase { +EmberAfStatus Get(chip::EndpointId endpoint, + chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum * value); // TimeZoneDatabaseEnum +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum value); +} // namespace TimeZoneDatabase + +namespace NTPServerAvailable { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); -} // namespace TimeZoneDatabase +} // namespace NTPServerAvailable -namespace NtpServerPort { -EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -EmberAfStatus SetNull(chip::EndpointId endpoint); -EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -} // namespace NtpServerPort +namespace TimeZoneListMaxSize { +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +} // namespace TimeZoneListMaxSize + +namespace DSTOffsetListMaxSize { +EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +} // namespace DSTOffsetListMaxSize + +namespace SupportsDNSResolve { +EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean +EmberAfStatus Set(chip::EndpointId endpoint, bool value); +} // namespace SupportsDNSResolve namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index f28ebdafecf988..5048181ab78ba0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -6530,6 +6530,35 @@ bool emberAfEthernetNetworkDiagnosticsClusterResetCountsCallback( bool emberAfTimeSynchronizationClusterSetUtcTimeCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::TimeSynchronization::Commands::SetUtcTime::DecodableType & commandData); +/** + * @brief Time Synchronization Cluster SetTrustedTimeSource Command callback (from client) + */ +bool emberAfTimeSynchronizationClusterSetTrustedTimeSourceCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::DecodableType & commandData); +/** + * @brief Time Synchronization Cluster SetTimeZone Command callback (from client) + */ +bool emberAfTimeSynchronizationClusterSetTimeZoneCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::DecodableType & commandData); +/** + * @brief Time Synchronization Cluster SetTimeZoneResponse Command callback (from server) + */ +bool emberAfTimeSynchronizationClusterSetTimeZoneResponseCallback(chip::EndpointId endpoint, chip::app::CommandSender * commandObj, + bool DSTOffsetRequired); +/** + * @brief Time Synchronization Cluster SetDSTOffset Command callback (from client) + */ +bool emberAfTimeSynchronizationClusterSetDSTOffsetCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::DecodableType & commandData); +/** + * @brief Time Synchronization Cluster SetDefaultNTP Command callback (from client) + */ +bool emberAfTimeSynchronizationClusterSetDefaultNTPCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TimeSynchronization::Commands::SetDefaultNTP::DecodableType & commandData); /** * @brief Administrator Commissioning Cluster OpenCommissioningWindow Command callback (from client) */ diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index d401935344cecb..e770f7e0c123dc 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1063,6 +1063,17 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Gr return static_cast(5); } } +static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::StatusCode val) +{ + using EnumType = TimeSynchronization::StatusCode; + switch (val) + { + case EnumType::kTimeNotAccepted: + return val; + default: + return static_cast(0); + } +} static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::TimeSourceEnum val) { using EnumType = TimeSynchronization::TimeSourceEnum; @@ -1072,16 +1083,16 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Ti case EnumType::kUnknown: case EnumType::kAdmin: case EnumType::kNodeTimeCluster: - case EnumType::kNonFabricSntp: - case EnumType::kNonFabricNtp: - case EnumType::kFabricSntp: - case EnumType::kFabricNtp: - case EnumType::kMixedNtp: - case EnumType::kNonFabricSntpNts: - case EnumType::kNonFabricNtpNts: - case EnumType::kFabricSntpNts: - case EnumType::kFabricNtpNts: - case EnumType::kMixedNtpNts: + case EnumType::kNonMatterSNTP: + case EnumType::kNonMatterNTP: + case EnumType::kMatterSNTP: + case EnumType::kMatterNTP: + case EnumType::kMixedNTP: + case EnumType::kNonMatterSNTPNTS: + case EnumType::kNonMatterNTPNTS: + case EnumType::kMatterSNTPNTS: + case EnumType::kMatterNTPNTS: + case EnumType::kMixedNTPNTS: case EnumType::kCloudSource: case EnumType::kPtp: case EnumType::kGnss: @@ -1090,6 +1101,19 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::Ti return static_cast(17); } } +static auto __attribute__((unused)) EnsureKnownEnumValue(TimeSynchronization::TimeZoneDatabaseEnum val) +{ + using EnumType = TimeSynchronization::TimeZoneDatabaseEnum; + switch (val) + { + case EnumType::kFull: + case EnumType::kPartial: + case EnumType::kNone: + return val; + default: + return static_cast(0); + } +} static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommissioning::CommissioningWindowStatusEnum val) { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index d9f35548eedd69..c62446387f9a8a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1223,6 +1223,17 @@ enum class GranularityEnum : uint8_t kUnknownEnumValue = 5, }; +// Enum for StatusCode +enum class StatusCode : uint8_t +{ + kTimeNotAccepted = 0x02, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 0, +}; + // Enum for TimeSourceEnum enum class TimeSourceEnum : uint8_t { @@ -1230,16 +1241,16 @@ enum class TimeSourceEnum : uint8_t kUnknown = 0x01, kAdmin = 0x02, kNodeTimeCluster = 0x03, - kNonFabricSntp = 0x04, - kNonFabricNtp = 0x05, - kFabricSntp = 0x06, - kFabricNtp = 0x07, - kMixedNtp = 0x08, - kNonFabricSntpNts = 0x09, - kNonFabricNtpNts = 0x0A, - kFabricSntpNts = 0x0B, - kFabricNtpNts = 0x0C, - kMixedNtpNts = 0x0D, + kNonMatterSNTP = 0x04, + kNonMatterNTP = 0x05, + kMatterSNTP = 0x06, + kMatterNTP = 0x07, + kMixedNTP = 0x08, + kNonMatterSNTPNTS = 0x09, + kNonMatterNTPNTS = 0x0A, + kMatterSNTPNTS = 0x0B, + kMatterNTPNTS = 0x0C, + kMixedNTPNTS = 0x0D, kCloudSource = 0x0E, kPtp = 0x0F, kGnss = 0x10, @@ -1249,6 +1260,28 @@ enum class TimeSourceEnum : uint8_t // enum value. This specific should never be transmitted. kUnknownEnumValue = 17, }; + +// Enum for TimeZoneDatabaseEnum +enum class TimeZoneDatabaseEnum : uint8_t +{ + kFull = 0x01, + kPartial = 0x02, + kNone = 0x03, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 0, +}; + +// Bitmap for TimeSynchronizationFeature +enum class TimeSynchronizationFeature : uint32_t +{ + kTimeZone = 0x1, + kNTPClient = 0x2, + kNTPServer = 0x4, + kTimeSyncClient = 0x8, +}; } // namespace TimeSynchronization namespace BridgedDeviceBasicInformation {} // namespace BridgedDeviceBasicInformation diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index a37e57cacbc576..ec182546befff7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -8078,6 +8078,50 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } // namespace DSTOffsetStruct +namespace FabricScopedTrustedTimeSourceStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kNodeID), nodeID)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kEndpoint), endpoint)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, nodeID)); + break; + case to_underlying(Fields::kEndpoint): + ReturnErrorOnFailure(DataModel::Decode(reader, endpoint)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + + return CHIP_NO_ERROR; +} + +} // namespace FabricScopedTrustedTimeSourceStruct namespace TimeZoneStruct { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { @@ -8126,6 +8170,54 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } // namespace TimeZoneStruct +namespace TrustedTimeSourceStruct { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kFabricIndex), fabricIndex)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kNodeID), nodeID)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kEndpoint), endpoint)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kFabricIndex): + ReturnErrorOnFailure(DataModel::Decode(reader, fabricIndex)); + break; + case to_underlying(Fields::kNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, nodeID)); + break; + case to_underlying(Fields::kEndpoint): + ReturnErrorOnFailure(DataModel::Decode(reader, endpoint)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + + return CHIP_NO_ERROR; +} + +} // namespace TrustedTimeSourceStruct } // namespace Structs namespace Commands { @@ -8174,6 +8266,191 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace SetUtcTime. +namespace SetTrustedTimeSource { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kTrustedTimeSource), trustedTimeSource)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kTrustedTimeSource): + ReturnErrorOnFailure(DataModel::Decode(reader, trustedTimeSource)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace SetTrustedTimeSource. +namespace SetTimeZone { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kTimeZone), timeZone)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kTimeZone): + ReturnErrorOnFailure(DataModel::Decode(reader, timeZone)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace SetTimeZone. +namespace SetTimeZoneResponse { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kDSTOffsetRequired), DSTOffsetRequired)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kDSTOffsetRequired): + ReturnErrorOnFailure(DataModel::Decode(reader, DSTOffsetRequired)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace SetTimeZoneResponse. +namespace SetDSTOffset { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kDSTOffset), DSTOffset)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kDSTOffset): + ReturnErrorOnFailure(DataModel::Decode(reader, DSTOffset)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace SetDSTOffset. +namespace SetDefaultNTP { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kDefaultNTP), defaultNTP)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kDefaultNTP): + ReturnErrorOnFailure(DataModel::Decode(reader, defaultNTP)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace SetDefaultNTP. } // namespace Commands namespace Attributes { @@ -8190,11 +8467,11 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre case Attributes::TimeSource::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, timeSource)); break; - case Attributes::TrustedTimeNodeId::TypeInfo::GetAttributeId(): - ReturnErrorOnFailure(DataModel::Decode(reader, trustedTimeNodeId)); + case Attributes::TrustedTimeSource::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, trustedTimeSource)); break; - case Attributes::DefaultNtp::TypeInfo::GetAttributeId(): - ReturnErrorOnFailure(DataModel::Decode(reader, defaultNtp)); + case Attributes::DefaultNTP::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, defaultNTP)); break; case Attributes::TimeZone::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, timeZone)); @@ -8208,8 +8485,17 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre case Attributes::TimeZoneDatabase::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, timeZoneDatabase)); break; - case Attributes::NtpServerPort::TypeInfo::GetAttributeId(): - ReturnErrorOnFailure(DataModel::Decode(reader, ntpServerPort)); + case Attributes::NTPServerAvailable::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, NTPServerAvailable)); + break; + case Attributes::TimeZoneListMaxSize::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, timeZoneListMaxSize)); + break; + case Attributes::DSTOffsetListMaxSize::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, DSTOffsetListMaxSize)); + break; + case Attributes::SupportsDNSResolve::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, supportsDNSResolve)); break; case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, generatedCommandList)); @@ -8237,7 +8523,185 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } } // namespace Attributes -namespace Events {} // namespace Events +namespace Events { +namespace DSTTableEmpty { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace DSTTableEmpty. +namespace DSTStatus { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kDSTOffsetActive), DSTOffsetActive)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kDSTOffsetActive): + ReturnErrorOnFailure(DataModel::Decode(reader, DSTOffsetActive)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace DSTStatus. +namespace TimeZoneStatus { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kOffset), offset)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(Fields::kName), name)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kOffset): + ReturnErrorOnFailure(DataModel::Decode(reader, offset)); + break; + case to_underlying(Fields::kName): + ReturnErrorOnFailure(DataModel::Decode(reader, name)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TimeZoneStatus. +namespace TimeFailure { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TimeFailure. +namespace MissingTrustedTimeSource { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace MissingTrustedTimeSource. +} // namespace Events } // namespace TimeSynchronization namespace BridgedDeviceBasicInformation { @@ -21600,6 +22064,8 @@ bool CommandIsFabricScoped(ClusterId aCluster, CommandId aCommand) case Clusters::TimeSynchronization::Id: { switch (aCommand) { + case Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::Id: + return true; default: return false; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 076c4097b13647..5f0ad30a94dcd2 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -10271,7 +10271,7 @@ struct Type public: int32_t offset = static_cast(0); uint64_t validStarting = static_cast(0); - uint64_t validUntil = static_cast(0); + DataModel::Nullable validUntil; CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -10283,6 +10283,29 @@ struct Type using DecodableType = Type; } // namespace DSTOffsetStruct +namespace FabricScopedTrustedTimeSourceStruct { +enum class Fields : uint8_t +{ + kNodeID = 0, + kEndpoint = 1, +}; + +struct Type +{ +public: + chip::NodeId nodeID = static_cast(0); + chip::EndpointId endpoint = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +using DecodableType = Type; + +} // namespace FabricScopedTrustedTimeSourceStruct namespace TimeZoneStruct { enum class Fields : uint8_t { @@ -10308,6 +10331,31 @@ struct Type using DecodableType = Type; } // namespace TimeZoneStruct +namespace TrustedTimeSourceStruct { +enum class Fields : uint8_t +{ + kFabricIndex = 0, + kNodeID = 1, + kEndpoint = 2, +}; + +struct Type +{ +public: + chip::FabricIndex fabricIndex = static_cast(0); + chip::NodeId nodeID = static_cast(0); + chip::EndpointId endpoint = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); + + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +using DecodableType = Type; + +} // namespace TrustedTimeSourceStruct } // namespace Structs namespace Commands { @@ -10318,6 +10366,31 @@ struct Type; struct DecodableType; } // namespace SetUtcTime +namespace SetTrustedTimeSource { +struct Type; +struct DecodableType; +} // namespace SetTrustedTimeSource + +namespace SetTimeZone { +struct Type; +struct DecodableType; +} // namespace SetTimeZone + +namespace SetTimeZoneResponse { +struct Type; +struct DecodableType; +} // namespace SetTimeZoneResponse + +namespace SetDSTOffset { +struct Type; +struct DecodableType; +} // namespace SetDSTOffset + +namespace SetDefaultNTP { +struct Type; +struct DecodableType; +} // namespace SetDefaultNTP + } // namespace Commands namespace Commands { @@ -10359,6 +10432,166 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace SetUtcTime +namespace SetTrustedTimeSource { +enum class Fields : uint8_t +{ + kTrustedTimeSource = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::SetTrustedTimeSource::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::Nullable trustedTimeSource; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::SetTrustedTimeSource::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::Nullable trustedTimeSource; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace SetTrustedTimeSource +namespace SetTimeZone { +enum class Fields : uint8_t +{ + kTimeZone = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::SetTimeZone::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::List timeZone; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = Clusters::TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::SetTimeZone::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::DecodableList timeZone; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace SetTimeZone +namespace SetTimeZoneResponse { +enum class Fields : uint8_t +{ + kDSTOffsetRequired = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::SetTimeZoneResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + bool DSTOffsetRequired = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::SetTimeZoneResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + bool DSTOffsetRequired = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace SetTimeZoneResponse +namespace SetDSTOffset { +enum class Fields : uint8_t +{ + kDSTOffset = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::SetDSTOffset::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::List DSTOffset; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::SetDSTOffset::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::DecodableList DSTOffset; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace SetDSTOffset +namespace SetDefaultNTP { +enum class Fields : uint8_t +{ + kDefaultNTP = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::SetDefaultNTP::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::Nullable defaultNTP; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::SetDefaultNTP::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + DataModel::Nullable defaultNTP; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace SetDefaultNTP } // namespace Commands namespace Attributes { @@ -10399,19 +10632,22 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace TimeSource -namespace TrustedTimeNodeId { +namespace TrustedTimeSource { struct TypeInfo { - using Type = chip::app::DataModel::Nullable; - using DecodableType = chip::app::DataModel::Nullable; - using DecodableArgType = const chip::app::DataModel::Nullable &; + using Type = chip::app::DataModel::Nullable< + chip::app::DataModel::List>; + using DecodableType = chip::app::DataModel::Nullable>; + using DecodableArgType = const chip::app::DataModel::Nullable> &; static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::TrustedTimeNodeId::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::TrustedTimeSource::Id; } static constexpr bool MustUseTimedWrite() { return false; } }; -} // namespace TrustedTimeNodeId -namespace DefaultNtp { +} // namespace TrustedTimeSource +namespace DefaultNTP { struct TypeInfo { using Type = chip::app::DataModel::Nullable; @@ -10419,11 +10655,11 @@ struct TypeInfo using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::DefaultNtp::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::DefaultNTP::Id; } static constexpr bool MustUseTimedWrite() { return false; } static constexpr size_t MaxLength() { return 128; } }; -} // namespace DefaultNtp +} // namespace DefaultNTP namespace TimeZone { struct TypeInfo { @@ -10466,28 +10702,64 @@ struct TypeInfo } // namespace LocalTime namespace TimeZoneDatabase { struct TypeInfo +{ + using Type = chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum; + using DecodableType = chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum; + using DecodableArgType = chip::app::Clusters::TimeSynchronization::TimeZoneDatabaseEnum; + + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::TimeZoneDatabase::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace TimeZoneDatabase +namespace NTPServerAvailable { +struct TypeInfo { using Type = bool; using DecodableType = bool; using DecodableArgType = bool; static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::TimeZoneDatabase::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::NTPServerAvailable::Id; } static constexpr bool MustUseTimedWrite() { return false; } }; -} // namespace TimeZoneDatabase -namespace NtpServerPort { +} // namespace NTPServerAvailable +namespace TimeZoneListMaxSize { struct TypeInfo { - using Type = chip::app::DataModel::Nullable; - using DecodableType = chip::app::DataModel::Nullable; - using DecodableArgType = const chip::app::DataModel::Nullable &; + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; + + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::TimeZoneListMaxSize::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace TimeZoneListMaxSize +namespace DSTOffsetListMaxSize { +struct TypeInfo +{ + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; + + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::DSTOffsetListMaxSize::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace DSTOffsetListMaxSize +namespace SupportsDNSResolve { +struct TypeInfo +{ + using Type = bool; + using DecodableType = bool; + using DecodableArgType = bool; static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::NtpServerPort::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::SupportsDNSResolve::Id; } static constexpr bool MustUseTimedWrite() { return false; } }; -} // namespace NtpServerPort +} // namespace SupportsDNSResolve namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -10538,13 +10810,17 @@ struct TypeInfo static_cast(0); Attributes::TimeSource::TypeInfo::DecodableType timeSource = static_cast(0); - Attributes::TrustedTimeNodeId::TypeInfo::DecodableType trustedTimeNodeId; - Attributes::DefaultNtp::TypeInfo::DecodableType defaultNtp; + Attributes::TrustedTimeSource::TypeInfo::DecodableType trustedTimeSource; + Attributes::DefaultNTP::TypeInfo::DecodableType defaultNTP; Attributes::TimeZone::TypeInfo::DecodableType timeZone; Attributes::DSTOffset::TypeInfo::DecodableType DSTOffset; Attributes::LocalTime::TypeInfo::DecodableType localTime; - Attributes::TimeZoneDatabase::TypeInfo::DecodableType timeZoneDatabase = static_cast(0); - Attributes::NtpServerPort::TypeInfo::DecodableType ntpServerPort; + Attributes::TimeZoneDatabase::TypeInfo::DecodableType timeZoneDatabase = + static_cast(0); + Attributes::NTPServerAvailable::TypeInfo::DecodableType NTPServerAvailable = static_cast(0); + Attributes::TimeZoneListMaxSize::TypeInfo::DecodableType timeZoneListMaxSize = static_cast(0); + Attributes::DSTOffsetListMaxSize::TypeInfo::DecodableType DSTOffsetListMaxSize = static_cast(0); + Attributes::SupportsDNSResolve::TypeInfo::DecodableType supportsDNSResolve = static_cast(0); Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -10554,6 +10830,161 @@ struct TypeInfo }; }; } // namespace Attributes +namespace Events { +namespace DSTTableEmpty { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::DSTTableEmpty::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::DSTTableEmpty::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace DSTTableEmpty +namespace DSTStatus { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kDSTOffsetActive = 0, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::DSTStatus::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr bool kIsFabricScoped = false; + + bool DSTOffsetActive = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::DSTStatus::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + bool DSTOffsetActive = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace DSTStatus +namespace TimeZoneStatus { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kOffset = 0, + kName = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::TimeZoneStatus::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr bool kIsFabricScoped = false; + + int32_t offset = static_cast(0); + chip::CharSpan name; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::TimeZoneStatus::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + int32_t offset = static_cast(0); + chip::CharSpan name; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace TimeZoneStatus +namespace TimeFailure { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::TimeFailure::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::TimeFailure::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace TimeFailure +namespace MissingTrustedTimeSource { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::MissingTrustedTimeSource::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + static constexpr bool kIsFabricScoped = false; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::MissingTrustedTimeSource::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TimeSynchronization::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace MissingTrustedTimeSource +} // namespace Events } // namespace TimeSynchronization namespace BridgedDeviceBasicInformation { diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 62102d5fed1e5f..4f41acae8400c9 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -1810,13 +1810,13 @@ namespace TimeSource { static constexpr AttributeId Id = 0x00000002; } // namespace TimeSource -namespace TrustedTimeNodeId { +namespace TrustedTimeSource { static constexpr AttributeId Id = 0x00000003; -} // namespace TrustedTimeNodeId +} // namespace TrustedTimeSource -namespace DefaultNtp { +namespace DefaultNTP { static constexpr AttributeId Id = 0x00000004; -} // namespace DefaultNtp +} // namespace DefaultNTP namespace TimeZone { static constexpr AttributeId Id = 0x00000005; @@ -1834,9 +1834,21 @@ namespace TimeZoneDatabase { static constexpr AttributeId Id = 0x00000008; } // namespace TimeZoneDatabase -namespace NtpServerPort { +namespace NTPServerAvailable { static constexpr AttributeId Id = 0x00000009; -} // namespace NtpServerPort +} // namespace NTPServerAvailable + +namespace TimeZoneListMaxSize { +static constexpr AttributeId Id = 0x0000000A; +} // namespace TimeZoneListMaxSize + +namespace DSTOffsetListMaxSize { +static constexpr AttributeId Id = 0x0000000B; +} // namespace DSTOffsetListMaxSize + +namespace SupportsDNSResolve { +static constexpr AttributeId Id = 0x0000000C; +} // namespace SupportsDNSResolve namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 4bf91f56d5eab0..ec6f0e3bcca248 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -484,6 +484,26 @@ namespace SetUtcTime { static constexpr CommandId Id = 0x00000000; } // namespace SetUtcTime +namespace SetTrustedTimeSource { +static constexpr CommandId Id = 0x00000001; +} // namespace SetTrustedTimeSource + +namespace SetTimeZone { +static constexpr CommandId Id = 0x00000002; +} // namespace SetTimeZone + +namespace SetTimeZoneResponse { +static constexpr CommandId Id = 0x00000003; +} // namespace SetTimeZoneResponse + +namespace SetDSTOffset { +static constexpr CommandId Id = 0x00000004; +} // namespace SetDSTOffset + +namespace SetDefaultNTP { +static constexpr CommandId Id = 0x00000005; +} // namespace SetDefaultNTP + } // namespace Commands } // namespace TimeSynchronization diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h index 743778bab8bd1f..598669e8ec2603 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h @@ -175,6 +175,32 @@ static constexpr EventId Id = 0x00000002; } // namespace Events } // namespace WiFiNetworkDiagnostics +namespace TimeSynchronization { +namespace Events { + +namespace DSTTableEmpty { +static constexpr EventId Id = 0x00000000; +} // namespace DSTTableEmpty + +namespace DSTStatus { +static constexpr EventId Id = 0x00000001; +} // namespace DSTStatus + +namespace TimeZoneStatus { +static constexpr EventId Id = 0x00000002; +} // namespace TimeZoneStatus + +namespace TimeFailure { +static constexpr EventId Id = 0x00000003; +} // namespace TimeFailure + +namespace MissingTrustedTimeSource { +static constexpr EventId Id = 0x00000004; +} // namespace MissingTrustedTimeSource + +} // namespace Events +} // namespace TimeSynchronization + namespace BridgedDeviceBasicInformation { namespace Events { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 98e822796ecc4a..dde5d28b88f33b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -2943,18 +2943,25 @@ class EthernetNetworkDiagnosticsResetCounts : public ClusterCommand |------------------------------------------------------------------------------| | Commands: | | | * SetUtcTime | 0x00 | +| * SetTrustedTimeSource | 0x01 | +| * SetTimeZone | 0x02 | +| * SetDSTOffset | 0x04 | +| * SetDefaultNTP | 0x05 | |------------------------------------------------------------------------------| | Attributes: | | | * UTCTime | 0x0000 | | * Granularity | 0x0001 | | * TimeSource | 0x0002 | -| * TrustedTimeNodeId | 0x0003 | -| * DefaultNtp | 0x0004 | +| * TrustedTimeSource | 0x0003 | +| * DefaultNTP | 0x0004 | | * TimeZone | 0x0005 | | * DSTOffset | 0x0006 | | * LocalTime | 0x0007 | | * TimeZoneDatabase | 0x0008 | -| * NtpServerPort | 0x0009 | +| * NTPServerAvailable | 0x0009 | +| * TimeZoneListMaxSize | 0x000A | +| * DSTOffsetListMaxSize | 0x000B | +| * SupportsDNSResolve | 0x000C | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -2963,6 +2970,11 @@ class EthernetNetworkDiagnosticsResetCounts : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * DSTTableEmpty | 0x0000 | +| * DSTStatus | 0x0001 | +| * TimeZoneStatus | 0x0002 | +| * TimeFailure | 0x0003 | +| * MissingTrustedTimeSource | 0x0004 | \*----------------------------------------------------------------------------*/ /* @@ -2997,6 +3009,137 @@ class TimeSynchronizationSetUtcTime : public ClusterCommand chip::app::Clusters::TimeSynchronization::Commands::SetUtcTime::Type mRequest; }; +/* + * Command SetTrustedTimeSource + */ +class TimeSynchronizationSetTrustedTimeSource : public ClusterCommand +{ +public: + TimeSynchronizationSetTrustedTimeSource(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("set-trusted-time-source", credsIssuerConfig), mComplex_TrustedTimeSource(&mRequest.trustedTimeSource) + { + AddArgument("TrustedTimeSource", &mComplex_TrustedTimeSource); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000001) on endpoint %u", endpointIds.at(0)); + + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00000038, 0x00000001, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000001) on Group %u", groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00000038, 0x00000001, mRequest); + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::Type mRequest; + TypedComplexArgument> + mComplex_TrustedTimeSource; +}; + +/* + * Command SetTimeZone + */ +class TimeSynchronizationSetTimeZone : public ClusterCommand +{ +public: + TimeSynchronizationSetTimeZone(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("set-time-zone", credsIssuerConfig), mComplex_TimeZone(&mRequest.timeZone) + { + AddArgument("TimeZone", &mComplex_TimeZone); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000002) on endpoint %u", endpointIds.at(0)); + + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00000038, 0x00000002, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000002) on Group %u", groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00000038, 0x00000002, mRequest); + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::Type mRequest; + TypedComplexArgument> + mComplex_TimeZone; +}; + +/* + * Command SetDSTOffset + */ +class TimeSynchronizationSetDSTOffset : public ClusterCommand +{ +public: + TimeSynchronizationSetDSTOffset(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("set-dstoffset", credsIssuerConfig), mComplex_DSTOffset(&mRequest.DSTOffset) + { + AddArgument("DSTOffset", &mComplex_DSTOffset); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000004) on endpoint %u", endpointIds.at(0)); + + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00000038, 0x00000004, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000004) on Group %u", groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00000038, 0x00000004, mRequest); + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::Type mRequest; + TypedComplexArgument> + mComplex_DSTOffset; +}; + +/* + * Command SetDefaultNTP + */ +class TimeSynchronizationSetDefaultNTP : public ClusterCommand +{ +public: + TimeSynchronizationSetDefaultNTP(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("set-default-ntp", credsIssuerConfig) + { + AddArgument("DefaultNTP", &mRequest.defaultNTP); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000005) on endpoint %u", endpointIds.at(0)); + + return ClusterCommand::SendCommand(device, endpointIds.at(0), 0x00000038, 0x00000005, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000005) on Group %u", groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, 0x00000038, 0x00000005, mRequest); + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetDefaultNTP::Type mRequest; +}; + /*----------------------------------------------------------------------------*\ | Cluster BridgedDeviceBasicInformation | 0x0039 | |------------------------------------------------------------------------------| @@ -11003,53 +11146,66 @@ void registerClusterTimeSynchronization(Commands & commands, CredentialIssuerCom // // Commands // - make_unique(Id, credsIssuerConfig), // - make_unique(credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // // // Attributes // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, "utctime", Attributes::UTCTime::Id, credsIssuerConfig), // - make_unique(Id, "granularity", Attributes::Granularity::Id, credsIssuerConfig), // - make_unique(Id, "time-source", Attributes::TimeSource::Id, credsIssuerConfig), // - make_unique(Id, "trusted-time-node-id", Attributes::TrustedTimeNodeId::Id, credsIssuerConfig), // - make_unique(Id, "default-ntp", Attributes::DefaultNtp::Id, credsIssuerConfig), // - make_unique(Id, "time-zone", Attributes::TimeZone::Id, credsIssuerConfig), // - make_unique(Id, "dstoffset", Attributes::DSTOffset::Id, credsIssuerConfig), // - make_unique(Id, "local-time", Attributes::LocalTime::Id, credsIssuerConfig), // - make_unique(Id, "time-zone-database", Attributes::TimeZoneDatabase::Id, credsIssuerConfig), // - make_unique(Id, "ntp-server-port", Attributes::NtpServerPort::Id, credsIssuerConfig), // - make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // - make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // - make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // - make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // - make_unique>(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "utctime", Attributes::UTCTime::Id, credsIssuerConfig), // + make_unique(Id, "granularity", Attributes::Granularity::Id, credsIssuerConfig), // + make_unique(Id, "time-source", Attributes::TimeSource::Id, credsIssuerConfig), // + make_unique(Id, "trusted-time-source", Attributes::TrustedTimeSource::Id, credsIssuerConfig), // + make_unique(Id, "default-ntp", Attributes::DefaultNTP::Id, credsIssuerConfig), // + make_unique(Id, "time-zone", Attributes::TimeZone::Id, credsIssuerConfig), // + make_unique(Id, "dstoffset", Attributes::DSTOffset::Id, credsIssuerConfig), // + make_unique(Id, "local-time", Attributes::LocalTime::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-database", Attributes::TimeZoneDatabase::Id, credsIssuerConfig), // + make_unique(Id, "ntpserver-available", Attributes::NTPServerAvailable::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-list-max-size", Attributes::TimeZoneListMaxSize::Id, credsIssuerConfig), // + make_unique(Id, "dstoffset-list-max-size", Attributes::DSTOffsetListMaxSize::Id, credsIssuerConfig), // + make_unique(Id, "supports-dnsresolve", Attributes::SupportsDNSResolve::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + make_unique>(Id, credsIssuerConfig), // make_unique>>(Id, "utctime", 0, UINT64_MAX, Attributes::UTCTime::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>( Id, "granularity", 0, UINT8_MAX, Attributes::Granularity::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>( Id, "time-source", 0, UINT8_MAX, Attributes::TimeSource::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "trusted-time-node-id", 0, UINT64_MAX, - Attributes::TrustedTimeNodeId::Id, - WriteCommandType::kWrite, credsIssuerConfig), // - make_unique>>(Id, "default-ntp", Attributes::DefaultNtp::Id, - WriteCommandType::kWrite, credsIssuerConfig), // + make_unique>>>( + Id, "trusted-time-source", Attributes::TrustedTimeSource::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>>( + Id, "default-ntp", Attributes::DefaultNTP::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( - Id, "time-zone", Attributes::TimeZone::Id, WriteCommandType::kWrite, credsIssuerConfig), // + Id, "time-zone", Attributes::TimeZone::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( - Id, "dstoffset", Attributes::DSTOffset::Id, WriteCommandType::kWrite, credsIssuerConfig), // + Id, "dstoffset", Attributes::DSTOffset::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "local-time", 0, UINT64_MAX, Attributes::LocalTime::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "time-zone-database", 0, 1, Attributes::TimeZoneDatabase::Id, + make_unique>( + Id, "time-zone-database", 0, UINT8_MAX, Attributes::TimeZoneDatabase::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // + make_unique>(Id, "ntpserver-available", 0, 1, Attributes::NTPServerAvailable::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "time-zone-list-max-size", 0, UINT8_MAX, Attributes::TimeZoneListMaxSize::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "dstoffset-list-max-size", 0, UINT8_MAX, Attributes::DSTOffsetListMaxSize::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "supports-dnsresolve", 0, 1, Attributes::SupportsDNSResolve::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>>(Id, "ntp-server-port", 0, UINT16_MAX, - Attributes::NtpServerPort::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -11062,29 +11218,42 @@ void registerClusterTimeSynchronization(Commands & commands, CredentialIssuerCom make_unique>(Id, "feature-map", 0, UINT32_MAX, Attributes::FeatureMap::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "cluster-revision", 0, UINT16_MAX, Attributes::ClusterRevision::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, "utctime", Attributes::UTCTime::Id, credsIssuerConfig), // - make_unique(Id, "granularity", Attributes::Granularity::Id, credsIssuerConfig), // - make_unique(Id, "time-source", Attributes::TimeSource::Id, credsIssuerConfig), // - make_unique(Id, "trusted-time-node-id", Attributes::TrustedTimeNodeId::Id, credsIssuerConfig), // - make_unique(Id, "default-ntp", Attributes::DefaultNtp::Id, credsIssuerConfig), // - make_unique(Id, "time-zone", Attributes::TimeZone::Id, credsIssuerConfig), // - make_unique(Id, "dstoffset", Attributes::DSTOffset::Id, credsIssuerConfig), // - make_unique(Id, "local-time", Attributes::LocalTime::Id, credsIssuerConfig), // - make_unique(Id, "time-zone-database", Attributes::TimeZoneDatabase::Id, credsIssuerConfig), // - make_unique(Id, "ntp-server-port", Attributes::NtpServerPort::Id, credsIssuerConfig), // - make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // - make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // - make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // - make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // - make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // + WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "utctime", Attributes::UTCTime::Id, credsIssuerConfig), // + make_unique(Id, "granularity", Attributes::Granularity::Id, credsIssuerConfig), // + make_unique(Id, "time-source", Attributes::TimeSource::Id, credsIssuerConfig), // + make_unique(Id, "trusted-time-source", Attributes::TrustedTimeSource::Id, credsIssuerConfig), // + make_unique(Id, "default-ntp", Attributes::DefaultNTP::Id, credsIssuerConfig), // + make_unique(Id, "time-zone", Attributes::TimeZone::Id, credsIssuerConfig), // + make_unique(Id, "dstoffset", Attributes::DSTOffset::Id, credsIssuerConfig), // + make_unique(Id, "local-time", Attributes::LocalTime::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-database", Attributes::TimeZoneDatabase::Id, credsIssuerConfig), // + make_unique(Id, "ntpserver-available", Attributes::NTPServerAvailable::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-list-max-size", Attributes::TimeZoneListMaxSize::Id, credsIssuerConfig), // + make_unique(Id, "dstoffset-list-max-size", Attributes::DSTOffsetListMaxSize::Id, credsIssuerConfig), // + make_unique(Id, "supports-dnsresolve", Attributes::SupportsDNSResolve::Id, credsIssuerConfig), // + make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // + make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // + make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // + make_unique(Id, "feature-map", Attributes::FeatureMap::Id, credsIssuerConfig), // + make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "dsttable-empty", Events::DSTTableEmpty::Id, credsIssuerConfig), // + make_unique(Id, "dststatus", Events::DSTStatus::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-status", Events::TimeZoneStatus::Id, credsIssuerConfig), // + make_unique(Id, "time-failure", Events::TimeFailure::Id, credsIssuerConfig), // + make_unique(Id, "missing-trusted-time-source", Events::MissingTrustedTimeSource::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "dsttable-empty", Events::DSTTableEmpty::Id, credsIssuerConfig), // + make_unique(Id, "dststatus", Events::DSTStatus::Id, credsIssuerConfig), // + make_unique(Id, "time-zone-status", Events::TimeZoneStatus::Id, credsIssuerConfig), // + make_unique(Id, "time-failure", Events::TimeFailure::Id, credsIssuerConfig), // + make_unique(Id, "missing-trusted-time-source", Events::MissingTrustedTimeSource::Id, credsIssuerConfig), // }; commands.Register(clusterName, clusterCommands); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 859fd542e6cc77..a01df2fc35ade6 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -845,6 +845,39 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials ComplexArgumentParser::Finalize(request.label); ComplexArgumentParser::Finalize(request.fabricIndex); } +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricScopedTrustedTimeSourceStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("FabricScopedTrustedTimeSourceStruct.endpoint", "endpoint", + value.isMember("endpoint"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); + valueCopy.removeMember("nodeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize( + chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.nodeID); + ComplexArgumentParser::Finalize(request.endpoint); +} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value) @@ -2589,6 +2622,44 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::S ComplexArgumentParser::Finalize(request.validAt); ComplexArgumentParser::Finalize(request.name); } +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TrustedTimeSourceStruct.fabricIndex", "fabricIndex", + value.isMember("fabricIndex"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("TrustedTimeSourceStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("TrustedTimeSourceStruct.endpoint", "endpoint", value.isMember("endpoint"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + valueCopy.removeMember("fabricIndex"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); + valueCopy.removeMember("nodeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.nodeID); + ComplexArgumentParser::Finalize(request.endpoint); +} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value) diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 8c0036f996e70c..ade73042e9b749 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -114,6 +114,11 @@ static CHIP_ERROR Setup(const char * label, Json::Value & value); static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request); +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value); @@ -252,6 +257,11 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchroniza Json::Value & value); static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value); 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 578944136f8fdd..2fd6e75af5b036 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -720,6 +720,31 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value) @@ -2346,6 +2371,39 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value) { @@ -3041,6 +3099,70 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Events::DSTTableEmpty::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Events::DSTStatus::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("DSTOffsetActive", indent + 1, value.DSTOffsetActive); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'DSTOffsetActive'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Events::TimeZoneStatus::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Offset", indent + 1, value.offset); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Offset'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("Name", indent + 1, value.name); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Name'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Events::TimeFailure::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const TimeSynchronization::Events::MissingTrustedTimeSource::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const BridgedDeviceBasicInformation::Events::StartUp::DecodableType & value) { @@ -3879,6 +4001,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) { @@ -6367,6 +6497,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> + 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) { @@ -10649,6 +10884,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) { @@ -11106,6 +11352,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 cb1d136ebc92b7..210c42b5256bc2 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -65,6 +65,9 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value); +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, @@ -135,6 +138,8 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::TrustedTimeSourceStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value); @@ -189,6 +194,16 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::WiFiNetworkDiagnostics::Events::AssociationFailure::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::WiFiNetworkDiagnostics::Events::ConnectionStatus::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Events::DSTTableEmpty::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Events::DSTStatus::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Events::TimeZoneStatus::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Events::TimeFailure::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Events::MissingTrustedTimeSource::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::BridgedDeviceBasicInformation::Events::StartUp::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, @@ -321,6 +336,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-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 3c52df46823049..8ceb993789ab26 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -30570,6 +30570,1599 @@ class SubscribeAttributeEthernetNetworkDiagnosticsClusterRevision : public Subsc } }; +/*----------------------------------------------------------------------------*\ +| Cluster TimeSynchronization | 0x0038 | +|------------------------------------------------------------------------------| +| Commands: | | +| * SetUtcTime | 0x00 | +| * SetTrustedTimeSource | 0x01 | +| * SetTimeZone | 0x02 | +| * SetDSTOffset | 0x04 | +| * SetDefaultNTP | 0x05 | +|------------------------------------------------------------------------------| +| Attributes: | | +| * UTCTime | 0x0000 | +| * Granularity | 0x0001 | +| * TimeSource | 0x0002 | +| * TrustedTimeSource | 0x0003 | +| * DefaultNTP | 0x0004 | +| * TimeZone | 0x0005 | +| * DSTOffset | 0x0006 | +| * LocalTime | 0x0007 | +| * TimeZoneDatabase | 0x0008 | +| * NTPServerAvailable | 0x0009 | +| * TimeZoneListMaxSize | 0x000A | +| * DSTOffsetListMaxSize | 0x000B | +| * SupportsDNSResolve | 0x000C | +| * GeneratedCommandList | 0xFFF8 | +| * AcceptedCommandList | 0xFFF9 | +| * EventList | 0xFFFA | +| * AttributeList | 0xFFFB | +| * FeatureMap | 0xFFFC | +| * ClusterRevision | 0xFFFD | +|------------------------------------------------------------------------------| +| Events: | | +| * DSTTableEmpty | 0x0000 | +| * DSTStatus | 0x0001 | +| * TimeZoneStatus | 0x0002 | +| * TimeFailure | 0x0003 | +| * MissingTrustedTimeSource | 0x0004 | +\*----------------------------------------------------------------------------*/ + +/* + * Command SetUtcTime + */ +class TimeSynchronizationSetUtcTime : public ClusterCommand { +public: + TimeSynchronizationSetUtcTime() + : ClusterCommand("set-utc-time") + { + AddArgument("UtcTime", 0, UINT64_MAX, &mRequest.utcTime); + AddArgument("Granularity", 0, UINT8_MAX, &mRequest.granularity); + AddArgument("TimeSource", 0, UINT8_MAX, &mRequest.timeSource); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000000) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRTimeSynchronizationClusterSetUtcTimeParams alloc] init]; + params.timedInvokeTimeoutMs + = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + params.utcTime = [NSNumber numberWithUnsignedLongLong:mRequest.utcTime]; + params.granularity = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.granularity)]; + if (mRequest.timeSource.HasValue()) { + params.timeSource = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.timeSource.Value())]; + } else { + params.timeSource = nil; + } + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster setUtcTimeWithParams:params + completion:^(NSError * _Nullable error) { + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetUtcTime::Type mRequest; +}; + +/* + * Command SetTrustedTimeSource + */ +class TimeSynchronizationSetTrustedTimeSource : public ClusterCommand { +public: + TimeSynchronizationSetTrustedTimeSource() + : ClusterCommand("set-trusted-time-source") + , mComplex_TrustedTimeSource(&mRequest.trustedTimeSource) + { + AddArgument("TrustedTimeSource", &mComplex_TrustedTimeSource); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000001) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; + params.timedInvokeTimeoutMs + = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + if (mRequest.trustedTimeSource.IsNull()) { + params.trustedTimeSource = nil; + } else { + params.trustedTimeSource = [MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct new]; + params.trustedTimeSource.nodeID = [NSNumber numberWithUnsignedLongLong:mRequest.trustedTimeSource.Value().nodeID]; + params.trustedTimeSource.endpoint = [NSNumber numberWithUnsignedShort:mRequest.trustedTimeSource.Value().endpoint]; + } + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster setTrustedTimeSourceWithParams:params + completion:^(NSError * _Nullable error) { + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::Type mRequest; + TypedComplexArgument> + mComplex_TrustedTimeSource; +}; + +/* + * Command SetTimeZone + */ +class TimeSynchronizationSetTimeZone : public ClusterCommand { +public: + TimeSynchronizationSetTimeZone() + : ClusterCommand("set-time-zone") + , mComplex_TimeZone(&mRequest.timeZone) + { + AddArgument("TimeZone", &mComplex_TimeZone); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000002) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + params.timedInvokeTimeoutMs + = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + for (auto & entry_0 : mRequest.timeZone) { + MTRTimeSynchronizationClusterTimeZoneStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterTimeZoneStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validAt = [NSNumber numberWithUnsignedLongLong:entry_0.validAt]; + if (entry_0.name.HasValue()) { + newElement_0.name = [[NSString alloc] initWithBytes:entry_0.name.Value().data() + length:entry_0.name.Value().size() + encoding:NSUTF8StringEncoding]; + } else { + newElement_0.name = nil; + } + [array_0 addObject:newElement_0]; + } + params.timeZone = array_0; + } + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster setTimeZoneWithParams:params + completion:^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, + NSError * _Nullable error) { + NSLog(@"Values: %@", values); + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::Type mRequest; + TypedComplexArgument> + mComplex_TimeZone; +}; + +/* + * Command SetDSTOffset + */ +class TimeSynchronizationSetDSTOffset : public ClusterCommand { +public: + TimeSynchronizationSetDSTOffset() + : ClusterCommand("set-dstoffset") + , mComplex_DSTOffset(&mRequest.DSTOffset) + { + AddArgument("DSTOffset", &mComplex_DSTOffset); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000004) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + params.timedInvokeTimeoutMs + = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + for (auto & entry_0 : mRequest.DSTOffset) { + MTRTimeSynchronizationClusterDSTOffsetStruct * newElement_0; + newElement_0 = [MTRTimeSynchronizationClusterDSTOffsetStruct new]; + newElement_0.offset = [NSNumber numberWithInt:entry_0.offset]; + newElement_0.validStarting = [NSNumber numberWithUnsignedLongLong:entry_0.validStarting]; + if (entry_0.validUntil.IsNull()) { + newElement_0.validUntil = nil; + } else { + newElement_0.validUntil = [NSNumber numberWithUnsignedLongLong:entry_0.validUntil.Value()]; + } + [array_0 addObject:newElement_0]; + } + params.dstOffset = array_0; + } + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster setDSTOffsetWithParams:params + completion:^(NSError * _Nullable error) { + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::Type mRequest; + TypedComplexArgument> + mComplex_DSTOffset; +}; + +/* + * Command SetDefaultNTP + */ +class TimeSynchronizationSetDefaultNTP : public ClusterCommand { +public: + TimeSynchronizationSetDefaultNTP() + : ClusterCommand("set-default-ntp") + { + AddArgument("DefaultNTP", &mRequest.defaultNTP); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) command (0x00000005) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRTimeSynchronizationClusterSetDefaultNTPParams alloc] init]; + params.timedInvokeTimeoutMs + = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + if (mRequest.defaultNTP.IsNull()) { + params.defaultNTP = nil; + } else { + params.defaultNTP = [[NSString alloc] initWithBytes:mRequest.defaultNTP.Value().data() + length:mRequest.defaultNTP.Value().size() + encoding:NSUTF8StringEncoding]; + } + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster setDefaultNTPWithParams:params + completion:^(NSError * _Nullable error) { + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::TimeSynchronization::Commands::SetDefaultNTP::Type mRequest; +}; + +/* + * Attribute UTCTime + */ +class ReadTimeSynchronizationUTCTime : public ReadAttribute { +public: + ReadTimeSynchronizationUTCTime() + : ReadAttribute("utctime") + { + } + + ~ReadTimeSynchronizationUTCTime() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000000) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeUTCTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.UTCTime response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization UTCTime read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationUTCTime : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationUTCTime() + : SubscribeAttribute("utctime") + { + } + + ~SubscribeAttributeTimeSynchronizationUTCTime() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000000) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeUTCTimeWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.UTCTime response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute Granularity + */ +class ReadTimeSynchronizationGranularity : public ReadAttribute { +public: + ReadTimeSynchronizationGranularity() + : ReadAttribute("granularity") + { + } + + ~ReadTimeSynchronizationGranularity() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000001) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeGranularityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.Granularity response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization Granularity read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationGranularity : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationGranularity() + : SubscribeAttribute("granularity") + { + } + + ~SubscribeAttributeTimeSynchronizationGranularity() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000001) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeGranularityWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.Granularity response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute TimeSource + */ +class ReadTimeSynchronizationTimeSource : public ReadAttribute { +public: + ReadTimeSynchronizationTimeSource() + : ReadAttribute("time-source") + { + } + + ~ReadTimeSynchronizationTimeSource() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000002) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeTimeSourceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeSource response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization TimeSource read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationTimeSource : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationTimeSource() + : SubscribeAttribute("time-source") + { + } + + ~SubscribeAttributeTimeSynchronizationTimeSource() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000002) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeTimeSourceWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeSource response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute TrustedTimeSource + */ +class ReadTimeSynchronizationTrustedTimeSource : public ReadAttribute { +public: + ReadTimeSynchronizationTrustedTimeSource() + : ReadAttribute("trusted-time-source") + { + } + + ~ReadTimeSynchronizationTrustedTimeSource() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000003) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeTrustedTimeSourceWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TrustedTimeSource response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization TrustedTimeSource read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationTrustedTimeSource : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationTrustedTimeSource() + : SubscribeAttribute("trusted-time-source") + { + } + + ~SubscribeAttributeTimeSynchronizationTrustedTimeSource() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000003) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeTrustedTimeSourceWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TrustedTimeSource response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute DefaultNTP + */ +class ReadTimeSynchronizationDefaultNTP : public ReadAttribute { +public: + ReadTimeSynchronizationDefaultNTP() + : ReadAttribute("default-ntp") + { + } + + ~ReadTimeSynchronizationDefaultNTP() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000004) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeDefaultNTPWithCompletion:^(NSString * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DefaultNTP response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization DefaultNTP read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationDefaultNTP : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationDefaultNTP() + : SubscribeAttribute("default-ntp") + { + } + + ~SubscribeAttributeTimeSynchronizationDefaultNTP() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000004) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeDefaultNTPWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSString * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DefaultNTP response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute TimeZone + */ +class ReadTimeSynchronizationTimeZone : public ReadAttribute { +public: + ReadTimeSynchronizationTimeZone() + : ReadAttribute("time-zone") + { + } + + ~ReadTimeSynchronizationTimeZone() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000005) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZone response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization TimeZone read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationTimeZone : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationTimeZone() + : SubscribeAttribute("time-zone") + { + } + + ~SubscribeAttributeTimeSynchronizationTimeZone() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000005) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeTimeZoneWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZone response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute DSTOffset + */ +class ReadTimeSynchronizationDSTOffset : public ReadAttribute { +public: + ReadTimeSynchronizationDSTOffset() + : ReadAttribute("dstoffset") + { + } + + ~ReadTimeSynchronizationDSTOffset() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000006) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DSTOffset response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization DSTOffset read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationDSTOffset : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationDSTOffset() + : SubscribeAttribute("dstoffset") + { + } + + ~SubscribeAttributeTimeSynchronizationDSTOffset() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000006) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeDSTOffsetWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DSTOffset response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute LocalTime + */ +class ReadTimeSynchronizationLocalTime : public ReadAttribute { +public: + ReadTimeSynchronizationLocalTime() + : ReadAttribute("local-time") + { + } + + ~ReadTimeSynchronizationLocalTime() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000007) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeLocalTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.LocalTime response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization LocalTime read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationLocalTime : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationLocalTime() + : SubscribeAttribute("local-time") + { + } + + ~SubscribeAttributeTimeSynchronizationLocalTime() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000007) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeLocalTimeWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.LocalTime response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute TimeZoneDatabase + */ +class ReadTimeSynchronizationTimeZoneDatabase : public ReadAttribute { +public: + ReadTimeSynchronizationTimeZoneDatabase() + : ReadAttribute("time-zone-database") + { + } + + ~ReadTimeSynchronizationTimeZoneDatabase() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000008) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeTimeZoneDatabaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZoneDatabase response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization TimeZoneDatabase read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationTimeZoneDatabase : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationTimeZoneDatabase() + : SubscribeAttribute("time-zone-database") + { + } + + ~SubscribeAttributeTimeSynchronizationTimeZoneDatabase() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000008) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeTimeZoneDatabaseWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZoneDatabase response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute NTPServerAvailable + */ +class ReadTimeSynchronizationNTPServerAvailable : public ReadAttribute { +public: + ReadTimeSynchronizationNTPServerAvailable() + : ReadAttribute("ntpserver-available") + { + } + + ~ReadTimeSynchronizationNTPServerAvailable() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x00000009) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeNTPServerAvailableWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.NTPServerAvailable response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization NTPServerAvailable read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationNTPServerAvailable : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationNTPServerAvailable() + : SubscribeAttribute("ntpserver-available") + { + } + + ~SubscribeAttributeTimeSynchronizationNTPServerAvailable() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x00000009) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeNTPServerAvailableWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.NTPServerAvailable response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute TimeZoneListMaxSize + */ +class ReadTimeSynchronizationTimeZoneListMaxSize : public ReadAttribute { +public: + ReadTimeSynchronizationTimeZoneListMaxSize() + : ReadAttribute("time-zone-list-max-size") + { + } + + ~ReadTimeSynchronizationTimeZoneListMaxSize() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000000A) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeTimeZoneListMaxSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZoneListMaxSize response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization TimeZoneListMaxSize read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationTimeZoneListMaxSize : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationTimeZoneListMaxSize() + : SubscribeAttribute("time-zone-list-max-size") + { + } + + ~SubscribeAttributeTimeSynchronizationTimeZoneListMaxSize() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000000A) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeTimeZoneListMaxSizeWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.TimeZoneListMaxSize response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute DSTOffsetListMaxSize + */ +class ReadTimeSynchronizationDSTOffsetListMaxSize : public ReadAttribute { +public: + ReadTimeSynchronizationDSTOffsetListMaxSize() + : ReadAttribute("dstoffset-list-max-size") + { + } + + ~ReadTimeSynchronizationDSTOffsetListMaxSize() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000000B) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeDSTOffsetListMaxSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DSTOffsetListMaxSize response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization DSTOffsetListMaxSize read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationDSTOffsetListMaxSize : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationDSTOffsetListMaxSize() + : SubscribeAttribute("dstoffset-list-max-size") + { + } + + ~SubscribeAttributeTimeSynchronizationDSTOffsetListMaxSize() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000000B) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeDSTOffsetListMaxSizeWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.DSTOffsetListMaxSize response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute SupportsDNSResolve + */ +class ReadTimeSynchronizationSupportsDNSResolve : public ReadAttribute { +public: + ReadTimeSynchronizationSupportsDNSResolve() + : ReadAttribute("supports-dnsresolve") + { + } + + ~ReadTimeSynchronizationSupportsDNSResolve() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000000C) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeSupportsDNSResolveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.SupportsDNSResolve response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization SupportsDNSResolve read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationSupportsDNSResolve : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationSupportsDNSResolve() + : SubscribeAttribute("supports-dnsresolve") + { + } + + ~SubscribeAttributeTimeSynchronizationSupportsDNSResolve() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000000C) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeSupportsDNSResolveWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.SupportsDNSResolve response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute GeneratedCommandList + */ +class ReadTimeSynchronizationGeneratedCommandList : public ReadAttribute { +public: + ReadTimeSynchronizationGeneratedCommandList() + : ReadAttribute("generated-command-list") + { + } + + ~ReadTimeSynchronizationGeneratedCommandList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000FFF8) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.GeneratedCommandList response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization GeneratedCommandList read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationGeneratedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationGeneratedCommandList() + : SubscribeAttribute("generated-command-list") + { + } + + ~SubscribeAttributeTimeSynchronizationGeneratedCommandList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000FFF8) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeGeneratedCommandListWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.GeneratedCommandList response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute AcceptedCommandList + */ +class ReadTimeSynchronizationAcceptedCommandList : public ReadAttribute { +public: + ReadTimeSynchronizationAcceptedCommandList() + : ReadAttribute("accepted-command-list") + { + } + + ~ReadTimeSynchronizationAcceptedCommandList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000FFF9) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.AcceptedCommandList response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization AcceptedCommandList read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationAcceptedCommandList : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationAcceptedCommandList() + : SubscribeAttribute("accepted-command-list") + { + } + + ~SubscribeAttributeTimeSynchronizationAcceptedCommandList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000FFF9) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAcceptedCommandListWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.AcceptedCommandList response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute AttributeList + */ +class ReadTimeSynchronizationAttributeList : public ReadAttribute { +public: + ReadTimeSynchronizationAttributeList() + : ReadAttribute("attribute-list") + { + } + + ~ReadTimeSynchronizationAttributeList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000FFFB) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.AttributeList response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization AttributeList read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationAttributeList : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationAttributeList() + : SubscribeAttribute("attribute-list") + { + } + + ~SubscribeAttributeTimeSynchronizationAttributeList() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000FFFB) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAttributeListWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.AttributeList response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute FeatureMap + */ +class ReadTimeSynchronizationFeatureMap : public ReadAttribute { +public: + ReadTimeSynchronizationFeatureMap() + : ReadAttribute("feature-map") + { + } + + ~ReadTimeSynchronizationFeatureMap() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000FFFC) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.FeatureMap response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization FeatureMap read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationFeatureMap : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationFeatureMap() + : SubscribeAttribute("feature-map") + { + } + + ~SubscribeAttributeTimeSynchronizationFeatureMap() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000FFFC) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeFeatureMapWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.FeatureMap response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +/* + * Attribute ClusterRevision + */ +class ReadTimeSynchronizationClusterRevision : public ReadAttribute { +public: + ReadTimeSynchronizationClusterRevision() + : ReadAttribute("cluster-revision") + { + } + + ~ReadTimeSynchronizationClusterRevision() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReadAttribute (0x0000FFFD) on endpoint %u", endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.ClusterRevision response %@", [value description]); + if (error != nil) { + LogNSError("TimeSynchronization ClusterRevision read Error", error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeTimeSynchronizationClusterRevision : public SubscribeAttribute { +public: + SubscribeAttributeTimeSynchronizationClusterRevision() + : SubscribeAttribute("cluster-revision") + { + } + + ~SubscribeAttributeTimeSynchronizationClusterRevision() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x00000038) ReportAttribute (0x0000FFFD) on endpoint %u", endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeClusterRevisionWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"TimeSynchronization.ClusterRevision response %@", [value description]); + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + /*----------------------------------------------------------------------------*\ | Cluster BridgedDeviceBasicInformation | 0x0039 | |------------------------------------------------------------------------------| @@ -98764,6 +100357,64 @@ void registerClusterEthernetNetworkDiagnostics(Commands & commands) commands.Register(clusterName, clusterCommands); } +void registerClusterTimeSynchronization(Commands & commands) +{ + using namespace chip::app::Clusters::TimeSynchronization; + + const char * clusterName = "TimeSynchronization"; + + commands_list clusterCommands = { + make_unique(Id), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(Id), // + make_unique(), // + make_unique(Id), // + make_unique(Id), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(Id), // + make_unique(Id), // + }; + + commands.Register(clusterName, clusterCommands); +} void registerClusterBridgedDeviceBasicInformation(Commands & commands) { using namespace chip::app::Clusters::BridgedDeviceBasicInformation; @@ -101163,6 +102814,7 @@ void registerClusters(Commands & commands) registerClusterThreadNetworkDiagnostics(commands); registerClusterWiFiNetworkDiagnostics(commands); registerClusterEthernetNetworkDiagnostics(commands); + registerClusterTimeSynchronization(commands); registerClusterBridgedDeviceBasicInformation(commands); registerClusterSwitch(commands); registerClusterAdministratorCommissioning(commands); diff --git a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h index ef6cbd56ee6145..83d3b4aa040736 100644 --- a/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/darwin/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -316,6 +316,26 @@ typedef void (*EthernetNetworkDiagnosticsEventListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); typedef void (*EthernetNetworkDiagnosticsAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +typedef void (*TimeSynchronizationTrustedTimeSourceListAttributeCallback)( + void * context, + const chip::app::DataModel::Nullable> & 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 bc03b37dc2ac4a..b32bf9444e0f5a 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 3d74200cb77c4f..82f4c19043b4f0 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 66 +#define GENERATED_CLUSTER_COUNT 67 // 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, \ @@ -929,7 +942,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 66, 0 }, \ + { ZAP_CLUSTER_INDEX(0), 67, 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 9652d781baf6e5..9d024369df58c9 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) @@ -198,6 +199,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